http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinPrecedenceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinPrecedenceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinPrecedenceTest.java index 5dc94c1..e45befe 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinPrecedenceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinPrecedenceTest.java @@ -22,16 +22,15 @@ package org.apache.polygene.runtime.mixin; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; -import org.junit.Test; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test mixin declaration precedence satisfiedBy @@ -66,7 +65,7 @@ public class MixinPrecedenceTest public void whenMultipleGenericMixinsPrecedence() { TestComposite3 instance = transientBuilderFactory.newTransient( TestComposite3.class ); - assertEquals( "GM1", instance.AMethod() ); + assertThat( instance.AMethod(), equalTo( "GM1" ) ); } @Mixins( { AMixin1.class, AMixin2.class } )
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinsOnThisInjectionTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinsOnThisInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinsOnThisInjectionTest.java index 95c856d..955504e 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinsOnThisInjectionTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/MixinsOnThisInjectionTest.java @@ -19,16 +19,16 @@ */ package org.apache.polygene.runtime.mixin; -import org.junit.Test; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test of declaring Mixin in @This declared interface http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/PrivateMixinTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/PrivateMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/PrivateMixinTest.java index 438089a..0d75e6b 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/PrivateMixinTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/PrivateMixinTest.java @@ -19,17 +19,17 @@ */ package org.apache.polygene.runtime.mixin; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Unit tests related to private mixins. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/Qi228Test.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/Qi228Test.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/Qi228Test.java index e2d2b5a..682657a 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/Qi228Test.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/Qi228Test.java @@ -23,12 +23,12 @@ package org.apache.polygene.runtime.mixin; import java.util.Collection; import java.util.Collections; import java.util.List; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.api.service.ServiceComposite; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; public class Qi228Test extends AbstractPolygeneTest http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java index 9a6c49f..e153cb6 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java @@ -26,11 +26,12 @@ import org.apache.polygene.api.injection.scope.Uses; import org.apache.polygene.api.object.NoSuchObjectTypeException; import org.apache.polygene.api.structure.Module; import org.apache.polygene.bootstrap.SingletonAssembler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Unit tests for ObjectBuilderFactory. @@ -43,12 +44,15 @@ public class ObjectBuilderFactoryTest * * @throws Exception expected */ - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void newBuilderForUnregisteredObject() throws Exception { - SingletonAssembler assembler = new SingletonAssembler( module -> {} ); - assembler.module().newObject( AnyObject.class ); + assertThrows( NoSuchObjectTypeException.class, () -> { + SingletonAssembler assembler = new SingletonAssembler( module -> { + } ); + assembler.module().newObject( AnyObject.class ); + } ); } /** @@ -56,12 +60,15 @@ public class ObjectBuilderFactoryTest * * @throws Exception expected */ - @Test( expected = NullPointerException.class ) + @Test public void newBuilderForNullType() throws Exception { - SingletonAssembler assembler = new SingletonAssembler( module -> {} ); - assembler.module().newObject( null ); + assertThrows( NullPointerException.class, () -> { + SingletonAssembler assembler = new SingletonAssembler( module -> { + } ); + assembler.module().newObject( null ); + } ); } /** @@ -69,12 +76,15 @@ public class ObjectBuilderFactoryTest * * @throws Exception expected */ - @Test( expected = NullPointerException.class ) + @Test public void newObjectInstanceForNullType() throws Exception { - SingletonAssembler assembler = new SingletonAssembler( module -> {} ); - assembler.module().newObject( null ); + assertThrows( NullPointerException.class, () -> { + SingletonAssembler assembler = new SingletonAssembler( module -> { + } ); + assembler.module().newObject( null ); + } ); } /** @@ -95,12 +105,12 @@ public class ObjectBuilderFactoryTest SingletonAssembler assembler = new SingletonAssembler( module -> module.objects( ManyConstructorObject.class ) ); ManyConstructorObject object = assembler.module().newObject( ManyConstructorObject.class ); - Assert.assertThat( "ref is not null", object.anyObject, notNullValue() ); + assertThat( "ref is not null", object.anyObject, notNullValue() ); object = assembler.module() .newObject( ManyConstructorObject.class, new AnyObject() ); - Assert.assertThat( "ref is not null", object.anyObject, notNullValue() ); + assertThat( "ref is not null", object.anyObject, notNullValue() ); } @Test @@ -109,7 +119,7 @@ public class ObjectBuilderFactoryTest { SingletonAssembler assembler = new SingletonAssembler( module -> module.objects( OuterClass.class ) ); - Assert.assertThat( "inner class has been injected", assembler.module() + assertThat( "inner class has been injected", assembler.module() .newObject( OuterClass.class ) .name(), equalTo( "Module 1" ) ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectConcernTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectConcernTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectConcernTest.java index 28922ba..1a5321f 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectConcernTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectConcernTest.java @@ -26,7 +26,7 @@ import org.apache.polygene.api.concern.Concerns; import org.apache.polygene.api.concern.GenericConcern; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.SingletonAssembler; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * JAVADOC http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java index ed0171a..ebf1bb1 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java @@ -40,9 +40,11 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.Energy4Java; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.EntityTestAssembler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class ObjectVisibilityTest { @@ -54,7 +56,7 @@ public class ObjectVisibilityTest private UnitOfWorkFactory uowf; private Application app; - @Before + @BeforeEach public void setup() throws Exception { @@ -89,7 +91,7 @@ public class ObjectVisibilityTest uowf = module.unitOfWorkFactory(); } - @After + @AfterEach public void tearDown() throws Exception { @@ -131,11 +133,13 @@ public class ObjectVisibilityTest service.besideLayerVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromServiceWhenAccessingBesideModuleVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.besideModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.besideModuleVisible(); + } ); } @Test @@ -145,39 +149,49 @@ public class ObjectVisibilityTest service.belowApplicationVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromServiceWhenAccessingBelowLayerVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.belowLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.belowLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromServiceWhenAccessingBelowModuleVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.belowModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.belowModuleVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) - public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException() + @Test + public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.aboveApplicationVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.aboveLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) - public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException() + @Test + public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.aboveLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.aboveApplicationVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromServiceWhenAccessingAboveModuleVisibleExpectException() { - FromService service = module.findService( FromService.class ).get(); - service.aboveModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromService service = module.findService( FromService.class ).get(); + service.aboveModuleVisible(); + } ); } @Test @@ -270,22 +284,24 @@ public class ObjectVisibilityTest } } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.besideModuleVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.besideModuleVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } @Test @@ -306,94 +322,104 @@ public class ObjectVisibilityTest } } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.belowLayerVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.belowLayerVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.belowModuleVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.belowModuleVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.aboveApplicationVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.aboveApplicationVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.aboveLayerVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.aboveLayerVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException() { - UnitOfWork unitOfWork = uowf.newUnitOfWork(); - try - { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); - entity.aboveModuleVisible(); - } - finally - { - if( unitOfWork.isOpen() ) + assertThrows( NoSuchObjectTypeException.class, () -> { + UnitOfWork unitOfWork = uowf.newUnitOfWork(); + try { - unitOfWork.discard(); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY ); + entity.aboveModuleVisible(); } - } + finally + { + if( unitOfWork.isOpen() ) + { + unitOfWork.discard(); + } + } + } ); } @Test @@ -431,11 +457,13 @@ public class ObjectVisibilityTest value.besideLayerVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingBesideModuleVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.besideModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.besideModuleVisible(); + } ); } @Test @@ -445,39 +473,49 @@ public class ObjectVisibilityTest value.belowApplicationVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingBelowLayerVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.belowLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.belowLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingBelowModuleVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.belowModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.belowModuleVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingAboveApplicationVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.aboveApplicationVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.aboveApplicationVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingAboveLayerVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.aboveLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.aboveLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromValueWhenAccessingAboveModuleVisibleExpectException() { - FromValue value = module.newValue( FromValue.class ); - value.aboveModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromValue value = module.newValue( FromValue.class ); + value.aboveModuleVisible(); + } ); } @Test @@ -515,11 +553,13 @@ public class ObjectVisibilityTest transientt.besideLayerVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingBesideModuleVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.besideModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.besideModuleVisible(); + } ); } @Test @@ -529,39 +569,49 @@ public class ObjectVisibilityTest transientt.belowApplicationVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingBelowLayerVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.belowLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.belowLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingBelowModuleVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.belowModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.belowModuleVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingAboveApplicationVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.aboveApplicationVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.aboveApplicationVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingAboveLayerVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.aboveLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.aboveLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromTransientWhenAccessingAboveModuleVisibleExpectException() { - FromTransient transientt = module.newTransient( FromTransient.class ); - transientt.aboveModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromTransient transientt = module.newTransient( FromTransient.class ); + transientt.aboveModuleVisible(); + } ); } @Test @@ -599,11 +649,13 @@ public class ObjectVisibilityTest object.besideLayerVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingBesideModuleVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.besideModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.besideModuleVisible(); + } ); } @Test @@ -613,39 +665,49 @@ public class ObjectVisibilityTest object.belowApplicationVisible(); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingBelowLayerVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.belowLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.belowLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingBelowModuleVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.belowModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.belowModuleVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingAboveApplicationVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.aboveApplicationVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.aboveApplicationVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingAboveLayerVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.aboveLayerVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.aboveLayerVisible(); + } ); } - @Test( expected = NoSuchObjectTypeException.class ) + @Test public void givenFromObjectWhenAccessingAboveModuleVisibleExpectException() { - FromObject object = module.newObject( FromObject.class ); - object.aboveModuleVisible(); + assertThrows( NoSuchObjectTypeException.class, () -> { + FromObject object = module.newObject( FromObject.class ); + object.aboveModuleVisible(); + } ); } private static class FromAssembler http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/property/ImmutablePropertyTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/property/ImmutablePropertyTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/property/ImmutablePropertyTest.java index c3518dc..f72c7db 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/property/ImmutablePropertyTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/property/ImmutablePropertyTest.java @@ -19,9 +19,6 @@ */ package org.apache.polygene.runtime.property; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.entity.EntityBuilder; @@ -31,10 +28,15 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public final class ImmutablePropertyTest extends AbstractPolygeneTest @@ -58,8 +60,8 @@ public final class ImmutablePropertyTest private void testNamePropertyGet( Location location, String locationName ) { - assertNotNull( location ); - assertEquals( locationName, location.name().get() ); + assertThat( location, notNullValue() ); + assertThat( location.name().get(), equalTo( locationName ) ); } @Test @@ -73,14 +75,15 @@ public final class ImmutablePropertyTest testNamePropertyGet( location, KUALA_LUMPUR ); } - @Test( expected = IllegalStateException.class ) + @Test public final void testSetter() { - Location location = createLocation( KUALA_LUMPUR ); - - // Must fail! - Property<String> stringProperty = location.name(); - stringProperty.set( "abc" ); + assertThrows( IllegalStateException.class, () -> { + Location location = createLocation( KUALA_LUMPUR ); + // Must fail! + Property<String> stringProperty = location.name(); + stringProperty.set( "abc" ); + } ); } @Test @@ -96,7 +99,7 @@ public final class ImmutablePropertyTest try { location.name().set( "Niclas" ); - Assert.fail( "Should be immutable" ); + fail( "Should be immutable" ); } catch( IllegalStateException e ) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyEqualityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyEqualityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyEqualityTest.java index fbccfa2..f2c0e71 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyEqualityTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyEqualityTest.java @@ -34,13 +34,13 @@ import org.apache.polygene.api.value.ValueDescriptor; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static java.time.ZoneOffset.UTC; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Assert that Property equals/hashcode methods combine PropertyDescriptor and State. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyStringArrayTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyStringArrayTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyStringArrayTest.java index 179e2eb..0ec3bac 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyStringArrayTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyStringArrayTest.java @@ -20,16 +20,16 @@ package org.apache.polygene.runtime.property; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.property.Property; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests for string arrays as properties (QI-132) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyTest.java index 530cd71..f7e1e44 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/property/PropertyTest.java @@ -23,8 +23,6 @@ package org.apache.polygene.runtime.property; import java.io.Serializable; import java.lang.reflect.Method; import javax.swing.Icon; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.common.AppliesTo; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientComposite; @@ -34,8 +32,11 @@ import org.apache.polygene.api.property.PropertyMixin; import org.apache.polygene.api.property.PropertyWrapper; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; /** * Tests for properties @@ -70,8 +71,8 @@ public class PropertyTest company = builder.newInstance(); } - company.name().set( "Jayway" ); - assertEquals( "Jayway", company.name().get() ); + company.name().set( "CodeDragons" ); + assertThat( company.name().get(), equalTo( "CodeDragons" ) ); System.out.println( "Name is:" + company.name().get() ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/property/ValueNestedBuilderTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/property/ValueNestedBuilderTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/property/ValueNestedBuilderTest.java index 0f14212..f50d059 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/property/ValueNestedBuilderTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/property/ValueNestedBuilderTest.java @@ -30,7 +30,7 @@ import org.apache.polygene.api.value.ValueComposite; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ValueNestedBuilderTest extends AbstractPolygeneTest http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java index 810eab2..3df8eb1 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java @@ -48,9 +48,9 @@ import org.apache.polygene.runtime.query.model.entities.PetEntity; import org.apache.polygene.runtime.query.model.values.ContactValue; import org.apache.polygene.runtime.query.model.values.ContactsValue; import org.apache.polygene.test.EntityTestAssembler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.polygene.api.query.QueryExpressions.eq; import static org.apache.polygene.api.query.QueryExpressions.ge; @@ -64,8 +64,9 @@ import static org.apache.polygene.api.query.QueryExpressions.or; import static org.apache.polygene.api.query.QueryExpressions.orderBy; import static org.apache.polygene.api.query.QueryExpressions.property; import static org.apache.polygene.api.query.QueryExpressions.templateFor; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.fail; public class IterableQuerySourceTest { @@ -73,7 +74,7 @@ public class IterableQuerySourceTest private UnitOfWork uow; private QueryBuilderFactory qbf; - @Before + @BeforeEach public void setUp() throws UnitOfWorkCompletionException, ActivationException, AssemblyException { @@ -97,7 +98,7 @@ public class IterableQuerySourceTest qbf = assembler.module(); } - @After + @AfterEach public void tearDown() { if( uow != null ) @@ -115,7 +116,7 @@ public class IterableQuerySourceTest for( Nameable entity : results ) { String name = entity.name().get(); - assertTrue( name + " returned but not expected", expected.remove( name ) ); + assertThat( name + " returned but not expected", expected.remove( name ), is( true ) ); } for( String notReturned : expected ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/query/NonQueryableTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/NonQueryableTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/NonQueryableTest.java index 5b5251e..1f3e8ea 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/NonQueryableTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/NonQueryableTest.java @@ -27,11 +27,11 @@ import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.polygene.api.query.QueryExpressions.eq; import static org.apache.polygene.api.query.QueryExpressions.templateFor; +import static org.junit.jupiter.api.Assertions.fail; public class NonQueryableTest extends AbstractPolygeneTest @@ -51,7 +51,7 @@ public class NonQueryableTest QueryBuilder<Abc> builder = queryBuilderFactory.newQueryBuilder( Abc.class ); Abc proto = templateFor( Abc.class ); builder.where( eq( proto.isValid(), Boolean.TRUE ) ); - Assert.fail( "Exception was expected." ); + fail( "Exception was expected." ); } catch( QueryException e ) { @@ -70,7 +70,7 @@ public class NonQueryableTest try { queryBuilderFactory.newQueryBuilder( Abc2.class ); - Assert.fail( "Exception was expected." ); + fail( "Exception was expected." ); } catch( QueryException e ) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImplTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImplTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImplTest.java index 3549165..00ca4fa 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImplTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImplTest.java @@ -22,9 +22,6 @@ package org.apache.polygene.runtime.query; import java.util.ArrayList; import java.util.List; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Before; -import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.property.Property; @@ -32,15 +29,17 @@ import org.apache.polygene.api.query.Query; import org.apache.polygene.api.query.QueryBuilder; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import static org.apache.polygene.api.query.QueryExpressions.and; import static org.apache.polygene.api.query.QueryExpressions.ge; import static org.apache.polygene.api.query.QueryExpressions.lt; import static org.apache.polygene.api.query.QueryExpressions.orderBy; import static org.apache.polygene.api.query.QueryExpressions.templateFor; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; /** * JAVADOC @@ -56,7 +55,7 @@ public class QueryBuilderFactoryImplTest module.transients( TestComposite.class ); } - @Before + @BeforeEach public void setUp() throws Exception { @@ -74,8 +73,8 @@ public class QueryBuilderFactoryImplTest public void givenPlainQueryWhenFindEntityExpectFirstEntityReturned() { Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites ); - assertEquals( "A", query.find().a().get() ); - assertEquals( 6, query.count() ); + assertThat( query.find().a().get(), equalTo( "A" ) ); + assertThat( query.count(), equalTo( 6 ) ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ActivatableServiceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ActivatableServiceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ActivatableServiceTest.java index 60ce6fd..7f6b237 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ActivatableServiceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ActivatableServiceTest.java @@ -20,16 +20,16 @@ package org.apache.polygene.runtime.service; -import org.junit.Test; import org.apache.polygene.api.injection.scope.Service; import org.apache.polygene.api.service.ServiceComposite; import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.SingletonAssembler; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; /** * Test of activatable services @@ -51,23 +51,25 @@ public class ActivatableServiceTest throws AssemblyException { module.objects( ActivatableServiceTest.class ); - module.services( ActivatableComposite.class ).withActivators( TestActivator.class).instantiateOnStartup(); + module.services( ActivatableComposite.class ) + .withActivators( TestActivator.class ) + .instantiateOnStartup(); } }; - assertTrue( isActive ); + assertThat( isActive, is( true ) ); assembly.module().injectTo( this ); - assertTrue( isActive ); + assertThat( isActive, is( true ) ); service.get(); - assertTrue( isActive ); + assertThat( isActive, is( true ) ); assembly.application().passivate(); - assertFalse( isActive ); + assertThat( isActive, is( false ) ); } public static interface ActivatableComposite @@ -76,7 +78,7 @@ public class ActivatableServiceTest } public static class TestActivator - extends org.apache.polygene.api.activation.ActivatorAdapter<Object> + extends org.apache.polygene.api.activation.ActivatorAdapter<Object> { @Override @@ -87,14 +89,13 @@ public class ActivatableServiceTest @Override public void afterPassivation( Object passivated ) - throws Exception + throws Exception { - if ( !isActive ) { + if( !isActive ) + { throw new Exception( "Not active!" ); } - isActive = false; } - } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/AvailableServiceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/AvailableServiceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/AvailableServiceTest.java index c5e4f3b..a3a95d1 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/AvailableServiceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/AvailableServiceTest.java @@ -36,12 +36,12 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.SingletonAssembler; import org.apache.polygene.test.EntityTestAssembler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * JAVADOC http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ComplexActivatableTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ComplexActivatableTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ComplexActivatableTest.java index baef5c0..1e6d971 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ComplexActivatableTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ComplexActivatableTest.java @@ -19,7 +19,6 @@ */ package org.apache.polygene.runtime.service; -import org.junit.Test; import org.apache.polygene.api.activation.ActivatorAdapter; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Initializable; @@ -30,15 +29,17 @@ import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class ComplexActivatableTest extends AbstractPolygeneTest { public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.services( SuperType.class ).withActivators( TestActivator.class ).instantiateOnStartup(); } @@ -47,12 +48,12 @@ public class ComplexActivatableTest public void validateThatApplicationGotAssembled() { ServiceReference<SuperType> reference = serviceFinder.findService( SuperType.class ); - assertEquals( "Hello, World", reference.get().sayHello() ); + assertThat( reference.get().sayHello(), equalTo( "Hello, World" ) ); } @Mixins( { DomainType.class, InitializationMixin.class } ) public interface SuperType - extends ServiceComposite, Initializable + extends ServiceComposite, Initializable { String sayHello(); @@ -60,22 +61,20 @@ public class ComplexActivatableTest Property<String> greeting(); Property<String> recepient(); - } public abstract static class DomainType - implements SuperType + implements SuperType { public String sayHello() { return greeting().get() + ", " + recepient().get(); } - } public static class InitializationMixin - implements Initializable + implements Initializable { @This @@ -85,20 +84,17 @@ public class ComplexActivatableTest { me.greeting().set( "Hello" ); } - } public static class TestActivator - extends ActivatorAdapter<ServiceReference<SuperType>> + extends ActivatorAdapter<ServiceReference<SuperType>> { @Override public void afterActivation( ServiceReference<SuperType> activated ) - throws Exception + throws Exception { activated.get().recepient().set( "World" ); } - } - } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationConstraintTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationConstraintTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationConstraintTest.java index 9c4d7ce..1dec1da 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationConstraintTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationConstraintTest.java @@ -33,11 +33,11 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.SingletonAssembler; import org.apache.polygene.entitystore.memory.MemoryEntityStoreService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test of configuration for services that Constraints are respected. @@ -61,22 +61,23 @@ public class ConfigurationConstraintTest service.get().test(); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenConstrainedConfigurationWhenIncorrectValueExpectConstraintViolationFailure() throws Exception { - SingletonAssembler underTest = new SingletonAssembler( - module -> - { - module.defaultServices(); - module.services( MemoryEntityStoreService.class ); - module.services( TestService.class ).identifiedBy( "TestService2" ); - module.configurations( TestConfiguration.class ); - } - ); - ServiceReference<TestService> service = underTest.module().findService( TestService.class ); - service.get().test(); - fail( "Expected failure from constraint violation." ); + assertThrows( ConstraintViolationException.class, () -> { + SingletonAssembler underTest = new SingletonAssembler( + module -> + { + module.defaultServices(); + module.services( MemoryEntityStoreService.class ); + module.services( TestService.class ).identifiedBy( "TestService2" ); + module.configurations( TestConfiguration.class ); + } + ); + ServiceReference<TestService> service = underTest.module().findService( TestService.class ); + service.get().test(); + } ); } @Mixins( TestMixin.class ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationTest.java index b8cc751..47a2007 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ConfigurationTest.java @@ -19,7 +19,6 @@ */ package org.apache.polygene.runtime.service; -import org.junit.Test; import org.apache.polygene.api.common.UseDefaults; import org.apache.polygene.api.configuration.Configuration; import org.apache.polygene.api.configuration.ConfigurationComposite; @@ -35,9 +34,10 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test of configuration for services http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/LazyActivatedServiceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/LazyActivatedServiceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/LazyActivatedServiceTest.java index 52a9d1b..7db0d4f 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/LazyActivatedServiceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/LazyActivatedServiceTest.java @@ -20,7 +20,6 @@ package org.apache.polygene.runtime.service; -import junit.framework.TestCase; import org.apache.polygene.api.activation.ActivatorAdapter; import org.apache.polygene.api.injection.scope.Service; import org.apache.polygene.api.mixin.Mixins; @@ -29,18 +28,22 @@ import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.SingletonAssembler; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; /** * Test of lazily activated services */ public class LazyActivatedServiceTest - extends TestCase { @Service ServiceReference<MyService> service; public static boolean isActive; + @Test public void testActivatable() throws Exception { @@ -54,23 +57,23 @@ public class LazyActivatedServiceTest } }; - assertFalse( isActive ); + assertThat( isActive, is( false ) ); assembly.module().injectTo( this ); - assertFalse( isActive ); + assertThat( isActive, is( false ) ); service.get(); - assertFalse( isActive ); + assertThat( isActive, is( false ) ); service.get().doStuff(); - assertTrue( isActive ); + assertThat( isActive, is( true ) ); assembly.application().passivate(); - assertFalse( isActive ); + assertThat( isActive, is( false ) ); } @Mixins( { MyServiceMixin.class } ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/PassivationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/PassivationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/PassivationTest.java index c3964f6..9e481b0 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/PassivationTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/PassivationTest.java @@ -21,7 +21,6 @@ package org.apache.polygene.runtime.service; import java.util.ArrayList; -import org.junit.Test; import org.apache.polygene.api.activation.ActivatorAdapter; import org.apache.polygene.api.activation.PassivationException; import org.apache.polygene.api.mixin.Mixins; @@ -30,10 +29,12 @@ import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.SingletonAssembler; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class PassivationTest { @@ -55,9 +56,9 @@ public class PassivationTest assembly.module().findServices( DataAccess.class ).forEach( service -> { - assertTrue( "Service should not be Active before accessed", !service.isActive() ); - assertTrue( service.get().data().activated ); - assertTrue( "Service should be Active after access.", service.isActive() ); + assertThat( "Service should not be Active before accessed", !service.isActive(), is( true ) ); + assertThat( service.get().data().activated, is( true ) ); + assertThat( "Service should be Active after access.", service.isActive(), is( true ) ); } ); assembly.application().passivate(); @@ -93,15 +94,15 @@ public class PassivationTest assembly.module().findServices( DataAccess.class ).forEach( service -> { - assertTrue( "Service should not be Active before accessed", !service.isActive() ); + assertThat( "Service should not be Active before accessed", !service.isActive(), is( true ) ); Data data = service.get().data(); if( DataAccessService.class.isInstance( service.get() ) ) { // Collect the expected successes. datas.add( data ); } - assertTrue( "Data should indicate that the service is activated", data.activated ); - assertTrue( "Service should be Active after access.", service.isActive() ); + assertThat( "Data should indicate that the service is activated", data.activated, is( true ) ); + assertThat( "Service should be Active after access.", service.isActive(), is( true ) ); } ); try @@ -118,37 +119,39 @@ public class PassivationTest assembly.module().findServices( DataAccess.class ).forEach( service -> { - assertFalse( "All services should have been shutdown", service.isActive() ); + assertThat( "All services should have been shutdown", service.isActive(), is( false ) ); } ); } - @Test(expected = PassivationException.class) + @Test public void givenMultipleFailingPassivationWhenPassivatingExpectPassivationExceptionToBubbleUp() throws Exception { - SingletonAssembler assembly = new SingletonAssembler() - { - public void assemble( ModuleAssembly module ) - throws AssemblyException + assertThrows( PassivationException.class, () -> { + SingletonAssembler assembly = new SingletonAssembler() { - module.addServices( DataAccessService.class ).withActivators( PassivationFailureActivator.class ); - module.addServices( DataAccessService.class ).withActivators( PassivationFailureActivator.class ); - } - }; + public void assemble( ModuleAssembly module ) + throws AssemblyException + { + module.addServices( DataAccessService.class ).withActivators( PassivationFailureActivator.class ); + module.addServices( DataAccessService.class ).withActivators( PassivationFailureActivator.class ); + } + }; - assembly.module().findServices( DataAccess.class ).forEach( - service -> - { - assertTrue( "Service should not be Active before accessed", !service.isActive() ); - assertTrue( service.get().data().activated ); - assertTrue( "Service should be Active after access.", service.isActive() ); - } - ); - assembly.application().passivate(); + assembly.module().findServices( DataAccess.class ).forEach( + service -> + { + assertThat( "Service should not be Active before accessed", !service.isActive(), is( true ) ); + assertThat( service.get().data().activated, is( true ) ); + assertThat( "Service should be Active after access.", service.isActive(), is( true ) ); + } + ); + assembly.application().passivate(); + } ); } - @Mixins(DataAccessMixin.class) + @Mixins( DataAccessMixin.class ) public interface DataAccessService extends DataAccess, ServiceComposite { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceFinderTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceFinderTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceFinderTest.java index 9bddd31..560ac03 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceFinderTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceFinderTest.java @@ -20,16 +20,16 @@ package org.apache.polygene.runtime.service; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; public class ServiceFinderTest extends AbstractPolygeneTest { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceIdSelectorTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceIdSelectorTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceIdSelectorTest.java index d00af2a..cdea688 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceIdSelectorTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceIdSelectorTest.java @@ -31,11 +31,11 @@ import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.SingletonAssembler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.polygene.api.service.qualifier.ServiceQualifier.withId; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * JAVADOC