http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/activation/StructureActivatorOrderTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/StructureActivatorOrderTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/StructureActivatorOrderTest.java index f130b18..0426b6b 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/StructureActivatorOrderTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/StructureActivatorOrderTest.java @@ -20,8 +20,6 @@ package org.apache.polygene.runtime.activation; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; import org.apache.polygene.api.structure.Application; import org.apache.polygene.api.structure.Layer; import org.apache.polygene.api.structure.Module; @@ -32,8 +30,11 @@ import org.apache.polygene.runtime.activation.ActivatorOrderTestSupport.Activati import org.apache.polygene.runtime.activation.ActivatorOrderTestSupport.ActivationStepsRecorderInstance; import org.apache.polygene.runtime.activation.ActivatorOrderTestSupport.Expected; import org.apache.polygene.runtime.activation.ActivatorOrderTestSupport.OrderTestActivator; +import org.junit.jupiter.api.BeforeEach; +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 StructureActivatorOrderTest { @@ -43,7 +44,7 @@ public class StructureActivatorOrderTest // public static final ActivationStepsRecorder RECORDER = new ActivationStepsRecorderInstance(); - @Before + @BeforeEach public void beforeEachTest() { RECORDER.reset(); @@ -53,69 +54,63 @@ public class StructureActivatorOrderTest // Activators in order: Alpha, Beta ----------------------------------- // public static class AlphaApplicationActivator - extends OrderTestActivator<Application> + extends OrderTestActivator<Application> { public AlphaApplicationActivator() { super( "Alpha", RECORDER ); } - } public static class BetaApplicationActivator - extends OrderTestActivator<Application> + extends OrderTestActivator<Application> { public BetaApplicationActivator() { super( "Beta", RECORDER ); } - } public static class AlphaLayerActivator - extends OrderTestActivator<Layer> + extends OrderTestActivator<Layer> { public AlphaLayerActivator() { super( "Alpha", RECORDER ); } - } public static class BetaLayerActivator - extends OrderTestActivator<Layer> + extends OrderTestActivator<Layer> { public BetaLayerActivator() { super( "Beta", RECORDER ); } - } public static class AlphaModuleActivator - extends OrderTestActivator<Module> + extends OrderTestActivator<Module> { public AlphaModuleActivator() { super( "Alpha", RECORDER ); } - } public static class BetaModuleActivator - extends OrderTestActivator<Module> + extends OrderTestActivator<Module> { public BetaModuleActivator() { super( "Beta", RECORDER ); } - } // @@ -123,80 +118,77 @@ public class StructureActivatorOrderTest // @Test public void testTwoActivatorsOrderOnApplication() - throws Exception + throws Exception { new SingletonAssembler() { @Override public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.layer().application().withActivators( AlphaApplicationActivator.class, BetaApplicationActivator.class ); } - }.application().passivate(); String actual = Arrays.toString( RECORDER.steps().toArray() ); System.out.println( "\n" + Expected.ALPHA_BETA_SINGLE + "\n" + actual + "\n" ); - assertEquals( Expected.ALPHA_BETA_SINGLE, actual ); + assertThat( actual, equalTo( Expected.ALPHA_BETA_SINGLE ) ); } @Test public void testTwoActivatorsOrderOnLayer() - throws Exception + throws Exception { new SingletonAssembler() { @Override public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.layer().withActivators( AlphaLayerActivator.class, BetaLayerActivator.class ); } - }.application().passivate(); String actual = Arrays.toString( RECORDER.steps().toArray() ); System.out.println( "\n" + Expected.ALPHA_BETA_SINGLE + "\n" + actual + "\n" ); - assertEquals( Expected.ALPHA_BETA_SINGLE, actual ); + assertThat( actual, equalTo( Expected.ALPHA_BETA_SINGLE ) ); } @Test public void testTwoActivatorsOrderOnModule() - throws Exception + throws Exception { new SingletonAssembler() { @Override public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.withActivators( AlphaModuleActivator.class, BetaModuleActivator.class ); } - }.application().passivate(); String actual = Arrays.toString( RECORDER.steps().toArray() ); System.out.println( "\n" + Expected.ALPHA_BETA_SINGLE + "\n" + actual + "\n" ); - assertEquals( Expected.ALPHA_BETA_SINGLE, actual ); + assertThat( actual, equalTo( Expected.ALPHA_BETA_SINGLE ) ); } @Test public void testTwoActivatorsOrderOnApplicationLayerAndModule() - throws Exception + throws Exception { new SingletonAssembler() { @Override public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.layer().application().withActivators( AlphaApplicationActivator.class, BetaApplicationActivator.class ); @@ -205,60 +197,58 @@ public class StructureActivatorOrderTest module.withActivators( AlphaModuleActivator.class, BetaModuleActivator.class ); } - }.application().passivate(); String expected = Arrays.toString( new String[]{ - // Application.beforeActivation - "Alpha.beforeActivation", - "Beta.beforeActivation", - // Layer.beforeActivation - "Alpha.beforeActivation", - "Beta.beforeActivation", - // Module.beforeActivation - "Alpha.beforeActivation", - "Beta.beforeActivation", - // - // -> Activation - // - // Application.afterActivation - "Alpha.afterActivation", - "Beta.afterActivation", - // Layer.afterActivation - "Alpha.afterActivation", - "Beta.afterActivation", - // Module.afterActivation - "Alpha.afterActivation", - "Beta.afterActivation", - // - // -> Active - // - // Module.beforePassivation - "Beta.beforePassivation", - "Alpha.beforePassivation", - // Layer.beforePassivation - "Beta.beforePassivation", - "Alpha.beforePassivation", - // Application.beforePassivation - "Beta.beforePassivation", - "Alpha.beforePassivation", - // - // -> Passivation - // - // Module.afterPassivation - "Beta.afterPassivation", - "Alpha.afterPassivation", - // Layer.afterPassivation - "Beta.afterPassivation", - "Alpha.afterPassivation", - // Application.afterPassivation - "Beta.afterPassivation", - "Alpha.afterPassivation" - } ); + // Application.beforeActivation + "Alpha.beforeActivation", + "Beta.beforeActivation", + // Layer.beforeActivation + "Alpha.beforeActivation", + "Beta.beforeActivation", + // Module.beforeActivation + "Alpha.beforeActivation", + "Beta.beforeActivation", + // + // -> Activation + // + // Application.afterActivation + "Alpha.afterActivation", + "Beta.afterActivation", + // Layer.afterActivation + "Alpha.afterActivation", + "Beta.afterActivation", + // Module.afterActivation + "Alpha.afterActivation", + "Beta.afterActivation", + // + // -> Active + // + // Module.beforePassivation + "Beta.beforePassivation", + "Alpha.beforePassivation", + // Layer.beforePassivation + "Beta.beforePassivation", + "Alpha.beforePassivation", + // Application.beforePassivation + "Beta.beforePassivation", + "Alpha.beforePassivation", + // + // -> Passivation + // + // Module.afterPassivation + "Beta.afterPassivation", + "Alpha.afterPassivation", + // Layer.afterPassivation + "Beta.afterPassivation", + "Alpha.afterPassivation", + // Application.afterPassivation + "Beta.afterPassivation", + "Alpha.afterPassivation" + } ); String actual = Arrays.toString( RECORDER.steps().toArray() ); System.out.println( "\n" + expected + "\n" + actual + "\n" ); - assertEquals( expected, actual ); + assertThat( actual, equalTo( expected ) ); } - }
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToFilterTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToFilterTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToFilterTest.java index 4fe8ba0..02806ce 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToFilterTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToFilterTest.java @@ -20,9 +20,6 @@ package org.apache.polygene.runtime.appliesto; import java.lang.reflect.Method; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.common.AppliesTo; import org.apache.polygene.api.common.AppliesToFilter; import org.apache.polygene.api.composite.TransientComposite; @@ -31,6 +28,11 @@ import org.apache.polygene.api.concern.GenericConcern; 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.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; /** * Test of the AppliesToFilter @@ -49,9 +51,9 @@ public class AppliesToFilterTest throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); - Assert.assertEquals( ",", some.doStuff1() ); - Assert.assertEquals( ",,..", some.doStuff2() ); - Assert.assertEquals( ",,,", some.doStuff3() ); + assertThat( some.doStuff1(), equalTo( "," ) ); + assertThat( some.doStuff2(), equalTo( ",,.." ) ); + assertThat( some.doStuff3(), equalTo( ",,," ) ); } @Concerns( MyConcern.class ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToOrConditionQI241Test.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToOrConditionQI241Test.java b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToOrConditionQI241Test.java index 51b705a..a630cbc 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToOrConditionQI241Test.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToOrConditionQI241Test.java @@ -39,9 +39,10 @@ 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.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; public class AppliesToOrConditionQI241Test extends AbstractPolygeneTest @@ -68,7 +69,7 @@ public class AppliesToOrConditionQI241Test SomeServiceCompositeWithFirstAnnotation.class ); SomeServiceCompositeWithFirstAnnotation someWithFirst = refWithFirst.get(); someWithFirst.doStuff(); - assertTrue( "AppliesTo did not match with first annotation", someWithFirst.concernHasBeenPlayed() ); + assertThat( "AppliesTo did not match with first annotation", someWithFirst.concernHasBeenPlayed(), is( true ) ); } finally { @@ -87,7 +88,7 @@ public class AppliesToOrConditionQI241Test SomeServiceCompositeWithSecondAnnotation.class ); SomeServiceCompositeWithSecondAnnotation someWithSecond = refWithSecond.get(); someWithSecond.doStuff(); - assertTrue( "AppliesTo did not match with second annotation", someWithSecond.concernHasBeenPlayed() ); + assertThat( "AppliesTo did not match with second annotation", someWithSecond.concernHasBeenPlayed(), is( true ) ); } finally { @@ -106,7 +107,7 @@ public class AppliesToOrConditionQI241Test SomeServiceCompositeWithTwoAnnotations.class ); SomeServiceCompositeWithTwoAnnotations someWithTwo = refWithTwo.get(); someWithTwo.doStuff(); - assertTrue( "AppliesTo did not match with two annotations", someWithTwo.concernHasBeenPlayed() ); + assertThat( "AppliesTo did not match with two annotations", someWithTwo.concernHasBeenPlayed(), is( true ) ); } finally { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToTest.java index 5af4e96..5f8b394 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/AppliesToTest.java @@ -21,8 +21,6 @@ package org.apache.polygene.runtime.appliesto; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.common.AppliesTo; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.concern.ConcernOf; @@ -31,6 +29,10 @@ 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.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; /** * Test of the @AppliesTo annotation @@ -49,7 +51,7 @@ public class AppliesToTest throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); - Assert.assertEquals( ",", some.doStuff1() ); + assertThat( some.doStuff1(), equalTo( "," ) ); } @Test @@ -57,7 +59,7 @@ public class AppliesToTest throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); - Assert.assertEquals( ",,..", some.doStuff2() ); + assertThat( some.doStuff2(), equalTo( ",,.." ) ); } @Test @@ -65,9 +67,9 @@ public class AppliesToTest throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); - Assert.assertEquals( ",", some.doStuff1() ); - Assert.assertEquals( ",,..", some.doStuff2() ); - Assert.assertEquals( ",,,", some.doStuff3() ); + assertThat( some.doStuff1(), equalTo( "," ) ); + assertThat( some.doStuff2(), equalTo( ",,.." ) ); + assertThat( some.doStuff3(), equalTo( ",,," ) ); } @Concerns( MyConcern.class ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/FragmentAppliesToTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/FragmentAppliesToTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/FragmentAppliesToTest.java index d0fb47e..4e18102 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/FragmentAppliesToTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/appliesto/FragmentAppliesToTest.java @@ -26,7 +26,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; -import org.junit.Test; import org.apache.polygene.api.common.AppliesTo; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientBuilderFactory; @@ -39,9 +38,11 @@ import org.apache.polygene.api.sideeffect.SideEffects; 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.junit.Assert.assertNotNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.IsNull.notNullValue; public class FragmentAppliesToTest extends AbstractPolygeneTest @@ -59,16 +60,16 @@ public class FragmentAppliesToTest TransientBuilder<Composite1> builder = transientBuilderFactory.newTransientBuilder( Composite1.class ); Composite1 instance = builder.newInstance(); - assertNotNull( "DependencyOld not injected.", instance.getBuilderFactory() ); - assertNotNull( "This not injected.", instance.getMeAsMixin2() ); - assertEquals( 1, instance.getValue() ); + assertThat( "DependencyOld not injected.", instance.getBuilderFactory(), notNullValue() ); + assertThat( "This not injected.", instance.getMeAsMixin2(), notNullValue() ); + assertThat( instance.getValue(), equalTo( 1 ) ); instance.getBuilderFactory(); instance.getMeAsMixin2(); instance.getBuilderFactory(); instance.getMeAsMixin2(); instance.getMeAsMixin2(); instance.getBuilderFactory(); - assertEquals( 4, instance.getValue() ); + assertThat( instance.getValue(), equalTo( 4 ) ); } @Mixins( { Mixin1.Mixin1Impl.class, Mixin2.Mixin2Impl.class, CounterImpl.class } ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java index 1c9a13c..50ca42a 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java @@ -29,11 +29,11 @@ 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.Test; +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 AssociationAssignmentTest extends AbstractPolygeneTest { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationEqualityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationEqualityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationEqualityTest.java index 9d968f0..15ba126 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationEqualityTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationEqualityTest.java @@ -19,8 +19,6 @@ */ package org.apache.polygene.runtime.association; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.association.Association; import org.apache.polygene.api.association.AssociationDescriptor; import org.apache.polygene.api.association.ManyAssociation; @@ -30,11 +28,13 @@ import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.api.value.ValueBuilder; 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.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Assert that Association, ManyAssociation and NamedAssociation equals/hashcode methods combine AssociationDescriptor and State. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java index f7afdee..c2e56d0 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java @@ -20,8 +20,6 @@ package org.apache.polygene.runtime.bootstrap; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.PolygeneAPI; import org.apache.polygene.api.composite.Composite; import org.apache.polygene.api.concern.ConcernOf; @@ -34,8 +32,11 @@ import org.apache.polygene.api.mixin.NoopMixin; 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; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class DereferenceForBootstrappedConcernsTest extends AbstractPolygeneTest @@ -55,9 +56,9 @@ public class DereferenceForBootstrappedConcernsTest { Result result = serviceFinder.findService( Result.class ).get(); Some some = serviceFinder.findService( Some.class ).get(); - assertEquals( "method()", some.method() ); - assertEquals( some.identity(), result.some().identity() ); - assertEquals( some.identity().get(), result.some().identity().get() ); + assertThat( some.method(), equalTo( "method()" ) ); + assertThat( result.some().identity(), equalTo( some.identity() ) ); + assertThat( result.some().identity().get(), equalTo( some.identity().get() ) ); } @Mixins( ResultMixin.class ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/AbstractMixinTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/AbstractMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/AbstractMixinTest.java index 1575f50..0789b8b 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/AbstractMixinTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/AbstractMixinTest.java @@ -21,9 +21,6 @@ package org.apache.polygene.runtime.composite; import java.lang.reflect.Method; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.common.Optional; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.concern.ConcernOf; @@ -35,6 +32,11 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.structure.Module; 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; /** * JAVADOC @@ -54,7 +56,7 @@ public class AbstractMixinTest { TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class ); - Assert.assertEquals( "Hello WorldHello World", instance.test( "Hello World" ) ); + assertThat( instance.test( "Hello World" ), equalTo( "Hello WorldHello World" ) ); } public interface TestComposite http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java index fd557e2..513328d 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java @@ -22,9 +22,6 @@ package org.apache.polygene.runtime.composite; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.Properties; -import org.apache.polygene.api.common.ConstructionException; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.common.AppliesTo; import org.apache.polygene.api.common.AppliesToFilter; import org.apache.polygene.api.composite.NoSuchTransientTypeException; @@ -33,8 +30,11 @@ 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.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class CompositeFactoryImplTest extends AbstractPolygeneTest @@ -47,13 +47,15 @@ public class CompositeFactoryImplTest } @SuppressWarnings( "unchecked" ) - @Test( expected = NoSuchTransientTypeException.class ) + @Test public void testNewInstanceNotExtendingComposite() throws Exception { - Class aClass = FirstComposite.class; - TransientBuilder builder = transientBuilderFactory.newTransientBuilder( aClass ); - builder.newInstance(); + assertThrows( NoSuchTransientTypeException.class, () -> { + Class aClass = FirstComposite.class; + TransientBuilder builder = transientBuilderFactory.newTransientBuilder( aClass ); + builder.newInstance(); + } ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeModelResolverTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeModelResolverTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeModelResolverTest.java index b6b000d..7dc4f21 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeModelResolverTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeModelResolverTest.java @@ -19,8 +19,6 @@ */ package org.apache.polygene.runtime.composite; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.composite.Composite; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.injection.scope.This; @@ -29,6 +27,10 @@ import org.apache.polygene.api.structure.Module; 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.IsEqual.equalTo; public class CompositeModelResolverTest { @@ -45,7 +47,7 @@ public class CompositeModelResolverTest } }.module(); - Assert.assertEquals( "ok", module.newTransient( TestComposite1.class ).testB() ); + assertThat( module.newTransient( TestComposite1.class ).testB(), equalTo( "ok" ) ); } public void assemble( ModuleAssembly module ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/FunctionalListTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/FunctionalListTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/FunctionalListTest.java index d7abd0f..19c1438 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/FunctionalListTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/FunctionalListTest.java @@ -22,7 +22,6 @@ package org.apache.polygene.runtime.composite; import java.util.ArrayList; import java.util.List; import java.util.function.Function; -import org.junit.Test; import org.apache.polygene.api.injection.scope.Structure; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; @@ -30,9 +29,10 @@ import org.apache.polygene.api.structure.Module; 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.hasItems; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class FunctionalListTest extends AbstractPolygeneTest { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java index ad9def8..f8f150b 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java @@ -32,20 +32,20 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.constraints.annotation.NotEmpty; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.apache.polygene.test.util.Assume.assumeJavaVersion; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; /** * Assert that interface default methods are mixed in composites. */ public class InterfaceDefaultMethodsTest extends AbstractPolygeneTest { - @BeforeClass + @BeforeAll public static void assumeJavaVersionIs8() { assumeJavaVersion( 8 ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceStaticMethodsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceStaticMethodsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceStaticMethodsTest.java index ee97d3f..7bd718b 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceStaticMethodsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceStaticMethodsTest.java @@ -22,10 +22,10 @@ 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.Test; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; /** * Assert that interface static methods are ignored when assembling composites. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/MapOverrideTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/MapOverrideTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/MapOverrideTest.java index bfd908a..4c48053 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/MapOverrideTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/MapOverrideTest.java @@ -24,9 +24,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Ignore; -import org.junit.Test; import org.apache.polygene.api.composite.Composite; import org.apache.polygene.api.concern.ConcernOf; import org.apache.polygene.api.injection.scope.Invocation; @@ -34,9 +31,13 @@ import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.value.ValueBuilder; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * This test shows how to override any java.util.Map to become read-only. HashMap will be used as the Mixin!! @@ -44,7 +45,7 @@ import static org.junit.Assert.assertThat; * Note that keySet(), values() and entrySet() would ALSO require overloading, but this has been left out for * clarity reasons. */ -@Ignore( "Awaiting QI-298 - Allow Transients to be declared by classes" ) +@Disabled( "Awaiting QI-298 - Allow Transients to be declared by classes" ) public class MapOverrideTest extends AbstractPolygeneTest { @@ -135,28 +136,36 @@ public class MapOverrideTest assertThat( underTest.values().contains( "Hedhman" ), equalTo( true ) ); } - @Test( expected = ReadOnlyException.class ) + @Test public void givenReadOnlyAnnotatedHashMapWhenCallingPutExpectReadOnlyException() { - // TODO + assertThrows( ReadOnlyException.class, () -> { + // TODO + } ); } - @Test( expected = ReadOnlyException.class ) + @Test public void givenReadOnlyAnnotatedHashMapWhenCallingRemoveExpectReadOnlyException() { - // TODO + assertThrows( ReadOnlyException.class, () -> { + // TODO + } ); } - @Test( expected = ReadOnlyException.class ) + @Test public void givenReadOnlyAnnotatedHashMapWhenCallingPutAllExpectReadOnlyException() { - // TODO + assertThrows( ReadOnlyException.class, () -> { + // TODO + } ); } - @Test( expected = ReadOnlyException.class ) + @Test public void givenReadOnlyAnnotatedHashMapWhenCallingClearExpectReadOnlyException() { - // TODO + assertThrows( ReadOnlyException.class, () -> { + // TODO + } ); } public static abstract class ReadOnlyMapConcern extends ConcernOf<Map> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test1.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test1.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test1.java index ec34343..dacb077 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test1.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test1.java @@ -19,17 +19,17 @@ */ package org.apache.polygene.runtime.composite; -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.junit.Assert.assertSame; -import static org.junit.Assert.assertEquals; -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; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.jupiter.api.Assertions.assertSame; public class QI247Test1 extends AbstractPolygeneTest @@ -43,22 +43,22 @@ public class QI247Test1 private void checkToString( ObjectMethods withMixin ) { - assertEquals( ObjectMethods.MESSAGE, withMixin.toString() ); + assertThat( withMixin.toString(), equalTo( ObjectMethods.MESSAGE ) ); } private void checkHashCode( ObjectMethods withMixin ) { - assertEquals( ObjectMethods.CODE, withMixin.hashCode() ); + assertThat( withMixin.hashCode(), equalTo( ObjectMethods.CODE ) ); } private void checkSelfEquals( ObjectMethods withMixin ) { - assertEquals( withMixin, withMixin ); + assertThat( withMixin, equalTo( withMixin ) ); } private void checkTwoNotEqual( ObjectMethods first, ObjectMethods second ) { - assertFalse( first.equals( second ) ); + assertThat( first.equals( second ), is( false ) ); } // MIXIN @@ -88,7 +88,7 @@ public class QI247Test1 public void testWithMixinSelfEquals2() { ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class ); - assertTrue( withMixin.equals( withMixin ) ); + assertThat( withMixin.equals( withMixin ), is( true ) ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test2.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test2.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test2.java index d39ed6e..bfb6230 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test2.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI247Test2.java @@ -21,17 +21,17 @@ package org.apache.polygene.runtime.composite; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; -import org.apache.polygene.test.AbstractPolygeneTest; -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.junit.Assert.assertSame; -import static org.junit.Assert.assertEquals; -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; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.jupiter.api.Assertions.assertSame; public class QI247Test2 extends AbstractPolygeneTest @@ -45,22 +45,22 @@ public class QI247Test2 private void checkToString( ObjectMethods instance ) { - assertEquals( ObjectMethods.MESSAGE, instance.toString() ); + assertThat( instance.toString(), equalTo( ObjectMethods.MESSAGE ) ); } private void checkHashCode( ObjectMethods instance ) { - assertEquals( ObjectMethods.CODE, instance.hashCode() ); + assertThat( instance.hashCode(), equalTo( ObjectMethods.CODE ) ); } private void checkSelfEquals( ObjectMethods instance ) { - assertEquals( instance, instance ); + assertThat( instance, equalTo( instance ) ); } private void checkTwoNotEqual( ObjectMethods first, ObjectMethods second ) { - assertFalse( first.equals( second ) ); + assertThat( first.equals( second ), is( false ) ); } //HANDLER @@ -90,7 +90,7 @@ public class QI247Test2 public void testWithHandlerSelfEquals2() { ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class ); - assertTrue( withHandler.equals( withHandler ) ); + assertThat( withHandler.equals( withHandler ), is( true ) ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI256Test.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI256Test.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI256Test.java index 6219487..1a89bd0 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI256Test.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/QI256Test.java @@ -25,7 +25,9 @@ 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.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; /** * JAVADOC @@ -211,134 +213,165 @@ public class QI256Test module.transients( TestTransient.class ); } - @Test( expected = TestException.class ) + @Test public void invokeCustomExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory.newTransient( TestTransient.class ).declaredMethodThatThrowsCustomException(); + assertThrows( TestException.class, () -> { + this.transientBuilderFactory.newTransient( TestTransient.class ).declaredMethodThatThrowsCustomException(); + } ); } - @Test( expected = TestException.class ) + @Test public void invokeDeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeDeclaredPublicMethodThatThrowsCustomException(); + assertThrows( TestException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeDeclaredPublicMethodThatThrowsCustomException(); + } ); } - @Test( expected = TestException.class ) + @Test public void invokeUndeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeUndeclaredPublicMethodThatThrowsCustomException(); + assertThrows( TestException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeUndeclaredPublicMethodThatThrowsCustomException(); + } ); } - @Test( expected = TestException.class ) + @Test public void invokePrivateMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory.newTransient( TestTransient.class ).invokePrivateMethodThatThrowsCustomException(); + assertThrows( TestException.class, () -> { + this.transientBuilderFactory.newTransient( TestTransient.class ) + .invokePrivateMethodThatThrowsCustomException(); + } ); } - @Test( expected = TestException.class ) + @Test public void invokeProtectedMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeProtectedMethodThatThrowsCustomException(); + assertThrows( TestException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeProtectedMethodThatThrowsCustomException(); + } ); } - @Test( expected = IllegalArgumentException.class ) + @Test public void invokeBuiltinInheritedExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .declaredMethodThatThrowsBuiltinInheritedException(); + assertThrows( IllegalArgumentException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .declaredMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = IllegalArgumentException.class ) + @Test public void invokeDeclaredPublicMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException(); + assertThrows( IllegalArgumentException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = IllegalArgumentException.class ) + @Test public void invokeUndeclaredPublicMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException(); + assertThrows( IllegalArgumentException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = IllegalArgumentException.class ) + @Test public void invokePrivateMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokePrivateMethodThatThrowsBuiltinInheritedException(); + assertThrows( IllegalArgumentException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokePrivateMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = IllegalArgumentException.class ) + @Test public void invokeProtectedMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeProtectedMethodThatThrowsBuiltinInheritedException(); + assertThrows( IllegalArgumentException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeProtectedMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = RuntimeException.class ) + @Test public void invokeBuiltinExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .declaredMethodThatThrowsBuiltinInheritedException(); + assertThrows( RuntimeException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .declaredMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = RuntimeException.class ) + @Test public void invokeDeclaredPublicMethodWhichInvokesBuiltinExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException(); + assertThrows( RuntimeException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = RuntimeException.class ) + @Test public void invokeUndeclaredPublicMethodWhichInvokesBuiltinExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException(); + assertThrows( RuntimeException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = RuntimeException.class ) + @Test public void invokePrivateMethodWhichInvokesBuiltinExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokePrivateMethodThatThrowsBuiltinInheritedException(); + assertThrows( RuntimeException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokePrivateMethodThatThrowsBuiltinInheritedException(); + } ); } - @Test( expected = RuntimeException.class ) + @Test public void invokeProtectedMethodWhichInvokesBuiltinExceptionThrowingMethod() throws Throwable { - this.transientBuilderFactory - .newTransient( TestTransient.class ) - .invokeProtectedMethodThatThrowsBuiltinInheritedException(); + assertThrows( RuntimeException.class, () -> { + this.transientBuilderFactory + .newTransient( TestTransient.class ) + .invokeProtectedMethodThatThrowsBuiltinInheritedException(); + } ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/TransientAsClassTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/TransientAsClassTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/TransientAsClassTest.java index f189593..9d5d09d 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/TransientAsClassTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/TransientAsClassTest.java @@ -23,13 +23,13 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import org.apache.polygene.api.concern.ConcernOf; import org.apache.polygene.api.concern.Concerns; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; 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.junit.Assert.assertThat; /** * Test for QI-298. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UsageGraphTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UsageGraphTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UsageGraphTest.java index 9eb1159..949a01a 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UsageGraphTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UsageGraphTest.java @@ -21,18 +21,18 @@ package org.apache.polygene.runtime.composite; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.polygene.bootstrap.BindingException; +import org.junit.jupiter.api.BeforeEach; +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; +import static org.junit.jupiter.api.Assertions.fail; public class UsageGraphTest { - @Before + @BeforeEach public void setUp() { Thing.counter = 1; @@ -78,73 +78,73 @@ public class UsageGraphTest data.add( thing2 ); randomize( data ); UsageGraph<Thing> deps = new UsageGraph<Thing>( data, new Userator(), false ); - assertFalse( deps.transitiveUse( thing1, thing1 ) ); - assertFalse( deps.transitiveUse( thing1, thing2 ) ); - assertTrue( deps.transitiveUse( thing1, thing3 ) ); - assertTrue( deps.transitiveUse( thing1, thing4 ) ); - assertTrue( deps.transitiveUse( thing1, thing5 ) ); - assertTrue( deps.transitiveUse( thing1, thing6 ) ); - assertFalse( deps.transitiveUse( thing1, thing7 ) ); - assertFalse( deps.transitiveUse( thing2, thing1 ) ); - assertFalse( deps.transitiveUse( thing2, thing2 ) ); - assertTrue( deps.transitiveUse( thing2, thing3 ) ); - assertTrue( deps.transitiveUse( thing2, thing4 ) ); - assertTrue( deps.transitiveUse( thing2, thing5 ) ); - assertFalse( deps.transitiveUse( thing2, thing6 ) ); - assertFalse( deps.transitiveUse( thing2, thing7 ) ); - assertFalse( deps.transitiveUse( thing3, thing1 ) ); - assertFalse( deps.transitiveUse( thing3, thing2 ) ); - assertFalse( deps.transitiveUse( thing3, thing3 ) ); - assertTrue( deps.transitiveUse( thing3, thing4 ) ); - assertTrue( deps.transitiveUse( thing3, thing5 ) ); - assertFalse( deps.transitiveUse( thing3, thing6 ) ); - assertFalse( deps.transitiveUse( thing3, thing7 ) ); - assertFalse( deps.transitiveUse( thing4, thing1 ) ); - assertFalse( deps.transitiveUse( thing4, thing2 ) ); - assertFalse( deps.transitiveUse( thing4, thing3 ) ); - assertFalse( deps.transitiveUse( thing4, thing4 ) ); - assertTrue( deps.transitiveUse( thing4, thing5 ) ); - assertFalse( deps.transitiveUse( thing4, thing6 ) ); - assertFalse( deps.transitiveUse( thing4, thing7 ) ); - assertFalse( deps.transitiveUse( thing5, thing1 ) ); - assertFalse( deps.transitiveUse( thing5, thing2 ) ); - assertFalse( deps.transitiveUse( thing5, thing3 ) ); - assertFalse( deps.transitiveUse( thing5, thing4 ) ); - assertFalse( deps.transitiveUse( thing5, thing5 ) ); - assertFalse( deps.transitiveUse( thing5, thing6 ) ); - assertFalse( deps.transitiveUse( thing5, thing7 ) ); - assertFalse( deps.transitiveUse( thing6, thing1 ) ); - assertFalse( deps.transitiveUse( thing6, thing2 ) ); - assertFalse( deps.transitiveUse( thing6, thing3 ) ); - assertFalse( deps.transitiveUse( thing6, thing4 ) ); - assertFalse( deps.transitiveUse( thing6, thing5 ) ); - assertFalse( deps.transitiveUse( thing6, thing6 ) ); - assertFalse( deps.transitiveUse( thing6, thing7 ) ); - assertTrue( deps.transitiveUse( thing7, thing1 ) ); - assertTrue( deps.transitiveUse( thing7, thing2 ) ); - assertTrue( deps.transitiveUse( thing7, thing3 ) ); - assertTrue( deps.transitiveUse( thing7, thing4 ) ); - assertTrue( deps.transitiveUse( thing7, thing5 ) ); - assertTrue( deps.transitiveUse( thing7, thing6 ) ); - assertFalse( deps.transitiveUse( thing7, thing7 ) ); + assertThat( deps.transitiveUse( thing1, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing1, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing1, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing3 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing3 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing4 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing3 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing4 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing5 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing3 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing4 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing5 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing7, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing2 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing7 ), is( false ) ); List<Thing> resolved = deps.resolveOrder(); System.out.println( resolved ); - assertTrue( resolved.indexOf( thing1 ) > resolved.indexOf( thing6 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing3 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing1 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing2 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing1 ) > resolved.indexOf( thing3 ) ); - assertTrue( resolved.indexOf( thing1 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing1 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing3 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing3 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing4 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing6 ) ); + assertThat( resolved.indexOf( thing1 ) > resolved.indexOf( thing6 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing3 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing1 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing2 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing1 ) > resolved.indexOf( thing3 ), is( true ) ); + assertThat( resolved.indexOf( thing1 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing1 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing3 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing3 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing4 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing6 ), is( true ) ); } private void randomize( List<Thing> data ) @@ -205,7 +205,7 @@ public class UsageGraphTest try { List<Thing> resolved = deps.resolveOrder(); - Assert.fail( "Cyclic Dependency Not Detected." ); + fail( "Cyclic Dependency Not Detected." ); } catch( BindingException e ) { @@ -245,8 +245,8 @@ public class UsageGraphTest UsageGraph<Thing> deps = new UsageGraph<Thing>( data, new Userator(), false ); try { - assertTrue( deps.transitiveUse( thing1, thing3 ) ); - Assert.fail( "Cyclic Dependency Not Detected." ); + assertThat( deps.transitiveUse( thing1, thing3 ), is( true ) ); + fail( "Cyclic Dependency Not Detected." ); } catch( BindingException e ) { @@ -284,65 +284,65 @@ public class UsageGraphTest data.add( thing2 ); randomize( data ); UsageGraph<Thing> deps = new UsageGraph<Thing>( data, new Userator(), true ); - assertTrue( deps.transitiveUse( thing1, thing1 ) ); - assertFalse( deps.transitiveUse( thing1, thing2 ) ); - assertTrue( deps.transitiveUse( thing1, thing3 ) ); - assertTrue( deps.transitiveUse( thing1, thing4 ) ); - assertTrue( deps.transitiveUse( thing1, thing5 ) ); - assertTrue( deps.transitiveUse( thing1, thing6 ) ); - assertFalse( deps.transitiveUse( thing1, thing7 ) ); - assertTrue( deps.transitiveUse( thing2, thing1 ) ); - assertFalse( deps.transitiveUse( thing2, thing2 ) ); - assertTrue( deps.transitiveUse( thing2, thing3 ) ); - assertTrue( deps.transitiveUse( thing2, thing4 ) ); - assertTrue( deps.transitiveUse( thing2, thing5 ) ); - assertTrue( deps.transitiveUse( thing2, thing6 ) ); - assertFalse( deps.transitiveUse( thing2, thing7 ) ); - assertTrue( deps.transitiveUse( thing3, thing1 ) ); - assertFalse( deps.transitiveUse( thing3, thing2 ) ); - assertTrue( deps.transitiveUse( thing3, thing3 ) ); - assertTrue( deps.transitiveUse( thing3, thing4 ) ); - assertTrue( deps.transitiveUse( thing3, thing5 ) ); - assertTrue( deps.transitiveUse( thing3, thing6 ) ); - assertFalse( deps.transitiveUse( thing3, thing7 ) ); - assertTrue( deps.transitiveUse( thing4, thing1 ) ); - assertFalse( deps.transitiveUse( thing4, thing2 ) ); - assertTrue( deps.transitiveUse( thing4, thing3 ) ); - assertTrue( deps.transitiveUse( thing4, thing4 ) ); - assertTrue( deps.transitiveUse( thing4, thing5 ) ); - assertTrue( deps.transitiveUse( thing4, thing6 ) ); - assertFalse( deps.transitiveUse( thing4, thing7 ) ); - assertTrue( deps.transitiveUse( thing5, thing1 ) ); - assertFalse( deps.transitiveUse( thing5, thing2 ) ); - assertTrue( deps.transitiveUse( thing5, thing3 ) ); - assertTrue( deps.transitiveUse( thing5, thing4 ) ); - assertTrue( deps.transitiveUse( thing5, thing5 ) ); - assertTrue( deps.transitiveUse( thing5, thing6 ) ); - assertFalse( deps.transitiveUse( thing5, thing7 ) ); - assertFalse( deps.transitiveUse( thing6, thing1 ) ); - assertFalse( deps.transitiveUse( thing6, thing2 ) ); - assertFalse( deps.transitiveUse( thing6, thing3 ) ); - assertFalse( deps.transitiveUse( thing6, thing4 ) ); - assertFalse( deps.transitiveUse( thing6, thing5 ) ); - assertFalse( deps.transitiveUse( thing6, thing6 ) ); - assertFalse( deps.transitiveUse( thing6, thing7 ) ); - assertTrue( deps.transitiveUse( thing7, thing1 ) ); - assertTrue( deps.transitiveUse( thing7, thing2 ) ); - assertTrue( deps.transitiveUse( thing7, thing3 ) ); - assertTrue( deps.transitiveUse( thing7, thing4 ) ); - assertTrue( deps.transitiveUse( thing7, thing5 ) ); - assertTrue( deps.transitiveUse( thing7, thing6 ) ); - assertFalse( deps.transitiveUse( thing7, thing7 ) ); + assertThat( deps.transitiveUse( thing1, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing1, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing1, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing2, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing2, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing3, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing3, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing4, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing4, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing5, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing5, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing5, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing5, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing5, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing5, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing1 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing2 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing3 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing4 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing5 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing6 ), is( false ) ); + assertThat( deps.transitiveUse( thing6, thing7 ), is( false ) ); + assertThat( deps.transitiveUse( thing7, thing1 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing2 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing3 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing4 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing5 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing6 ), is( true ) ); + assertThat( deps.transitiveUse( thing7, thing7 ), is( false ) ); List<Thing> resolved = deps.resolveOrder(); System.out.println( resolved ); - assertTrue( resolved.indexOf( thing1 ) > resolved.indexOf( thing6 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing3 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing4 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing5 ) ); - assertTrue( resolved.indexOf( thing2 ) > resolved.indexOf( thing1 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing1 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing2 ) ); - assertTrue( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ) ); + assertThat( resolved.indexOf( thing1 ) > resolved.indexOf( thing6 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing3 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing4 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing5 ), is( true ) ); + assertThat( resolved.indexOf( thing2 ) > resolved.indexOf( thing1 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing1 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing2 ), is( true ) ); + assertThat( resolved.indexOf( thing7 ) > resolved.indexOf( thing4 ), is( true ) ); // The cyclic nodes can not be determine which one is before the other } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UseCompositeTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UseCompositeTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UseCompositeTest.java index 16cb948..840bd10 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UseCompositeTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/UseCompositeTest.java @@ -26,10 +26,10 @@ 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.Test; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; public class UseCompositeTest extends AbstractPolygeneTest { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/GenericConcernTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/GenericConcernTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/GenericConcernTest.java index 5238a49..540436c 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/GenericConcernTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/GenericConcernTest.java @@ -30,7 +30,7 @@ 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.Test; +import org.junit.jupiter.api.Test; /** * Tests for GenericConcern http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/MethodConcernsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/MethodConcernsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/MethodConcernsTest.java index 245c12f..eaf00d2 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/MethodConcernsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/MethodConcernsTest.java @@ -27,10 +27,10 @@ import org.apache.polygene.api.sideeffect.SideEffects; 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 org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; public class MethodConcernsTest extends AbstractPolygeneTest { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/ModuleConcernTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/ModuleConcernTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/ModuleConcernTest.java index b2e9e47..6403899 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/ModuleConcernTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/ModuleConcernTest.java @@ -22,7 +22,6 @@ package org.apache.polygene.runtime.concerns; import java.lang.reflect.Method; import java.util.Arrays; -import org.junit.Test; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.concern.GenericConcern; import org.apache.polygene.api.mixin.Mixins; @@ -31,9 +30,10 @@ import org.apache.polygene.bootstrap.AssemblyVisitorAdapter; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.bootstrap.TransientDeclaration; 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 concern in assembly http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/PropertyInheritanceTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/PropertyInheritanceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/PropertyInheritanceTest.java index 1982f2d..796985d 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/PropertyInheritanceTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/concerns/PropertyInheritanceTest.java @@ -29,10 +29,10 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.AssemblyReportException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; //TODO 2.0 removed this possibility when simplifying the Property handling. So, we are now checking that a decent // exception is thrown, but should be changed to supported instead. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java index f7d40d5..ae6d44c 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java @@ -23,23 +23,24 @@ import java.lang.annotation.Retention; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; import org.apache.polygene.api.common.Optional; import org.apache.polygene.api.composite.TransientComposite; import org.apache.polygene.api.constraint.Constraint; import org.apache.polygene.api.constraint.ConstraintDeclaration; -import org.apache.polygene.api.constraint.ValueConstraintViolation; import org.apache.polygene.api.constraint.ConstraintViolationException; import org.apache.polygene.api.constraint.Constraints; import org.apache.polygene.api.constraint.Name; +import org.apache.polygene.api.constraint.ValueConstraintViolation; 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 java.lang.annotation.RetentionPolicy.RUNTIME; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.jupiter.api.Assertions.fail; public class ConstraintsTest extends AbstractPolygeneTest @@ -67,8 +68,8 @@ public class ConstraintsTest catch( ConstraintViolationException e ) { Collection<ValueConstraintViolation> violations = e.constraintViolations(); - assertEquals( 2, violations.size() ); -// assertEquals( MyOne.class.getName(), e.mixinTypeName() ); + assertThat( violations.size(), equalTo( 2 ) ); +// assertThat( e.mixinTypeName() , equalTo( MyOne.class.getName())); } } @@ -88,8 +89,8 @@ public class ConstraintsTest catch( ConstraintViolationException e ) { Collection<ValueConstraintViolation> violations = e.constraintViolations(); - assertEquals( 2, violations.size() ); -// assertEquals( MyOne.class.getName(), e.mixinTypeName() ); + assertThat( violations.size(), equalTo( 2 ) ); +// assertThat( e.mixinTypeName() , equalTo( MyOne.class.getName())); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java index fe3e46a..427568e 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java @@ -30,12 +30,12 @@ import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.property.Property; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; /** * JAVADOC @@ -64,11 +64,11 @@ public class UseDefaultsTest extends AbstractPolygeneTest assertThat( "assemblyString is set string", testComposite.assemblyString().get(), equalTo( "habba" ) ); assertThat( "nullPrimitiveArray is null", testComposite.nullPrimitiveArray().get(), nullValue() ); - assertTrue( "emptyPrimitiveArray is empty", - Arrays.equals( testComposite.emptyPrimitiveArray().get(), new int[ 0 ] ) ); + assertThat( "emptyPrimitiveArray is empty", + Arrays.equals( testComposite.emptyPrimitiveArray().get(), new int[ 0 ] ), is( true ) ); assertThat( "nullArray is null", testComposite.nullArray().get(), nullValue() ); - assertTrue( "emptyArray is empty array", - Arrays.equals( testComposite.emptyArray().get(), new Integer[ 0 ] ) ); + assertThat( "emptyArray is empty array", + Arrays.equals( testComposite.emptyArray().get(), new Integer[ 0 ] ), is( true ) ); } @Test @@ -85,10 +85,14 @@ public class UseDefaultsTest extends AbstractPolygeneTest Map<String, Integer> expectedMap = Collections.singletonMap( "abcd", 345 ); assertThat( testComposite.initializedMapDefaultValue().get(), equalTo( expectedMap ) ); - assertTrue( "initializedPrimitiveArray is set", - Arrays.equals( testComposite.initializedPrimitiveArray().get(), new int[] { 23, 42 } ) ); - assertTrue( "initializedArray is set", - Arrays.equals( testComposite.initializedArray().get(), new Integer[] { 23, 42 } ) ); + assertThat( "initializedPrimitiveArray is set", + Arrays.equals( testComposite.initializedPrimitiveArray().get(), new int[]{ 23, 42 } ), + is( true ) + ); + assertThat( "initializedArray is set", + Arrays.equals( testComposite.initializedArray().get(), new Integer[]{ 23, 42 } ), + is( true ) + ); } interface TestComposite
