diff --git a/license-report.md b/license-report.md index f800f3111c6..151028a4adc 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.5.24` +# Dependencies of `io.spine:spine-client:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -406,12 +406,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:45:58 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-core:1.5.24` +# Dependencies of `io.spine:spine-core:1.5.25` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -777,12 +777,12 @@ This report was generated on **Fri Aug 14 14:46:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:45:59 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-assembler:1.5.24` +# Dependencies of `io.spine.tools:spine-model-assembler:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1183,12 +1183,12 @@ This report was generated on **Fri Aug 14 14:46:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:46:00 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-verifier:1.5.24` +# Dependencies of `io.spine.tools:spine-model-verifier:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1659,12 +1659,12 @@ This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:46:00 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-server:1.5.24` +# Dependencies of `io.spine:spine-server:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2082,12 +2082,12 @@ This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:46:01 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-client:1.5.24` +# Dependencies of `io.spine:spine-testutil-client:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2542,12 +2542,12 @@ This report was generated on **Fri Aug 14 14:46:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:49 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:46:04 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-core:1.5.24` +# Dependencies of `io.spine:spine-testutil-core:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3010,12 +3010,12 @@ This report was generated on **Fri Aug 14 14:46:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:50 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Tue Aug 18 15:46:05 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-server:1.5.24` +# Dependencies of `io.spine:spine-testutil-server:1.5.25` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3514,4 +3514,4 @@ This report was generated on **Fri Aug 14 14:46:50 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 14 14:46:51 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Tue Aug 18 15:46:08 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index eea537e584a..798e551ec58 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.5.24 +1.5.25 2015 diff --git a/server/src/main/java/io/spine/server/EnvSetting.java b/server/src/main/java/io/spine/server/EnvSetting.java index e45105f5fd2..10b9feab466 100644 --- a/server/src/main/java/io/spine/server/EnvSetting.java +++ b/server/src/main/java/io/spine/server/EnvSetting.java @@ -21,7 +21,6 @@ package io.spine.server; import com.google.common.annotations.VisibleForTesting; -import io.spine.annotation.Internal; import io.spine.base.EnvironmentType; import java.util.HashMap; @@ -86,7 +85,6 @@ * @param * the type of value */ -@Internal final class EnvSetting { private final Map, V> environmentValues = @@ -138,6 +136,21 @@ void ifPresentForEnvironment(Class type, } } + /** + * Applies the passed operation to this setting regardless of current environment. + * + *

This means the operation is applied to all passed setting {@linkplain #environmentValues + * values} on a per-environment basis. + * + * @apiNote The not yet run {@linkplain #fallbacks fallback suppliers} are ignored to avoid an + * unnecessary value instantiation. + */ + void apply(SettingOperation operation) throws Exception { + for (V v : environmentValues.values()) { + operation.accept(v); + } + } + /** * If the value corresponding to the specified environment type is set, returns it. * diff --git a/server/src/main/java/io/spine/server/ServerEnvironment.java b/server/src/main/java/io/spine/server/ServerEnvironment.java index 86e7091fa15..98e134c4b95 100644 --- a/server/src/main/java/io/spine/server/ServerEnvironment.java +++ b/server/src/main/java/io/spine/server/ServerEnvironment.java @@ -442,9 +442,9 @@ public void reset() { */ @Override public void close() throws Exception { - tracerFactory.ifPresentForEnvironment(Production.class, AutoCloseable::close); - transportFactory.ifPresentForEnvironment(Production.class, AutoCloseable::close); - storageFactory.ifPresentForEnvironment(Production.class, AutoCloseable::close); + tracerFactory.apply(AutoCloseable::close); + transportFactory.apply(AutoCloseable::close); + storageFactory.apply(AutoCloseable::close); } private static void use(V value, EnvSetting setting, EnvironmentType type) { diff --git a/server/src/main/java/io/spine/server/event/model/StateSubscriberMethod.java b/server/src/main/java/io/spine/server/event/model/StateSubscriberMethod.java index 0421ed07dbe..47ff19a056e 100644 --- a/server/src/main/java/io/spine/server/event/model/StateSubscriberMethod.java +++ b/server/src/main/java/io/spine/server/event/model/StateSubscriberMethod.java @@ -26,7 +26,7 @@ import io.spine.base.EventMessage; import io.spine.base.Field; import io.spine.base.FieldPath; -import io.spine.base.Production; +import io.spine.base.Tests; import io.spine.core.BoundedContext; import io.spine.core.BoundedContextName; import io.spine.logging.Logging; @@ -107,7 +107,7 @@ protected Class rawMessageClass() { private BoundedContextName contextOf(Class cls) { Model model = Model.inContextOf(cls); BoundedContextName name = model.contextName(); - if (Environment.instance().is(Production.class) && name.equals(assumingTests())) { + if (!Environment.instance().is(Tests.class) && name.equals(assumingTests())) { _warn().log( "The class `%s` belongs to the Bounded Context named `%s`," + " which is used for testing. As such, it should not be used in production." + diff --git a/server/src/main/java/io/spine/system/server/SystemSettings.java b/server/src/main/java/io/spine/system/server/SystemSettings.java index 2e1ff1428ac..0e3e067c930 100644 --- a/server/src/main/java/io/spine/system/server/SystemSettings.java +++ b/server/src/main/java/io/spine/system/server/SystemSettings.java @@ -24,7 +24,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.spine.annotation.Internal; import io.spine.base.Environment; -import io.spine.base.Production; +import io.spine.base.Tests; /** * A configuration of features of a system context. @@ -61,10 +61,10 @@ public static SystemSettings defaults() { .disableCommandLog() .enableAggregateQuerying() .forgetEvents(); - if (Environment.instance().is(Production.class)) { - settings.enableParallelPosting(); - } else { + if (Environment.instance().is(Tests.class)) { settings.disableParallelPosting(); + } else { + settings.enableParallelPosting(); } return settings; } diff --git a/server/src/test/java/io/spine/server/EnvSettingTest.java b/server/src/test/java/io/spine/server/EnvSettingTest.java index cda3694eb55..5335523c2a3 100644 --- a/server/src/test/java/io/spine/server/EnvSettingTest.java +++ b/server/src/test/java/io/spine/server/EnvSettingTest.java @@ -170,37 +170,58 @@ void testRetainsDefaultForEnv(Class type) { assertThat(storageFactory.value(type)).isSameInstanceAs(actualFactory); } } + } - @Test - @DisplayName("reset the value for all environments") - void resetTheValues() { - InMemoryStorageFactory prodStorageFactory = InMemoryStorageFactory.newInstance(); - MemoizingStorageFactory testingStorageFactory = new MemoizingStorageFactory(); - InMemoryStorageFactory localstorageFactory = InMemoryStorageFactory.newInstance(); + @Test + @DisplayName("reset the value for all environments") + void resetTheValues() { + InMemoryStorageFactory prodStorageFactory = InMemoryStorageFactory.newInstance(); + MemoizingStorageFactory testingStorageFactory = new MemoizingStorageFactory(); + InMemoryStorageFactory localStorageFactory = InMemoryStorageFactory.newInstance(); - EnvSetting storageFactory = new EnvSetting<>(); - storageFactory.use(prodStorageFactory, Production.class); - storageFactory.use(testingStorageFactory, Tests.class); - storageFactory.use(localstorageFactory, Local.class); + EnvSetting storageFactory = new EnvSetting<>(); + storageFactory.use(prodStorageFactory, Production.class); + storageFactory.use(testingStorageFactory, Tests.class); + storageFactory.use(localStorageFactory, Local.class); - storageFactory.reset(); + storageFactory.reset(); - Stream.of(Production.class, Tests.class, Local.class) - .map(storageFactory::optionalValue) - .forEach(s -> assertThat(s).isEmpty()); - } + Stream.of(Production.class, Tests.class, Local.class) + .map(storageFactory::optionalValue) + .forEach(s -> assertThat(s).isEmpty()); + } - @Test - @DisplayName("should run an operation against a value value if it's present") - void runThrowableConsumer() throws Exception { - MemoizingStorageFactory storageFactory = new MemoizingStorageFactory(); + @Test + @DisplayName("run an operation against a value if it's present") + void runThrowableConsumer() throws Exception { + MemoizingStorageFactory storageFactory = new MemoizingStorageFactory(); - EnvSetting storageSetting = new EnvSetting<>(); + EnvSetting storageSetting = new EnvSetting<>(); - storageSetting.use(storageFactory, Production.class); - storageSetting.ifPresentForEnvironment(Production.class, AutoCloseable::close); + storageSetting.use(storageFactory, Production.class); + storageSetting.ifPresentForEnvironment(Production.class, AutoCloseable::close); + + assertThat(storageFactory.isClosed()).isTrue(); + } + + @Test + @DisplayName("run an operation for all present values") + void runOperationForAll() throws Exception { + MemoizingStorageFactory prodStorageFactory = new MemoizingStorageFactory(); + MemoizingStorageFactory testingStorageFactory = new MemoizingStorageFactory(); + MemoizingStorageFactory localStorageFactory = new MemoizingStorageFactory(); + + EnvSetting storageSetting = new EnvSetting<>(); + + storageSetting.use(prodStorageFactory, Production.class); + storageSetting.use(testingStorageFactory, Tests.class); + storageSetting.use(localStorageFactory, Local.class); + + storageSetting.apply(AutoCloseable::close); + + assertThat(prodStorageFactory.isClosed()).isTrue(); + assertThat(testingStorageFactory.isClosed()).isTrue(); + assertThat(localStorageFactory.isClosed()).isTrue(); - assertThat(storageFactory.isClosed()).isTrue(); - } } } diff --git a/server/src/test/java/io/spine/server/ServerEnvironmentTest.java b/server/src/test/java/io/spine/server/ServerEnvironmentTest.java index 7f64a070aa9..0f86e2b32bb 100644 --- a/server/src/test/java/io/spine/server/ServerEnvironmentTest.java +++ b/server/src/test/java/io/spine/server/ServerEnvironmentTest.java @@ -21,6 +21,7 @@ package io.spine.server; import io.spine.base.Environment; +import io.spine.base.EnvironmentType; import io.spine.base.Production; import io.spine.base.Tests; import io.spine.server.delivery.Delivery; @@ -504,32 +505,33 @@ void resetEnvironment() { @Test @DisplayName("close the production transport, tracer and storage factories") - void testCloses() throws Exception { - ServerEnvironment serverEnv = ServerEnvironment.instance(); - serverEnv.use(transportFactory, Production.class) - .use(storageFactory, Production.class) - .use(tracerFactory, Production.class); - - serverEnv.close(); + void productionCloses() throws Exception { + testClosesEnv(Production.class); + } - assertThat(transportFactory.isOpen()).isFalse(); - assertThat(storageFactory.isClosed()).isTrue(); - assertThat(tracerFactory.closed()).isTrue(); + @Test + @DisplayName("close the testing transport, tracer and storage factories") + void testCloses() throws Exception { + testClosesEnv(Tests.class); } @Test - @DisplayName("leave the testing transport, tracer and storage factories open") - void testDoesNotClose() throws Exception { + @DisplayName("close the custom env transport, tracer and storage factories") + void customEnvCloses() throws Exception { + testClosesEnv(Local.class); + } + + private void testClosesEnv(Class envType) throws Exception { ServerEnvironment serverEnv = ServerEnvironment.instance(); - serverEnv.use(transportFactory, Tests.class) - .use(storageFactory, Tests.class) - .use(tracerFactory, Tests.class); + serverEnv.use(transportFactory, envType) + .use(storageFactory, envType) + .use(tracerFactory, envType); serverEnv.close(); - assertThat(tracerFactory.closed()).isFalse(); - assertThat(transportFactory.isOpen()).isTrue(); - assertThat(storageFactory.isClosed()).isFalse(); + assertThat(transportFactory.isOpen()).isFalse(); + assertThat(storageFactory.isClosed()).isTrue(); + assertThat(tracerFactory.closed()).isTrue(); } } diff --git a/server/src/test/java/io/spine/system/server/SystemSettingsTest.java b/server/src/test/java/io/spine/system/server/SystemSettingsTest.java index 3d5dae37bd7..4d5bec4517d 100644 --- a/server/src/test/java/io/spine/system/server/SystemSettingsTest.java +++ b/server/src/test/java/io/spine/system/server/SystemSettingsTest.java @@ -23,8 +23,8 @@ import io.spine.base.Environment; import io.spine.base.Production; import io.spine.base.Tests; +import io.spine.server.given.environment.Local; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -67,19 +67,36 @@ void events() { assertFalse(features.includePersistentEvents()); } + @Nested + @DisplayName("allow parallel posting of system events") + class AllowParallelPosting { + + private final Environment env = Environment.instance(); + + @Test + @DisplayName("in the `Production` environment") + void forProductionEnv() { + env.setTo(Production.class); + assertTrue(SystemSettings.defaults() + .postEventsInParallel()); + } + + @Test + @DisplayName("in a custom environment") + void forCustomEnv() { + env.setTo(Local.class); + assertTrue(SystemSettings.defaults() + .postEventsInParallel()); + } + } + @Test - @Disabled - @DisplayName("allow parallel posting for system events") - void parallelism() { + @DisplayName("disallow parallel posting of system events in the test environment") + void disallowParallelPostingForTest() { Environment env = Environment.instance(); - assumeTrue(env.is(Tests.class)); assertFalse(SystemSettings.defaults() .postEventsInParallel()); - - env.setTo(Production.class); - assertTrue(SystemSettings.defaults() - .postEventsInParallel()); } } diff --git a/version.gradle.kts b/version.gradle.kts index f276dd5c548..1ee60589510 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -27,4 +27,4 @@ val spineBaseVersion: String by extra("1.5.23") val spineTimeVersion: String by extra("1.5.21") -val versionToPublish: String by extra("1.5.24") +val versionToPublish: String by extra("1.5.25")