This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 965e074da8a7f22afaf50bffcbed81f44d0dcc34 Author: Andrus Adamchik <[email protected]> AuthorDate: Thu May 14 10:40:24 2026 -0400 tests cleanup - unwinding DI --- .../org/apache/cayenne/gen/CgenCaseModule.java | 9 +---- .../cayenne/unit/di/DataChannelInterceptor.java | 2 - .../unit/di/runtime/ConnectionProperties.java | 2 +- .../runtime/RuntimeCaseDataChannelInterceptor.java | 7 +--- .../unit/di/runtime/RuntimeCaseExtraModules.java | 44 ---------------------- .../unit/di/runtime/RuntimeCaseProperties.java | 35 ----------------- 6 files changed, 5 insertions(+), 94 deletions(-) diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/CgenCaseModule.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/CgenCaseModule.java index efec37782..204c0c9be 100644 --- a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/CgenCaseModule.java +++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/CgenCaseModule.java @@ -23,8 +23,6 @@ import org.apache.cayenne.di.Binder; import org.apache.cayenne.di.Module; import org.apache.cayenne.di.spi.DefaultScope; import org.apache.cayenne.gen.mock.CustomPropertyDescriptor; -import org.apache.cayenne.unit.di.runtime.RuntimeCaseExtraModules; -import org.apache.cayenne.unit.di.runtime.RuntimeCaseProperties; public class CgenCaseModule implements Module { @@ -33,12 +31,9 @@ public class CgenCaseModule implements Module { public CgenCaseModule(DefaultScope testScope) { this.testScope = testScope; } + @Override public void configure(Binder binder) { - binder.bind(RuntimeCaseProperties.class).to(RuntimeCaseProperties.class).in(testScope); - binder.bind(RuntimeCaseExtraModules.class).to(RuntimeCaseExtraModules.class).in(testScope); - - CgenModule.contributeUserProperties(binder) - .add(CustomPropertyDescriptor.class); + CgenModule.contributeUserProperties(binder).add(CustomPropertyDescriptor.class); } } diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java b/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java index b2822f1a7..2925971e9 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java @@ -27,6 +27,4 @@ public interface DataChannelInterceptor { void runWithQueriesBlocked(UnitTestClosure closure); int runWithQueryCounter(UnitTestClosure closure); - - DataChannelSyncStats runWithSyncStatsCollection(UnitTestClosure closure); } diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/ConnectionProperties.java b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/ConnectionProperties.java index 04d965c2d..b272a02bd 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/ConnectionProperties.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/ConnectionProperties.java @@ -45,7 +45,7 @@ class ConnectionProperties { private static final String URL_KEY = "jdbc.url"; private static final String DRIVER_KEY = "jdbc.driver"; - private Map<String, UnitDataSourceDescriptor> connectionDescriptors; + private final Map<String, UnitDataSourceDescriptor> connectionDescriptors; /** * Constructor for ConnectionProperties. diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java index 729cb1144..e1432629f 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java @@ -22,7 +22,6 @@ import org.apache.cayenne.access.UnitTestDomain; import org.apache.cayenne.di.Provider; import org.apache.cayenne.runtime.CayenneRuntime; import org.apache.cayenne.unit.di.DataChannelInterceptor; -import org.apache.cayenne.unit.di.DataChannelSyncStats; import org.apache.cayenne.unit.di.UnitTestClosure; public class RuntimeCaseDataChannelInterceptor implements DataChannelInterceptor { @@ -33,6 +32,7 @@ public class RuntimeCaseDataChannelInterceptor implements DataChannelInterceptor this.runtimeProvider = runtimeProvider; } + @Override public void runWithQueriesBlocked(UnitTestClosure closure) { UnitTestDomain channel = (UnitTestDomain) runtimeProvider @@ -48,6 +48,7 @@ public class RuntimeCaseDataChannelInterceptor implements DataChannelInterceptor } } + @Override public int runWithQueryCounter(UnitTestClosure closure) { UnitTestDomain channel = (UnitTestDomain) runtimeProvider.get().getChannel(); RuntimeCaseDataNode node = (RuntimeCaseDataNode)channel.getDataNodes().iterator().next(); @@ -61,8 +62,4 @@ public class RuntimeCaseDataChannelInterceptor implements DataChannelInterceptor } return end - start; } - - public DataChannelSyncStats runWithSyncStatsCollection(UnitTestClosure closure) { - throw new UnsupportedOperationException("TODO... so far unused"); - } } diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseExtraModules.java b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseExtraModules.java deleted file mode 100644 index fd854bdb9..000000000 --- a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseExtraModules.java +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.unit.di.runtime; - -import org.apache.cayenne.di.Module; - -import java.util.ArrayList; -import java.util.Collection; - -public class RuntimeCaseExtraModules { - protected Class<?>[] extraModules; - - public Collection<? extends Module> getExtraModules() { - Collection<Module> result = new ArrayList<>(); - for (Class<?> extraModule : extraModules) { - try { - result.add((Module) extraModule.getConstructor().newInstance()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return result; - } - - public void setExtraModules(Class<?>[] extraModules) { - this.extraModules = extraModules; - } -} diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseProperties.java b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseProperties.java deleted file mode 100644 index 13ee8a360..000000000 --- a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseProperties.java +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.unit.di.runtime; - -/** - * Stores various unit test properties. This object should be bound in a unit test scope. - */ -public class RuntimeCaseProperties { - - protected String configurationLocation; - - public String getConfigurationLocation() { - return configurationLocation; - } - - public void setConfigurationLocation(String configurationLocation) { - this.configurationLocation = configurationLocation; - } -}
