http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java b/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java index 3c59c82..41d3fa4 100644 --- a/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java +++ b/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java @@ -20,7 +20,7 @@ package org.apache.polygene.library.appbrowser; import java.io.StringWriter; import java.io.Writer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.polygene.api.association.Association; import org.apache.polygene.api.association.ManyAssociation; import org.apache.polygene.api.common.Optional;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/BreaksCircuitOnThrowableTest.java ---------------------------------------------------------------------- diff --git a/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/BreaksCircuitOnThrowableTest.java b/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/BreaksCircuitOnThrowableTest.java index 6d944d5..1bf99c0 100644 --- a/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/BreaksCircuitOnThrowableTest.java +++ b/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/BreaksCircuitOnThrowableTest.java @@ -20,8 +20,6 @@ package org.apache.polygene.library.circuitbreaker; import java.beans.PropertyVetoException; -import org.junit.Assert; -import org.junit.Test; import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.api.service.ServiceComposite; import org.apache.polygene.api.service.ServiceReference; @@ -30,6 +28,10 @@ import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.circuitbreaker.service.AbstractBreakOnThrowable; import org.apache.polygene.library.circuitbreaker.service.BreaksCircuitOnThrowable; import org.apache.polygene.test.AbstractPolygeneTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * Test @BreaksCircuitOnThrowable annotation @@ -40,7 +42,7 @@ public class BreaksCircuitOnThrowableTest // START SNIPPET: service public void assemble( ModuleAssembly module ) - throws AssemblyException + throws AssemblyException { module.services( TestService.class ).setMetaInfo( new CircuitBreaker() ); } @@ -60,37 +62,33 @@ public class BreaksCircuitOnThrowableTest { ServiceReference<TestService> serviceReference = serviceFinder.findService( TestService.class ); TestService service = serviceReference.get(); - try { - service.throwingMethod(); - Assert.fail( "Service should have thrown exception" ); - } catch ( Exception e ) { - // Ok - } + assertThrows( Exception.class, () -> service.throwingMethod(), "Service should have thrown exception" ); - try { - service.successfulMethod(); - Assert.fail( "Circuit breaker should have tripped" ); - } catch ( Exception e ) { - // Ok - } + assertThrows( Exception.class, () -> service.successfulMethod(), "Circuit breaker should have tripped" ); - try { + try + { serviceReference.metaInfo( CircuitBreaker.class ).turnOn(); - } catch ( PropertyVetoException e ) { - Assert.fail( "Should have been possible to turn on circuit breaker" ); + } + catch( PropertyVetoException e ) + { + fail( "Should have been possible to turn on circuit breaker" ); } - try { + try + { service.successfulMethod(); - } catch ( Exception e ) { - Assert.fail( "Circuit breaker should have been turned on" ); + } + catch( Exception e ) + { + fail( "Circuit breaker should have been turned on" ); } } @Mixins( TestService.Mixin.class ) // START SNIPPET: service public interface TestService - extends AbstractBreakOnThrowable, ServiceComposite + extends AbstractBreakOnThrowable, ServiceComposite { @BreaksCircuitOnThrowable @@ -101,7 +99,7 @@ public class BreaksCircuitOnThrowableTest // END SNIPPET: service abstract class Mixin - implements TestService + implements TestService { int count = 0; @@ -115,11 +113,9 @@ public class BreaksCircuitOnThrowableTest { return count++; } - } // START SNIPPET: service } // END SNIPPET: service - } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/CircuitBreakerTest.java ---------------------------------------------------------------------- diff --git a/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/CircuitBreakerTest.java b/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/CircuitBreakerTest.java index cf47c91..bdcefad 100644 --- a/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/CircuitBreakerTest.java +++ b/libraries/circuitbreaker/src/test/java/org/apache/polygene/library/circuitbreaker/CircuitBreakerTest.java @@ -26,13 +26,13 @@ import java.beans.VetoableChangeListener; import java.io.IOException; import java.util.concurrent.Callable; import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; import static org.awaitility.Duration.ONE_SECOND; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; /** * JAVADOC @@ -42,7 +42,7 @@ public class CircuitBreakerTest private CircuitBreaker cb; - @Before + @BeforeEach public void createCircuitBreaker() { // START SNIPPET: direct http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java ---------------------------------------------------------------------- diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java index 8b697b9..5248caa 100644 --- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java +++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java @@ -27,9 +27,9 @@ import org.apache.polygene.api.constraint.ConstraintViolationException; 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.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ConstraintTest extends AbstractPolygeneTest { @@ -41,12 +41,13 @@ public class ConstraintTest extends AbstractPolygeneTest module.transients( TestCaseComposite.class ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testContainsFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().containsString().set( "bar" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().containsString().set( "bar" ); + } ); } @Test @@ -58,12 +59,13 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().containsString().set( "xxxfooyyy" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testEmailFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().email().set( "foo.com" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().email().set( "foo.com" ); + } ); } @Test @@ -74,11 +76,13 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().email().set( "rick...@gmail.com" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testURLFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().url().set( "this is no url" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().url().set( "this is no url" ); + } ); } @Test @@ -88,11 +92,13 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().url().set( "http://polygene.apache.org/path?query=string#fragment" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testURIFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().uri().set( "" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().uri().set( "" ); + } ); } @Test @@ -102,99 +108,99 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().uri().set( "http://polygene.apache.org/path?query=string#fragment" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testGreaterThanFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().greaterThan().set( 10 ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().greaterThan().set( 10 ); + } ); } @Test public void testGreaterThanOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().greaterThan().set( 11 ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testInstanceOfFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().instanceOf().set( new HashSet() ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().instanceOf().set( new HashSet() ); + } ); } @Test public void testInstanceOfOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().instanceOf().set( new ArrayList() ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testLessThanFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().lessThan().set( 10 ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().lessThan().set( 10 ); + } ); } @Test public void testLessThanOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().lessThan().set( 9 ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testMatchesFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().matches().set( "cba" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().matches().set( "cba" ); + } ); } @Test public void testMatchesOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().matches().set( "abbccc" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testMaxLengthFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().maxLength().set( "xxxxx" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().maxLength().set( "xxxxx" ); + } ); } @Test public void testMaxLengthOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().maxLength().set( "xxx" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testMinLengthFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().minLength().set( "xx" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().minLength().set( "xx" ); + } ); } @Test public void testMinLengthOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().minLength().set( "xxx" ); } @@ -202,32 +208,17 @@ public class ConstraintTest extends AbstractPolygeneTest public void testNotEmptyFail() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - try - { + assertThrows( ConstraintViolationException.class, () -> { cb.prototype().notEmptyString().set( "" ); - fail( "Should have thrown exception" ); - } - catch( ConstraintViolationException e ) - { - } - - try - { + } ); + + assertThrows( ConstraintViolationException.class, () -> { cb.prototype().notEmptyCollection().set( new ArrayList() ); - fail( "Should have thrown exception" ); - } - catch( ConstraintViolationException e ) - { - } - - try - { + } ); + + assertThrows( ConstraintViolationException.class, () -> { cb.prototype().notEmptyList().set( new ArrayList() ); - fail( "Should have thrown exception" ); - } - catch( ConstraintViolationException e ) - { - } + } ); } @Test @@ -239,12 +230,13 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().notEmptyList().set( Collections.singletonList( "X" ) ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testOneOfFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().oneOf().set( "Foo" ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().oneOf().set( "Foo" ); + } ); } @Test @@ -255,19 +247,19 @@ public class ConstraintTest extends AbstractPolygeneTest cb.prototype().oneOf().set( "Bar" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testRangeFail() { - TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - - cb.prototype().range().set( 101 ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); + cb.prototype().range().set( 101 ); + } ); } @Test public void testRangeOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); - cb.prototype().range().set( 0 ); cb.prototype().range().set( 50 ); cb.prototype().range().set( 100 ); @@ -279,5 +271,4 @@ public class ConstraintTest extends AbstractPolygeneTest TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().testParameters( 15 ); } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java ---------------------------------------------------------------------- diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java index 477f95d..75d525a 100644 --- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java +++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java @@ -26,7 +26,9 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.constraints.annotation.HostPort; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class HostPortConstraintTest extends AbstractPolygeneTest { @@ -71,20 +73,24 @@ public class HostPortConstraintTest extends AbstractPolygeneTest someValue.hostPort().set( "localhost:1234" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidHostNameWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1:2:3_i:1234" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1:2:3_i:1234" ); + } ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidPortNumberWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1.2.3.4:123456" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1.2.3.4:123456" ); + } ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java ---------------------------------------------------------------------- diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java index 430ffd7..2bbfa1d 100644 --- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java +++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java @@ -26,7 +26,9 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.constraints.annotation.HostPortList; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class HostPortListConstraintTest extends AbstractPolygeneTest { @@ -63,20 +65,24 @@ public class HostPortListConstraintTest extends AbstractPolygeneTest someValue.hostPort().set( "habba.zout.com:1234" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidHostNameWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1:2:3_i:1234" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1:2:3_i:1234" ); + } ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidPortNumberWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1.2.3.4:123456" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1.2.3.4:123456" ); + } ); } @Test @@ -111,20 +117,24 @@ public class HostPortListConstraintTest extends AbstractPolygeneTest someValue.hostPort().set( "habba.zout.com:1234,12.34.56.78:1234" ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidListHostNameWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1.2.3.4:12,1:2:3_i:1234" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1.2.3.4:12,1:2:3_i:1234" ); + } ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void givenInvalidListPortNumberWhenSettingPropertyExpectConstrainViolation() throws Exception { - SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); - someValue.hostPort().set( "1.2.3.4:1234 1.2.3.4:123456" ); + assertThrows( ConstraintViolationException.class, () -> { + SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); + someValue.hostPort().set( "1.2.3.4:1234 1.2.3.4:123456" ); + } ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/qi70/IssueTest.java ---------------------------------------------------------------------- diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/qi70/IssueTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/qi70/IssueTest.java index 5f52393..129bfe5 100644 --- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/qi70/IssueTest.java +++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/qi70/IssueTest.java @@ -19,12 +19,14 @@ */ package org.apache.polygene.library.constraints.qi70; -import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.constraint.ConstraintViolationException; 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.jupiter.api.Assertions.assertThrows; public class IssueTest extends AbstractPolygeneTest @@ -36,10 +38,12 @@ public class IssueTest module.transients( SampleComposite.class ); } - @Test( expected = ConstraintViolationException.class ) + @Test public void testNotEmpty() { - TransientBuilder<Sample> cb = transientBuilderFactory.newTransientBuilder( Sample.class ); - cb.prototypeFor( Sample.class ).stuff().set( null ); + assertThrows( ConstraintViolationException.class, () -> { + TransientBuilder<Sample> cb = transientBuilderFactory.newTransientBuilder( Sample.class ); + cb.prototypeFor( Sample.class ).stuff().set( null ); + } ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/fileconfig/build.gradle ---------------------------------------------------------------------- diff --git a/libraries/fileconfig/build.gradle b/libraries/fileconfig/build.gradle index 1e42d35..32fdd34 100644 --- a/libraries/fileconfig/build.gradle +++ b/libraries/fileconfig/build.gradle @@ -32,6 +32,7 @@ dependencies { runtimeOnly polygene.core.runtime testImplementation polygene.core.testsupport + testImplementation libraries.junit_vintage testRuntimeOnly libraries.logback } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/fileconfig/src/test/java/org/apache/polygene/library/fileconfig/FileConfigurationTest.java ---------------------------------------------------------------------- diff --git a/libraries/fileconfig/src/test/java/org/apache/polygene/library/fileconfig/FileConfigurationTest.java b/libraries/fileconfig/src/test/java/org/apache/polygene/library/fileconfig/FileConfigurationTest.java index 4cf5ac2..748ac34 100644 --- a/libraries/fileconfig/src/test/java/org/apache/polygene/library/fileconfig/FileConfigurationTest.java +++ b/libraries/fileconfig/src/test/java/org/apache/polygene/library/fileconfig/FileConfigurationTest.java @@ -24,11 +24,13 @@ import java.io.IOException; import org.apache.polygene.api.activation.ActivationException; import org.apache.polygene.bootstrap.SingletonAssembler; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.rules.TemporaryFolder; +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.assertEquals; -import static org.junit.Assert.assertNotNull; public class FileConfigurationTest { @@ -48,11 +50,11 @@ public class FileConfigurationTest ); FileConfiguration config = assembler.module().findService( FileConfiguration.class ).get(); - assertNotNull( config.configurationDirectory() ); - assertNotNull( config.dataDirectory() ); - assertNotNull( config.temporaryDirectory() ); - assertNotNull( config.cacheDirectory() ); - assertNotNull( config.logDirectory() ); + assertThat( config.configurationDirectory(), notNullValue() ); + assertThat( config.dataDirectory(), notNullValue() ); + assertThat( config.temporaryDirectory(), notNullValue() ); + assertThat( config.cacheDirectory(), notNullValue() ); + assertThat( config.logDirectory(), notNullValue() ); System.out.println( "FileConfiguration defaults:\n" + "\tconfiguration: " + config.configurationDirectory().getAbsolutePath() + "\n" + "\tdata: " + config.configurationDirectory().getAbsolutePath() + "\n" @@ -87,11 +89,11 @@ public class FileConfigurationTest FileConfiguration config = assembler.module().findService( FileConfiguration.class ).get(); - assertEquals( testFile.getAbsolutePath(), config.configurationDirectory().getAbsolutePath() ); - assertEquals( testFile.getAbsolutePath(), config.dataDirectory().getAbsolutePath() ); - assertEquals( testFile.getAbsolutePath(), config.temporaryDirectory().getAbsolutePath() ); - assertEquals( testFile.getAbsolutePath(), config.cacheDirectory().getAbsolutePath() ); - assertEquals( testFile.getAbsolutePath(), config.logDirectory().getAbsolutePath() ); + assertThat( config.configurationDirectory().getAbsolutePath(), equalTo( testFile.getAbsolutePath() ) ); + assertThat( config.dataDirectory().getAbsolutePath(), equalTo( testFile.getAbsolutePath() ) ); + assertThat( config.temporaryDirectory().getAbsolutePath(), equalTo( testFile.getAbsolutePath() ) ); + assertThat( config.cacheDirectory().getAbsolutePath(), equalTo( testFile.getAbsolutePath() ) ); + assertThat( config.logDirectory().getAbsolutePath(), equalTo( testFile.getAbsolutePath() ) ); } @Test http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/build.gradle ---------------------------------------------------------------------- diff --git a/libraries/http/build.gradle b/libraries/http/build.gradle index 651249b..7fe1d7f 100644 --- a/libraries/http/build.gradle +++ b/libraries/http/build.gradle @@ -39,6 +39,7 @@ dependencies { testImplementation polygene.core.testsupport testImplementation libraries.http_client testImplementation libraries.junit + testImplementation libraries.junit_vintage testRuntimeOnly libraries.logback } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/test/java/org/apache/polygene/library/http/AbstractJettyTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/test/java/org/apache/polygene/library/http/AbstractJettyTest.java b/libraries/http/src/test/java/org/apache/polygene/library/http/AbstractJettyTest.java index bfa1c53..351c7ff 100644 --- a/libraries/http/src/test/java/org/apache/polygene/library/http/AbstractJettyTest.java +++ b/libraries/http/src/test/java/org/apache/polygene/library/http/AbstractJettyTest.java @@ -22,17 +22,15 @@ package org.apache.polygene.library.http; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Security; - import org.apache.http.HttpResponse; import org.apache.http.client.ResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; - import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; public abstract class AbstractJettyTest extends AbstractPolygeneTest @@ -49,14 +47,14 @@ public abstract class AbstractJettyTest }; - @BeforeClass + @BeforeAll public static void beforeJettyTestClass() { // Be sure that no test trigger a DNS cache, needed by VirtualHosts test plumbing Security.setProperty( "networkaddress.cache.ttl", "0" ); } - @Before + @BeforeEach public void before() throws GeneralSecurityException, IOException { @@ -64,7 +62,7 @@ public abstract class AbstractJettyTest defaultHttpClient = HttpClients.createDefault(); } - @After + @AfterEach public void after() throws IOException { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/test/java/org/apache/polygene/library/http/JettyJMXStatisticsTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/test/java/org/apache/polygene/library/http/JettyJMXStatisticsTest.java b/libraries/http/src/test/java/org/apache/polygene/library/http/JettyJMXStatisticsTest.java index c8ba055..cad23c7 100644 --- a/libraries/http/src/test/java/org/apache/polygene/library/http/JettyJMXStatisticsTest.java +++ b/libraries/http/src/test/java/org/apache/polygene/library/http/JettyJMXStatisticsTest.java @@ -19,14 +19,14 @@ */ package org.apache.polygene.library.http; -import org.apache.polygene.test.AbstractPolygeneTest; -import org.apache.polygene.test.util.FreePortFinder; -import org.junit.Test; import org.apache.polygene.api.common.Visibility; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.jmx.JMXAssembler; +import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; +import org.apache.polygene.test.util.FreePortFinder; +import org.junit.jupiter.api.Test; import static org.apache.polygene.library.http.Servlets.addServlets; import static org.apache.polygene.library.http.Servlets.serve; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/test/java/org/apache/polygene/library/http/JettyServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/test/java/org/apache/polygene/library/http/JettyServiceTest.java b/libraries/http/src/test/java/org/apache/polygene/library/http/JettyServiceTest.java index 6a258fb..a3ef382 100644 --- a/libraries/http/src/test/java/org/apache/polygene/library/http/JettyServiceTest.java +++ b/libraries/http/src/test/java/org/apache/polygene/library/http/JettyServiceTest.java @@ -22,22 +22,23 @@ package org.apache.polygene.library.http; import java.util.Iterator; import java.util.stream.Collectors; import org.apache.http.client.methods.HttpGet; -import org.apache.polygene.test.util.FreePortFinder; -import org.junit.Test; import org.apache.polygene.api.common.Visibility; import org.apache.polygene.api.service.ServiceReference; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.EntityTestAssembler; +import org.apache.polygene.test.util.FreePortFinder; +import org.hamcrest.core.Is; +import org.junit.Test; import static javax.servlet.DispatcherType.REQUEST; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.apache.polygene.library.http.Servlets.addFilters; import static org.apache.polygene.library.http.Servlets.addServlets; import static org.apache.polygene.library.http.Servlets.filter; import static org.apache.polygene.library.http.Servlets.serve; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.IsNull.notNullValue; public final class JettyServiceTest extends AbstractJettyTest @@ -74,19 +75,19 @@ public final class JettyServiceTest { Iterable<ServiceReference<JettyService>> services = serviceFinder.findServices( JettyService.class ) .collect( Collectors.toList() ); - assertNotNull( services ); + assertThat( services, notNullValue() ); Iterator<ServiceReference<JettyService>> iterator = services.iterator(); - assertTrue( iterator.hasNext() ); + assertThat( iterator.hasNext(), Is.is( true ) ); ServiceReference<JettyService> serviceRef = iterator.next(); - assertNotNull( serviceRef ); + assertThat( serviceRef, notNullValue() ); JettyService jettyService = serviceRef.get(); - assertNotNull( jettyService ); + assertThat( jettyService, notNullValue() ); String output = defaultHttpClient.execute( new HttpGet( "http://127.0.0.1:" + httpPort + "/helloWorld" ), stringResponseHandler ); - assertEquals( "Hello World", output ); + assertThat( output, equalTo( "Hello World" ) ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/test/java/org/apache/polygene/library/http/MutualSecureJettyServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/test/java/org/apache/polygene/library/http/MutualSecureJettyServiceTest.java b/libraries/http/src/test/java/org/apache/polygene/library/http/MutualSecureJettyServiceTest.java index 59dc186..843ed8f 100644 --- a/libraries/http/src/test/java/org/apache/polygene/library/http/MutualSecureJettyServiceTest.java +++ b/libraries/http/src/test/java/org/apache/polygene/library/http/MutualSecureJettyServiceTest.java @@ -21,16 +21,17 @@ package org.apache.polygene.library.http; import java.io.IOException; import org.apache.http.client.methods.HttpGet; -import org.apache.polygene.test.util.FreePortFinder; -import org.junit.Test; import org.apache.polygene.api.common.Visibility; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.EntityTestAssembler; +import org.apache.polygene.test.util.FreePortFinder; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; import static org.apache.polygene.library.http.Servlets.addServlets; import static org.apache.polygene.library.http.Servlets.serve; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class MutualSecureJettyServiceTest extends AbstractSecureJettyTest @@ -70,7 +71,7 @@ public class MutualSecureJettyServiceTest // As we set wantClientAuth we can request without a client certificate ... String output = trustHttpClient.execute( new HttpGet( "https://127.0.0.1:" + httpsPort + "/hello" ), stringResponseHandler ); - assertEquals( "Hello World", output ); + assertThat( output, equalTo( "Hello World" ) ); } @Test @@ -80,6 +81,6 @@ public class MutualSecureJettyServiceTest // ... and with one String output = mutualHttpClient.execute( new HttpGet( "https://127.0.0.1:" + httpsPort + "/hello" ), stringResponseHandler ); - assertEquals( "Hello Mutual World", output ); + assertThat( output, equalTo( "Hello Mutual World" ) ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/test/java/org/apache/polygene/library/http/SecureJettyServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/test/java/org/apache/polygene/library/http/SecureJettyServiceTest.java b/libraries/http/src/test/java/org/apache/polygene/library/http/SecureJettyServiceTest.java index 20a567b..0f22a10 100644 --- a/libraries/http/src/test/java/org/apache/polygene/library/http/SecureJettyServiceTest.java +++ b/libraries/http/src/test/java/org/apache/polygene/library/http/SecureJettyServiceTest.java @@ -23,20 +23,21 @@ import java.io.IOException; import javax.net.ssl.SSLHandshakeException; import org.apache.http.NoHttpResponseException; import org.apache.http.client.methods.HttpGet; -import org.apache.polygene.test.util.FreePortFinder; -import org.junit.Test; import org.apache.polygene.api.common.Visibility; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.EntityTestAssembler; +import org.apache.polygene.test.util.FreePortFinder; +import org.junit.Test; import static javax.servlet.DispatcherType.REQUEST; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; import static org.apache.polygene.library.http.Servlets.addFilters; import static org.apache.polygene.library.http.Servlets.addServlets; import static org.apache.polygene.library.http.Servlets.filter; import static org.apache.polygene.library.http.Servlets.serve; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.jupiter.api.Assertions.fail; public class SecureJettyServiceTest extends AbstractSecureJettyTest @@ -93,6 +94,6 @@ public class SecureJettyServiceTest { String output = trustHttpClient.execute( new HttpGet( "https://127.0.0.1:" + httpsPort + "/hello" ), stringResponseHandler ); - assertEquals( "Hello World", output ); + assertThat( output, equalTo( "Hello World" ) ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/http/src/vhost-test/java/org/apache/polygene/library/http/VirtualHostJettyServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/vhost-test/java/org/apache/polygene/library/http/VirtualHostJettyServiceTest.java b/libraries/http/src/vhost-test/java/org/apache/polygene/library/http/VirtualHostJettyServiceTest.java index 8e363c1..dafcb4f 100644 --- a/libraries/http/src/vhost-test/java/org/apache/polygene/library/http/VirtualHostJettyServiceTest.java +++ b/libraries/http/src/vhost-test/java/org/apache/polygene/library/http/VirtualHostJettyServiceTest.java @@ -26,14 +26,15 @@ import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.http.dns.LocalManagedDns; import org.apache.polygene.test.EntityTestAssembler; import org.apache.polygene.test.util.FreePortFinder; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.apache.polygene.library.http.Servlets.addServlets; import static org.apache.polygene.library.http.Servlets.serve; import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class VirtualHostJettyServiceTest extends AbstractJettyTest @@ -43,7 +44,7 @@ public class VirtualHostJettyServiceTest private final int httpPort = FreePortFinder.findFreePortOnLoopback(); - @BeforeClass + @BeforeAll public static void beforeVirtualHostsClass() { assumeNoIbmJdk(); @@ -51,7 +52,7 @@ public class VirtualHostJettyServiceTest LocalManagedDns.putName( HOST2, "127.0.0.1" ); } - @AfterClass + @AfterAll public static void afterVirtualHostsClass() { LocalManagedDns.removeName( HOST1 ); @@ -80,10 +81,10 @@ public class VirtualHostJettyServiceTest // Available on HOST1 and HOST2 String output = defaultHttpClient.execute( new HttpGet( "http://" + HOST1 + ":" + httpPort + "/hello" ), stringResponseHandler ); - assertEquals( "Hello World", output ); + assertThat( output, equalTo( "Hello World" ) ); output = defaultHttpClient.execute( new HttpGet( "http://" + HOST2 + ":" + httpPort + "/hello" ), stringResponseHandler ); - assertEquals( "Hello World", output ); + assertThat( output, equalTo( "Hello World" ) ); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/jmx/src/test/java/org/apache/polygene/library/jmx/JMXTest.java ---------------------------------------------------------------------- diff --git a/libraries/jmx/src/test/java/org/apache/polygene/library/jmx/JMXTest.java b/libraries/jmx/src/test/java/org/apache/polygene/library/jmx/JMXTest.java index 4db31b2..5e271a0 100644 --- a/libraries/jmx/src/test/java/org/apache/polygene/library/jmx/JMXTest.java +++ b/libraries/jmx/src/test/java/org/apache/polygene/library/jmx/JMXTest.java @@ -37,7 +37,7 @@ import org.apache.polygene.bootstrap.SingletonAssembler; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import org.apache.polygene.test.util.JmxFixture; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Start a simple server so that it can be accessed through JMX remotely. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/locking/src/test/java/org/apache/polygene/library/locking/LockingTest.java ---------------------------------------------------------------------- diff --git a/libraries/locking/src/test/java/org/apache/polygene/library/locking/LockingTest.java b/libraries/locking/src/test/java/org/apache/polygene/library/locking/LockingTest.java index 6ed836e..e807f9a 100644 --- a/libraries/locking/src/test/java/org/apache/polygene/library/locking/LockingTest.java +++ b/libraries/locking/src/test/java/org/apache/polygene/library/locking/LockingTest.java @@ -20,16 +20,15 @@ package org.apache.polygene.library.locking; -import org.junit.Test; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; 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 java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.Test; /** * JAVADOC http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/logging/src/test/java/org/apache/polygene/library/logging/DebuggingTest.java ---------------------------------------------------------------------- diff --git a/libraries/logging/src/test/java/org/apache/polygene/library/logging/DebuggingTest.java b/libraries/logging/src/test/java/org/apache/polygene/library/logging/DebuggingTest.java index 407d309..f758adf 100644 --- a/libraries/logging/src/test/java/org/apache/polygene/library/logging/DebuggingTest.java +++ b/libraries/logging/src/test/java/org/apache/polygene/library/logging/DebuggingTest.java @@ -39,9 +39,10 @@ import org.apache.polygene.spi.entity.EntityState; import org.apache.polygene.spi.entitystore.EntityStore; 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.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class DebuggingTest extends AbstractPolygeneTest @@ -68,10 +69,10 @@ public class DebuggingTest // QueryBuilder<DebugRecord> builder = module.newQueryBuilder( DebugRecord.class ); // Query<DebugRecord> query = builder.newQuery( uow ); -// assertEquals( 0, query.count() ); +// assertThat( query.count() , equalTo( 0)); Some service = serviceFinder.findService( Some.class ).get(); String message = service.doSomething( "World!", 10 ); - assertEquals( message, "Hello!" ); + assertThat( "Hello!", equalTo( message ) ); EntityStore es = serviceFinder.findService( EntityStore.class ).get(); final Identity[] result = new Identity[1]; try( Stream<EntityState> entityStates = es.entityStates( module ) ) @@ -90,7 +91,7 @@ public class DebuggingTest ServiceDebugRecordEntity debugEntry = uow.get( ServiceDebugRecordEntity.class, result[ 0 ] ); String mess = debugEntry.message().get(); System.out.println( mess ); - assertEquals( "some message.", mess ); + assertThat( mess, equalTo( "some message." ) ); uow.complete(); } catch( ConcurrentEntityModificationException e ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/logging/src/test/java/org/apache/polygene/library/logging/TracingTest.java ---------------------------------------------------------------------- diff --git a/libraries/logging/src/test/java/org/apache/polygene/library/logging/TracingTest.java b/libraries/logging/src/test/java/org/apache/polygene/library/logging/TracingTest.java index 852a868..c70d2d7 100644 --- a/libraries/logging/src/test/java/org/apache/polygene/library/logging/TracingTest.java +++ b/libraries/logging/src/test/java/org/apache/polygene/library/logging/TracingTest.java @@ -20,7 +20,7 @@ package org.apache.polygene.library.logging; -import org.junit.Test; +import java.util.Iterator; import org.apache.polygene.api.concern.ConcernOf; import org.apache.polygene.api.concern.Concerns; import org.apache.polygene.api.mixin.Mixins; @@ -40,13 +40,14 @@ import org.apache.polygene.library.logging.trace.records.EntityTraceRecordEntity import org.apache.polygene.library.logging.trace.records.ServiceTraceRecordEntity; import org.apache.polygene.library.logging.trace.records.TraceRecord; import org.apache.polygene.test.AbstractPolygeneTest; - -import java.util.Iterator; import org.apache.polygene.test.EntityTestAssembler; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; import static org.apache.polygene.api.query.QueryExpressions.orderBy; import static org.apache.polygene.api.query.QueryExpressions.templateFor; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsEqual.equalTo; public class TracingTest extends AbstractPolygeneTest @@ -69,8 +70,8 @@ public class TracingTest throws Exception { SomeService sc = serviceFinder.findService( SomeService.class ).get(); - assertEquals( 123, sc.doSomethingImportant() ); - assertEquals( 456, sc.doSomethingLessImportant() ); + assertThat( sc.doSomethingImportant(), equalTo( 123 ) ); + assertThat( sc.doSomethingLessImportant(), equalTo( 456 ) ); UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class ); Query<TraceRecord> query = uow.newQuery( builder ); @@ -78,10 +79,10 @@ public class TracingTest // TraceRecord template = templateFor( TraceRecord.class ); // query.orderBy( orderBy( template.methodName() ) ); Iterator<TraceRecord> result = query.iterator(); - assertTrue( result.hasNext() ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec1 = result.next(); - assertEquals( "doSomethingImportant", rec1.methodName().get() ); - assertFalse( result.hasNext() ); + assertThat( rec1.methodName().get(), equalTo( "doSomethingImportant" ) ); + assertThat( result.hasNext(), is( false ) ); uow.complete(); } @@ -90,8 +91,8 @@ public class TracingTest throws Exception { SomeService2 sc = serviceFinder.findService( SomeService2.class ).get(); - assertEquals( 123, sc.doSomethingImportant() ); - assertEquals( 456, sc.doSomethingLessImportant() ); + assertThat( sc.doSomethingImportant(), equalTo( 123 ) ); + assertThat( sc.doSomethingLessImportant(), equalTo( 456 ) ); UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class ); Query<TraceRecord> query = uow.newQuery( builder ); @@ -99,13 +100,13 @@ public class TracingTest // TraceRecord template = templateFor( TraceRecord.class ); // query.orderBy( orderBy( template.methodName() ) ); Iterator<TraceRecord> result = query.iterator(); - assertTrue( result.hasNext() ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec1 = result.next(); - assertEquals( "doSomethingImportant", rec1.methodName().get() ); - assertTrue( result.hasNext() ); + assertThat( rec1.methodName().get(), equalTo( "doSomethingImportant" ) ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec2 = result.next(); - assertEquals( "doSomethingLessImportant", rec2.methodName().get() ); - assertFalse( result.hasNext() ); + assertThat( rec2.methodName().get(), equalTo( "doSomethingLessImportant" ) ); + assertThat( result.hasNext(), is( false ) ); uow.complete(); } @@ -114,8 +115,8 @@ public class TracingTest throws Exception { SomeService sc = serviceFinder.findService( SomeService.class ).get(); - assertEquals( 123, sc.doSomethingImportant() ); - assertEquals( 789, sc.doSomethingModeratelyImportant() ); + assertThat( sc.doSomethingImportant(), equalTo( 123 ) ); + assertThat( sc.doSomethingModeratelyImportant(), equalTo( 789 ) ); UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { @@ -125,13 +126,13 @@ public class TracingTest TraceRecord template = templateFor( TraceRecord.class ); query.orderBy( orderBy( template.methodName() ) ); Iterator<TraceRecord> result = query.iterator(); - assertTrue( result.hasNext() ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec1 = result.next(); - assertEquals( "doSomethingImportant", rec1.methodName().get() ); - assertTrue( result.hasNext() ); + assertThat( rec1.methodName().get(), equalTo( "doSomethingImportant" ) ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec2 = result.next(); - assertEquals( "doSomethingModeratelyImportant", rec2.methodName().get() ); - assertFalse( result.hasNext() ); + assertThat( rec2.methodName().get(), equalTo( "doSomethingModeratelyImportant" ) ); + assertThat( result.hasNext(), is( false ) ); uow.complete(); } catch( Exception e ) @@ -153,8 +154,8 @@ public class TracingTest // It is not possible to put Annotation on Concern Methods, so it should only record one. SomeService sc = serviceFinder.findService( SomeService.class ).get(); - assertEquals( 123, sc.doSomethingImportant() ); - assertEquals( 753, sc.doSomethingInsanelyImportant() ); + assertThat( sc.doSomethingImportant(), equalTo( 123 ) ); + assertThat( sc.doSomethingInsanelyImportant(), equalTo( 753 ) ); UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class ); Query<TraceRecord> query = uow.newQuery( builder ); @@ -162,10 +163,10 @@ public class TracingTest // TraceRecord template = templateFor( TraceRecord.class ); // query.orderBy( orderBy( template.methodName() ) ); Iterator<TraceRecord> result = query.iterator(); - assertTrue( result.hasNext() ); + assertThat( result.hasNext(), is( true ) ); TraceRecord rec1 = result.next(); - assertEquals( "doSomethingImportant", rec1.methodName().get() ); - assertFalse( result.hasNext() ); + assertThat( rec1.methodName().get(), equalTo( "doSomethingImportant" ) ); + assertThat( result.hasNext(), is( false ) ); uow.complete(); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/osgi/src/test/java/org/apache/polygene/library/osgi/OSGiServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/osgi/src/test/java/org/apache/polygene/library/osgi/OSGiServiceTest.java b/libraries/osgi/src/test/java/org/apache/polygene/library/osgi/OSGiServiceTest.java index 1514f54..b275145 100644 --- a/libraries/osgi/src/test/java/org/apache/polygene/library/osgi/OSGiServiceTest.java +++ b/libraries/osgi/src/test/java/org/apache/polygene/library/osgi/OSGiServiceTest.java @@ -19,15 +19,16 @@ */ package org.apache.polygene.library.osgi; -import org.junit.Test; -import org.osgi.framework.BundleContext; import org.apache.polygene.api.common.UseDefaults; 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 org.osgi.framework.BundleContext; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -54,7 +55,7 @@ public class OSGiServiceTest { MyService service = serviceFinder.findService( MyService.class ).get(); service.value().set( 15 ); - assertEquals( (Integer) 15, service.value().get() ); + assertThat( service.value().get(), equalTo( 15 ) ); String[] expectedClasses = new String[] { "org.apache.polygene.library.osgi.OSGiServiceTest$MyService", http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/build.gradle ---------------------------------------------------------------------- diff --git a/libraries/rdf/build.gradle b/libraries/rdf/build.gradle index 50babbe..6dad3e3 100644 --- a/libraries/rdf/build.gradle +++ b/libraries/rdf/build.gradle @@ -34,6 +34,7 @@ dependencies { runtimeOnly polygene.core.runtime testImplementation polygene.core.testsupport + testImplementation libraries.junit_vintage testRuntimeOnly libraries.logback } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/ApplicationXmlTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/ApplicationXmlTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/ApplicationXmlTest.java index e953c9b..f332e10 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/ApplicationXmlTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/ApplicationXmlTest.java @@ -35,7 +35,7 @@ import org.apache.polygene.bootstrap.LayerAssembly; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.rdf.model.ApplicationSerializer; import org.apache.polygene.test.AbstractPolygeneTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openrdf.model.Statement; import org.openrdf.rio.RDFHandlerException; import org.openrdf.rio.RDFWriter; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/Model2XMLTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/Model2XMLTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/Model2XMLTest.java index 865219a..1d650f6 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/Model2XMLTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/Model2XMLTest.java @@ -33,7 +33,7 @@ import org.apache.polygene.bootstrap.Energy4Java; import org.apache.polygene.bootstrap.LayerAssembly; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.rdf.model.Model2XML; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; /** http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java index 64512cb..d233090 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java @@ -44,7 +44,7 @@ import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openrdf.model.Statement; import org.openrdf.rio.RDFHandlerException; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java index 8e8d8d7..9d30057 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java @@ -39,7 +39,7 @@ import org.apache.polygene.spi.entitystore.EntityStore; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openrdf.model.Statement; import org.openrdf.rio.RDFHandlerException; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/MemoryRepositoryTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/MemoryRepositoryTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/MemoryRepositoryTest.java index bce71ed..e5acb43 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/MemoryRepositoryTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/MemoryRepositoryTest.java @@ -20,16 +20,17 @@ package org.apache.polygene.library.rdf.repository; +import org.apache.polygene.api.injection.scope.Service; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.AbstractPolygeneTest; import org.hamcrest.CoreMatchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.RepositoryException; -import org.apache.polygene.api.injection.scope.Service; -import org.apache.polygene.bootstrap.AssemblyException; -import org.apache.polygene.bootstrap.ModuleAssembly; + +import static org.hamcrest.MatcherAssert.assertThat; /** * JAVADOC @@ -50,7 +51,7 @@ public class MemoryRepositoryTest public void testMemoryRepository() throws RepositoryException { RepositoryConnection conn = repository.getConnection(); - Assert.assertThat( "repository is open", conn.isOpen(), CoreMatchers.equalTo( true ) ); + assertThat( "repository is open", conn.isOpen(), CoreMatchers.equalTo( true ) ); conn.close(); } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/NativeRepositoryTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/NativeRepositoryTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/NativeRepositoryTest.java index aaa6ce8..f1c3067 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/NativeRepositoryTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/repository/NativeRepositoryTest.java @@ -27,15 +27,16 @@ import org.apache.polygene.library.fileconfig.FileConfigurationAssembler; import org.apache.polygene.library.fileconfig.FileConfigurationOverride; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; -import org.hamcrest.CoreMatchers; -import org.junit.Assert; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.rules.TemporaryFolder; import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.RepositoryException; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; + /** * JAVADOC */ @@ -62,7 +63,7 @@ public class NativeRepositoryTest extends AbstractPolygeneTest public void testNativeRepository() throws RepositoryException { RepositoryConnection conn = repository.getConnection(); - Assert.assertThat("repository is open", conn.isOpen(), CoreMatchers.equalTo(true)); + assertThat( "repository is open", conn.isOpen(), equalTo( true ) ); conn.close(); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java ---------------------------------------------------------------------- diff --git a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java index b6854f5..951e334 100644 --- a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java +++ b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java @@ -70,11 +70,9 @@ import org.apache.polygene.library.rest.server.restlet.NullCommandResult; import org.apache.polygene.library.rest.server.spi.CommandResult; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.util.FreePortFinder; -import org.hamcrest.CoreMatchers; -import org.junit.After; -import org.junit.Assert; -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 org.restlet.Client; import org.restlet.Request; import org.restlet.Response; @@ -95,6 +93,8 @@ import static org.apache.polygene.bootstrap.ImportedServiceDeclaration.NEW_OBJEC import static org.apache.polygene.library.rest.client.api.HandlerCommand.command; import static org.apache.polygene.library.rest.client.api.HandlerCommand.query; import static org.apache.polygene.library.rest.client.api.HandlerCommand.refresh; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; public class ContextResourceClientFactoryTest extends AbstractPolygeneTest @@ -137,7 +137,7 @@ public class ContextResourceClientFactoryTest { } - @Before + @BeforeEach public void startWebServer() throws Exception { @@ -198,7 +198,7 @@ public class ContextResourceClientFactoryTest //END SNIPPET: client-create3 } - @After + @AfterEach public void stopWebServer() throws Exception { @@ -223,15 +223,15 @@ public class ContextResourceClientFactoryTest return query( "querywithoutvalue" ); } } ). - onQuery( "querywithoutvalue", new ResultHandler<TestResult>() - { - @Override - public HandlerCommand handleResult( TestResult result, ContextResourceClient client ) - { - Assert.assertThat( result.xyz().get(), CoreMatchers.equalTo( "bar" ) ); - return null; - } - } ); + onQuery( "querywithoutvalue", new ResultHandler<TestResult>() + { + @Override + public HandlerCommand handleResult( TestResult result, ContextResourceClient client ) + { + assertThat( result.xyz().get(), equalTo( "bar" ) ); + return null; + } + } ); crc.start(); //END SNIPPET: query-without-value @@ -364,11 +364,11 @@ public class ContextResourceClientFactoryTest @Override public HandlerCommand handleResult( Links result, ContextResourceClient client ) { - Assert.assertEquals( result.links().get().size(), 3 ); + assertThat( result.links().get().size(), equalTo( 3 ) ); return null; } } ) - .start(); + .start(); } public interface TestQuery @@ -442,9 +442,9 @@ public class ContextResourceClientFactoryTest public Links commandwithvalue() { return new LinksBuilder( module ). - command( "commandwithvalue" ). - addLink( "Command ABC", "right" ). - addLink( "Command XYZ", "wrong" ).newLinks(); + command( "commandwithvalue" ). + addLink( "Command ABC", "right" ). + addLink( "Command XYZ", "wrong" ).newLinks(); } @Override http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContinuousIntegrationTest.java ---------------------------------------------------------------------- diff --git a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContinuousIntegrationTest.java b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContinuousIntegrationTest.java index f2653ab..6386f1f 100644 --- a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContinuousIntegrationTest.java +++ b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContinuousIntegrationTest.java @@ -48,11 +48,9 @@ import org.apache.polygene.library.rest.server.restlet.NullCommandResult; import org.apache.polygene.library.rest.server.spi.CommandResult; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.util.FreePortFinder; -import org.hamcrest.CoreMatchers; -import org.junit.After; -import org.junit.Assert; -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 org.restlet.Client; import org.restlet.Request; import org.restlet.Response; @@ -73,6 +71,8 @@ import static org.apache.polygene.bootstrap.ImportedServiceDeclaration.NEW_OBJEC import static org.apache.polygene.library.rest.client.api.HandlerCommand.command; import static org.apache.polygene.library.rest.client.api.HandlerCommand.query; import static org.apache.polygene.library.rest.client.api.HandlerCommand.refresh; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; /** * ReST Client libraries documentation source snippets. @@ -112,7 +112,7 @@ public class ContinuousIntegrationTest { } - @Before + @BeforeEach public void startWebServer() throws Exception { @@ -173,7 +173,7 @@ public class ContinuousIntegrationTest //END SNIPPET: client-create3 } - @After + @AfterEach public void stopWebServer() throws Exception { @@ -202,7 +202,7 @@ public class ContinuousIntegrationTest @Override public HandlerCommand handleResult( ServerStatus result, ContextResourceClient client ) { - Assert.assertThat( result.currentStatus().get(), CoreMatchers.equalTo( "Idle" ) ); + assertThat( result.currentStatus().get(), equalTo( "Idle" ) ); return null; } } ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/RssReaderTest.java ---------------------------------------------------------------------- diff --git a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/RssReaderTest.java b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/RssReaderTest.java index a1fb7a0..5bfb054 100644 --- a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/RssReaderTest.java +++ b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/RssReaderTest.java @@ -36,8 +36,8 @@ import org.apache.polygene.library.rest.client.api.HandlerCommand; import org.apache.polygene.library.rest.client.spi.ResultHandler; import org.apache.polygene.library.rest.common.ValueAssembler; 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 org.restlet.Client; import org.restlet.data.Protocol; import org.restlet.data.Reference; @@ -58,7 +58,7 @@ public class RssReaderTest extends AbstractPolygeneTest { - @BeforeClass + @BeforeAll public static void beforeRssReaderTest() { assumeConnectivity( "github.com", 443 ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/docsupport/RestPrimerDocs.java ---------------------------------------------------------------------- diff --git a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/docsupport/RestPrimerDocs.java b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/docsupport/RestPrimerDocs.java index d805192..3e75e7d 100644 --- a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/docsupport/RestPrimerDocs.java +++ b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/docsupport/RestPrimerDocs.java @@ -19,8 +19,6 @@ */ package org.apache.polygene.library.rest.client.docsupport; -import org.hamcrest.CoreMatchers; -import org.junit.Assert; import org.apache.polygene.api.property.Property; import org.apache.polygene.api.structure.Module; import org.apache.polygene.api.value.ValueComposite; @@ -32,6 +30,7 @@ import org.apache.polygene.library.rest.client.spi.NullResponseHandler; import org.apache.polygene.library.rest.client.spi.ResponseHandler; import org.apache.polygene.library.rest.client.spi.ResultHandler; import org.apache.polygene.library.rest.common.Resource; +import org.hamcrest.CoreMatchers; import org.restlet.Client; import org.restlet.Response; import org.restlet.data.MediaType; @@ -42,6 +41,7 @@ import org.restlet.security.User; import static org.apache.polygene.library.rest.client.api.HandlerCommand.query; import static org.apache.polygene.library.rest.client.api.HandlerCommand.refresh; +import static org.hamcrest.MatcherAssert.assertThat; public class RestPrimerDocs { @@ -67,7 +67,7 @@ public class RestPrimerDocs @Override public HandlerCommand handleResult( TestResult result, ContextResourceClient client ) { - Assert.assertThat(result.xyz().get(), CoreMatchers.equalTo("bar")); + assertThat( result.xyz().get(), CoreMatchers.equalTo( "bar" ) ); return null; } } ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java ---------------------------------------------------------------------- diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java index db6db80..5d33b5e 100644 --- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java +++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java @@ -55,14 +55,13 @@ import org.apache.polygene.index.rdf.assembly.RdfMemoryStoreAssembler; import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import org.apache.polygene.test.util.FreePortFinder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.AnyOf.anyOf; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.IsNull.nullValue; public class RestTest extends AbstractPolygeneTest { @@ -73,17 +72,18 @@ public class RestTest extends AbstractPolygeneTest throws AssemblyException { return polygene.newApplicationModel( new ApplicationAssemblerAdapter( - new Assembler[][][] - { - { - { - RestTest.this, - new RestAssembler(), - new RdfMemoryStoreAssembler() - } - } - } ) - {} // subclassing ApplicationAssemblerAdapter + new Assembler[][][] + { + { + { + RestTest.this, + new RestAssembler(), + new RdfMemoryStoreAssembler() + } + } + } ) + { + } // subclassing ApplicationAssemblerAdapter ); } @@ -103,7 +103,7 @@ public class RestTest extends AbstractPolygeneTest } @Override - @Before + @BeforeEach public void setUp() throws Exception { @@ -163,8 +163,8 @@ public class RestTest extends AbstractPolygeneTest try { PersonEntity entity = work.get( PersonEntity.class, StringIdentity.identityOf( "P1" ) ); - assertEquals( "FirstName not changed.", "Jack", entity.firstname().get() ); - assertEquals( "LastName not changed.", "Doe", entity.lastname().get() ); + assertThat( "FirstName not changed.", entity.firstname().get(), equalTo( "Jack" ) ); + assertThat( "LastName not changed.", entity.lastname().get(), equalTo( "Doe" ) ); work.complete(); } finally @@ -191,7 +191,7 @@ public class RestTest extends AbstractPolygeneTest { // expected } - assertNull( "Entity not removed.", entity ); + assertThat( "Entity not removed.", entity, nullValue() ); work.complete(); } finally @@ -227,7 +227,7 @@ public class RestTest extends AbstractPolygeneTest CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet( "http://localhost:" + ADMIN_PORT + "/entity/" + identity + ".rdf" ); method.addHeader( "Accept", "application/rdf+xml" ); - try( CloseableHttpResponse response = client.execute( method ) ) + try (CloseableHttpResponse response = client.execute( method )) { if( response.getStatusLine().getStatusCode() != 200 ) { @@ -248,7 +248,7 @@ public class RestTest extends AbstractPolygeneTest parameters.add( new BasicNameValuePair( entry.getKey(), entry.getValue() ) ); } method.setEntity( new UrlEncodedFormEntity( parameters ) ); - try( CloseableHttpResponse response = client.execute( method ) ) + try (CloseableHttpResponse response = client.execute( method )) { if( response.getStatusLine().getStatusCode() != 205 ) { @@ -262,7 +262,7 @@ public class RestTest extends AbstractPolygeneTest { CloseableHttpClient client = HttpClients.createDefault(); HttpDelete method = new HttpDelete( "http://localhost:" + ADMIN_PORT + "/entity/" + identity ); - try( CloseableHttpResponse response = client.execute( method ) ) + try (CloseableHttpResponse response = client.execute( method )) { if( response.getStatusLine().getStatusCode() != 204 ) { @@ -277,7 +277,7 @@ public class RestTest extends AbstractPolygeneTest CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet( "http://localhost:" + ADMIN_PORT + "/entity.rdf" ); method.addHeader( "Accept", "application/rdf+xml" ); - try( CloseableHttpResponse response = client.execute( method ) ) + try (CloseableHttpResponse response = client.execute( method )) { if( response.getStatusLine().getStatusCode() != 200 ) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6ae17138/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/FormField.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/FormField.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/FormField.java deleted file mode 100644 index 5bbe2a5..0000000 --- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/FormField.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.polygene.library.restlet; - -import java.util.Map; -import java.util.Objects; -import org.apache.polygene.api.common.Optional; -import org.apache.polygene.api.common.UseDefaults; -import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.property.Property; - -@Mixins( FormField.Mixin.class ) -public interface FormField extends HasName -{ - String TEXT = "TEXT"; - - Property<String> type(); - - @Optional - @UseDefaults - Property<String> value(); - - Map.Entry<String,String> toMapEntry(); - - abstract class Mixin - implements FormField - { - @Override - public Map.Entry<String, String> toMapEntry() - { - return new StringMapEntry( name().get(), value().get() ); - } - } - - class StringMapEntry implements Map.Entry<String, String> - { - private final String key; - private final String value; - - public StringMapEntry( String key, String value ) - { - this.key = key; - this.value = value; - } - - @Override - public String getKey() - { - return key; - } - - @Override - public String getValue() - { - return value; - } - - @Override - public String setValue( String value ) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean equals( Object o ) - { - if( this == o ) - { - return true; - } - if( !( o instanceof StringMapEntry ) ) - { - return false; - } - StringMapEntry miniMap = (StringMapEntry) o; - return Objects.equals( key, miniMap.key ) && - Objects.equals( value, miniMap.value ); - } - - @Override - public int hashCode() - { - return Objects.hash( key, value ); - } - } - -}