diff --git a/dropwizard-jaxws-example/pom.xml b/dropwizard-jaxws-example/pom.xml index ab2133a..4a69109 100644 --- a/dropwizard-jaxws-example/pom.xml +++ b/dropwizard-jaxws-example/pom.xml @@ -12,6 +12,12 @@ dropwizard-jaxws-example Dropwizard JAX-WS Example Application + + 2.2.224 + + 3.5.1 + + @@ -59,13 +65,12 @@ com.h2database h2 - 2.2.224 + ${h2.version} jakarta.mail jakarta.mail-api - 2.1.2 @@ -109,7 +114,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.1 + ${maven-shade-plugin.version} false diff --git a/dropwizard-jaxws/pom.xml b/dropwizard-jaxws/pom.xml index 0c2f140..c7b2a82 100644 --- a/dropwizard-jaxws/pom.xml +++ b/dropwizard-jaxws/pom.xml @@ -69,7 +69,6 @@ jakarta.mail jakarta.mail-api - 2.1.2 test diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ClientBuilderTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ClientBuilderTest.java index a143518..401e52a 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ClientBuilderTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ClientBuilderTest.java @@ -5,9 +5,7 @@ import jakarta.xml.ws.handler.Handler; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; class ClientBuilderTest { @@ -32,14 +30,14 @@ void buildClient() { .cxfOutInterceptors(outInterceptor, outInterceptor) .cxfOutFaultInterceptors(outFaultInterceptor, outFaultInterceptor); - assertThat(builder.getAddress(), equalTo("address")); - assertThat(builder.getServiceClass(), equalTo(Object.class)); - assertThat(builder.getConnectTimeout(), equalTo(1234)); - assertThat(builder.getReceiveTimeout(), equalTo(5678)); - assertThat(builder.getBindingId(), equalTo("binding id")); - assertThat(builder.getCxfInInterceptors(), contains(new Interceptor[]{ inInterceptor, inInterceptor })); - assertThat(builder.getCxfInFaultInterceptors(), contains(new Interceptor[]{ inFaultInterceptor, inFaultInterceptor })); - assertThat(builder.getCxfOutInterceptors(), contains(new Interceptor[]{ outInterceptor, outInterceptor })); - assertThat(builder.getCxfOutFaultInterceptors(), contains(new Interceptor[]{ outFaultInterceptor, outFaultInterceptor })); + assertThat(builder.getAddress()).isEqualTo("address"); + assertThat(builder.getServiceClass()).isEqualTo(Object.class); + assertThat(builder.getConnectTimeout()).isEqualTo(1234); + assertThat(builder.getReceiveTimeout()).isEqualTo(5678); + assertThat(builder.getBindingId()).isEqualTo("binding id"); + assertThat(builder.getCxfInInterceptors()).contains(new Interceptor[]{ inInterceptor, inInterceptor }); + assertThat(builder.getCxfInFaultInterceptors()).contains(new Interceptor[]{ inFaultInterceptor, inFaultInterceptor }); + assertThat(builder.getCxfOutInterceptors()).contains(new Interceptor[]{ outInterceptor, outInterceptor }); + assertThat(builder.getCxfOutFaultInterceptors()).contains(new Interceptor[]{ outFaultInterceptor, outFaultInterceptor }); } } diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/EndpointBuilderTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/EndpointBuilderTest.java index 3361231..2e72b0a 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/EndpointBuilderTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/EndpointBuilderTest.java @@ -8,9 +8,7 @@ import java.util.Map; import static org.mockito.Mockito.mock; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.assertj.core.api.Assertions.assertThat; class EndpointBuilderTest { @@ -38,15 +36,15 @@ void buildEndpoint() { .cxfOutFaultInterceptors(outFaultInterceptor, outFaultInterceptor) .properties(props); - assertThat(builder.getPath(), equalTo(path)); - assertThat(builder.getService(), equalTo(service)); - assertThat(builder.publishedEndpointUrl(), equalTo(publishedUrl)); - assertThat(builder.getAuthentication(), equalTo(basicAuth)); - assertThat(builder.getSessionFactory(), equalTo(sessionFactory)); - assertThat(builder.getCxfInInterceptors(), contains(new Interceptor[]{ inInterceptor, inInterceptor })); - assertThat(builder.getCxfInFaultInterceptors(), contains(new Interceptor[]{ inFaultInterceptor, inFaultInterceptor })); - assertThat(builder.getCxfOutInterceptors(), contains(new Interceptor[]{ outInterceptor, outInterceptor })); - assertThat(builder.getCxfOutFaultInterceptors(), contains(new Interceptor[]{ outFaultInterceptor, outFaultInterceptor })); - assertThat(builder.getProperties().get("key"), equalTo("value")); + assertThat(builder.getPath()).isEqualTo(path); + assertThat(builder.getService()).isEqualTo(service); + assertThat(builder.publishedEndpointUrl()).isEqualTo(publishedUrl); + assertThat(builder.getAuthentication()).isEqualTo(basicAuth); + assertThat(builder.getSessionFactory()).isEqualTo(sessionFactory); + assertThat(builder.getCxfInInterceptors()).contains(new Interceptor[]{ inInterceptor, inInterceptor }); + assertThat(builder.getCxfInFaultInterceptors()).contains(new Interceptor[]{ inFaultInterceptor, inFaultInterceptor }); + assertThat(builder.getCxfOutInterceptors()).contains(new Interceptor[]{ outInterceptor, outInterceptor }); + assertThat(builder.getCxfOutFaultInterceptors()).contains(new Interceptor[]{ outFaultInterceptor, outFaultInterceptor }); + assertThat(builder.getProperties().get("key")).isEqualTo("value"); } } diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/InstrumentedInvokerFactoryTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/InstrumentedInvokerFactoryTest.java index b2f17a9..36469d7 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/InstrumentedInvokerFactoryTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/InstrumentedInvokerFactoryTest.java @@ -14,11 +14,14 @@ import org.junit.jupiter.api.Test; import java.lang.reflect.Method; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.*; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.contains; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + class InstrumentedInvokerFactoryTest { @@ -103,7 +106,7 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p .thenReturn(InstrumentedService.class.getMethod(methodName, parameterTypes)); } catch (Exception e) { - fail("setTargetMethod failed: " + e.getClass().getName() + ": " + e.getMessage()); + fail("setTargetMethod failed", e); } } @@ -139,10 +142,10 @@ void noAnnotation() { this.setTargetMethod(exchange, "foo"); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("fooReturn", result); + assertThat(result).isEqualTo("fooReturn"); - assertThat(timer.getCount(), is(oldtimervalue)); - assertThat(meter.getCount(), is(oldmetervalue)); + assertThat(timer.getCount()).isEqualTo(oldtimervalue); + assertThat(meter.getCount()).isEqualTo(oldmetervalue); } @Test @@ -160,10 +163,10 @@ void meteredAnnotation() { this.setTargetMethod(exchange, "metered"); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("meteredReturn", result); + assertThat(result).isEqualTo("meteredReturn"); - assertThat(timer.getCount(), is(oldtimervalue)); - assertThat(meter.getCount(), is(1 + oldmetervalue)); + assertThat(timer.getCount()).isEqualTo(oldtimervalue); + assertThat(meter.getCount()).isEqualTo(1 + oldmetervalue); } @Test @@ -181,10 +184,10 @@ void timedAnnotation() { this.setTargetMethod(exchange, "timed"); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("timedReturn", result); + assertThat(result).isEqualTo("timedReturn"); - assertThat(timer.getCount(), is(1 + oldtimervalue)); - assertThat(meter.getCount(), is(oldmetervalue)); + assertThat(timer.getCount()).isEqualTo(1 + oldtimervalue); + assertThat(meter.getCount()).isEqualTo(oldmetervalue); } @Test @@ -207,11 +210,11 @@ void exceptionMeteredAnnotation() { this.setTargetMethod(exchange, "exceptionMetered", boolean.class); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("exceptionMeteredReturn", result); + assertThat(result).isEqualTo("exceptionMeteredReturn"); - assertThat(timer.getCount(), is(oldtimervalue)); - assertThat(meter.getCount(), is(oldmetervalue)); - assertThat(exceptionmeter.getCount(), is(oldexceptionmetervalue)); + assertThat(timer.getCount()).isEqualTo(oldtimervalue); + assertThat(meter.getCount()).isEqualTo(oldmetervalue); + assertThat(exceptionmeter.getCount()).isEqualTo(oldexceptionmetervalue); // Invoke InstrumentedResource.exceptionMetered with exception beeing thrown @@ -219,16 +222,15 @@ void exceptionMeteredAnnotation() { try { invoker.invoke(exchange, null); - fail("Exception shall be thrown here"); + fail("Exception should be thrown here"); } catch (Exception e) { - assertThat(e, is(instanceOf(RuntimeException.class))); + assertThat(e).isInstanceOf(RuntimeException.class); } - assertThat(timer.getCount(), is(oldtimervalue)); - assertThat(meter.getCount(), is(oldmetervalue)); - assertThat(exceptionmeter.getCount(), is(1 + oldexceptionmetervalue)); - + assertThat(timer.getCount()).isEqualTo(oldtimervalue); + assertThat(meter.getCount()).isEqualTo(oldmetervalue); + assertThat(exceptionmeter.getCount()).isEqualTo(1 + oldexceptionmetervalue); } } diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSBundleTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSBundleTest.java index 6eb5c6e..c8d7906 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSBundleTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSBundleTest.java @@ -13,11 +13,15 @@ import jakarta.servlet.ServletRegistration; import jakarta.servlet.http.HttpServlet; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.startsWith; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; class JAXWSBundleTest { @@ -42,18 +46,18 @@ void setUp() { void constructorArgumentChecks() { try { new JAXWSBundle<>(null, null); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { new JAXWSBundle<>("soap", null); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } } @@ -65,7 +69,7 @@ void initializeAndRun() { jaxwsBundle.run(null, null); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } jaxwsBundle.initialize(bootstrap); @@ -91,7 +95,7 @@ protected String getPublishedEndpointUrlPrefix(Configuration configuration) { jaxwsBundle.run(null, null); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } jaxwsBundle.initialize(bootstrap); @@ -111,26 +115,26 @@ void publishEndpoint() { Object service = new Object(); try { jaxwsBundle.publishEndpoint(new EndpointBuilder("foo", null)); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { jaxwsBundle.publishEndpoint(new EndpointBuilder(null, service)); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { jaxwsBundle.publishEndpoint(new EndpointBuilder(" ", service)); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } EndpointBuilder builder = mock(EndpointBuilder.class); @@ -148,27 +152,27 @@ void getClient() { try { jaxwsBundle.getClient(new ClientBuilder<>(null, null)); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { jaxwsBundle.getClient(new ClientBuilder<>(null, url)); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } try { jaxwsBundle.getClient(new ClientBuilder<>(cls, " ")); - fail(); + fail("expected IllegalArgumentException but no exception thrown"); } catch (Exception e) { - assertThat(e, is(instanceOf(IllegalArgumentException.class))); + assertThat(e).isInstanceOf(IllegalArgumentException.class); } ClientBuilder builder = new ClientBuilder<>(cls, url); diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSEnvironmentTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSEnvironmentTest.java index 60e2e9f..66e4a87 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSEnvironmentTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/JAXWSEnvironmentTest.java @@ -40,12 +40,7 @@ import java.lang.reflect.Proxy; import java.util.HashMap; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.notNullValue; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -132,15 +127,15 @@ void teardown() { @Test void buildServlet() { Object result = jaxwsEnvironment.buildServlet(); - assertThat(result, is(instanceOf(CXFNonSpringServlet.class))); - assertThat(((CXFNonSpringServlet) result).getBus(), is(instanceOf(Bus.class))); + assertThat(result).isInstanceOf(CXFNonSpringServlet.class); + assertThat(((CXFNonSpringServlet) result).getBus()).isInstanceOf(Bus.class); } @Test void publishEndpoint() throws Exception { Endpoint e = jaxwsEnvironment.publishEndpoint(new EndpointBuilder("local://path", service)); - assertThat(e, is(notNullValue())); + assertThat(e).isNotNull(); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); verifyNoInteractions(mockUnitOfWorkInvokerBuilder); @@ -193,7 +188,7 @@ void publishEndpointWithAuthentication() throws Exception { testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); - assertThat(mockBasicAuthInterceptorInvoked, equalTo(1)); + assertThat(mockBasicAuthInterceptorInvoked).isEqualTo(1); } @Test @@ -232,9 +227,9 @@ void publishEndpointWithCxfInterceptors() throws Exception { LocalTransportFactory.TRANSPORT_ID, soapRequest); verify(mockInvoker).invoke(any(Exchange.class), any()); - assertThat(inInterceptor.getInvocationCount(), equalTo(1)); - assertThat(inInterceptor2.getInvocationCount(), equalTo(1)); - assertThat(outInterceptor.getInvocationCount(), equalTo(1)); + assertThat(inInterceptor.getInvocationCount()).isEqualTo(1); + assertThat(inInterceptor2.getInvocationCount()).isEqualTo(1); + assertThat(outInterceptor.getInvocationCount()).isEqualTo(1); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); @@ -242,9 +237,9 @@ void publishEndpointWithCxfInterceptors() throws Exception { LocalTransportFactory.TRANSPORT_ID, soapRequest); verify(mockInvoker, times(2)).invoke(any(Exchange.class), any()); - assertThat(inInterceptor.getInvocationCount(), equalTo(2)); - assertThat(inInterceptor2.getInvocationCount(), equalTo(2)); - assertThat(outInterceptor.getInvocationCount(), equalTo(2)); + assertThat(inInterceptor.getInvocationCount()).isEqualTo(2); + assertThat(inInterceptor2.getInvocationCount()).isEqualTo(2); + assertThat(outInterceptor.getInvocationCount()).isEqualTo(2); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); } @@ -265,7 +260,7 @@ void publishEndpointWithMtom() throws Exception { MimeMultipart mimeMultipart = new MimeMultipart(new ByteArrayDataSource(response, "application/xop+xml; charset=UTF-8; type=\"text/xml\"")); - assertThat(mimeMultipart.getCount(), equalTo(1)); + assertThat(mimeMultipart.getCount()).isEqualTo(1); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", StaxUtils.read(mimeMultipart.getBodyPart(0).getInputStream())); } @@ -285,7 +280,7 @@ void publishEndpointWithCustomPublishedUrl() throws Exception { AbstractDestination destination = (AbstractDestination) server.getDestination(); String publishedEndpointUrl = destination.getEndpointInfo().getProperty(WSDLGetUtils.PUBLISHED_ENDPOINT_URL, String.class); - assertThat(publishedEndpointUrl, equalTo("http://external.server/external/path")); + assertThat(publishedEndpointUrl).isEqualTo("http://external.server/external/path"); } @Test @@ -298,8 +293,8 @@ void publishEndpointWithProperties() throws Exception { new EndpointBuilder("local://path", service) .properties(props)); - assertThat(e, is(notNullValue())); - assertThat(e.getProperties().get("key"), equalTo("value")); + assertThat(e).isNotNull(); + assertThat(e.getProperties().get("key")).isEqualTo("value"); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); verifyNoInteractions(mockUnitOfWorkInvokerBuilder); @@ -328,7 +323,7 @@ void publishEndpointWithPublishedUrlPrefix() throws WSDLException { AbstractDestination destination = (AbstractDestination) server.getDestination(); String publishedEndpointUrl = destination.getEndpointInfo().getProperty(WSDLGetUtils.PUBLISHED_ENDPOINT_URL, String.class); - assertThat(publishedEndpointUrl, equalTo("http://external/prefix/path")); + assertThat(publishedEndpointUrl).isEqualTo("http://external/prefix/path"); } @Test @@ -363,16 +358,16 @@ void getClient() { DummyInterface clientProxy = jaxwsEnvironment.getClient( new ClientBuilder<>(DummyInterface.class, address) ); - assertThat(clientProxy, is(instanceOf(Proxy.class))); + assertThat(clientProxy).isInstanceOf(Proxy.class); Client c = ClientProxy.getClient(clientProxy); - assertThat(c.getEndpoint().getEndpointInfo().getAddress(), equalTo(address)); - assertThat(c.getEndpoint().getService().get("endpoint.class").equals(DummyInterface.class), equalTo(true)); - assertThat(((BindingProvider)clientProxy).getBinding() .getHandlerChain().size(), equalTo(0)); + assertThat(c.getEndpoint().getEndpointInfo().getAddress()).isEqualTo(address); + assertThat(c.getEndpoint().getService().get("endpoint.class").equals(DummyInterface.class)).isEqualTo(true); + assertThat(((BindingProvider)clientProxy).getBinding() .getHandlerChain().size()).isEqualTo(0); HTTPClientPolicy httpclient = ((HTTPConduit)c.getConduit()).getClient(); - assertThat(httpclient.getConnectionTimeout(), equalTo(500L)); - assertThat(httpclient.getReceiveTimeout(), equalTo(2000L)); + assertThat(httpclient.getConnectionTimeout()).isEqualTo(500L); + assertThat(httpclient.getReceiveTimeout()).isEqualTo(2000L); // with timeouts, handlers, interceptors, properties and MTOM @@ -390,18 +385,18 @@ void getClient() { .cxfOutInterceptors(outInterceptor) .enableMtom()); c = ClientProxy.getClient(clientProxy); - assertThat(((BindingProvider) clientProxy).getBinding().getBindingID(), equalTo("http://www.w3.org/2003/05/soap/bindings/HTTP/")); - assertThat(c.getEndpoint().getEndpointInfo().getAddress(), equalTo(address)); - assertThat(c.getEndpoint().getService().get("endpoint.class").equals(DummyInterface.class), equalTo(true)); + assertThat(((BindingProvider) clientProxy).getBinding().getBindingID()).isEqualTo("http://www.w3.org/2003/05/soap/bindings/HTTP/"); + assertThat(c.getEndpoint().getEndpointInfo().getAddress()).isEqualTo(address); + assertThat(c.getEndpoint().getService().get("endpoint.class").equals(DummyInterface.class)).isEqualTo(true); httpclient = ((HTTPConduit)c.getConduit()).getClient(); - assertThat(httpclient.getConnectionTimeout(), equalTo(123L)); - assertThat(httpclient.getReceiveTimeout(), equalTo(456L)); + assertThat(httpclient.getConnectionTimeout()).isEqualTo(123L); + assertThat(httpclient.getReceiveTimeout()).isEqualTo(456L); - assertThat(((BindingProvider)clientProxy).getBinding().getHandlerChain(), contains(handler)); + assertThat(((BindingProvider)clientProxy).getBinding().getHandlerChain()).contains(handler); BindingProvider bp = (BindingProvider)clientProxy; SOAPBinding binding = (SOAPBinding)bp.getBinding(); - assertThat(binding.isMTOMEnabled(), equalTo(true)); + assertThat(binding.isMTOMEnabled()).isEqualTo(true); } } diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/UnitOfWorkInvokerFactoryTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/UnitOfWorkInvokerFactoryTest.java index 8ead528..e7aeeac 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/UnitOfWorkInvokerFactoryTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/UnitOfWorkInvokerFactoryTest.java @@ -14,8 +14,8 @@ import java.lang.reflect.Method; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -94,7 +94,7 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p .thenReturn(FooService.class.getMethod(methodName, parameterTypes)); } catch (Exception e) { - fail("setTargetMethod failed: " + e.getClass().getName() + ": " + e.getMessage()); + fail("setTargetMethod failed", e); } } @@ -104,7 +104,7 @@ void noAnnotation() { this.setTargetMethod(exchange, "foo"); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("foo return", result); + assertThat(result).isEqualTo("foo return"); verifyNoInteractions(sessionFactory); verifyNoInteractions(session); @@ -118,7 +118,7 @@ void unitOfWorkAnnotation() { this.setTargetMethod(exchange, "unitOfWork", boolean.class); // simulate CXF behavior Object result = invoker.invoke(exchange, null); - assertEquals("unitOfWork return", result); + assertThat(result).isEqualTo("unitOfWork return"); verify(session, times(1)).beginTransaction(); verify(transaction, times(1)).commit(); @@ -136,7 +136,7 @@ void unitOfWorkWithException() { invoker.invoke(exchange, null); } catch (Exception e) { - assertEquals("Uh oh", e.getMessage()); + assertThat(e.getMessage()).isEqualTo("Uh oh"); } verify(session, times(1)).beginTransaction(); diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ValidatingInvokerTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ValidatingInvokerTest.java index 5b22435..497914b 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ValidatingInvokerTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/ValidatingInvokerTest.java @@ -21,11 +21,12 @@ import java.util.Arrays; import java.util.List; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; class ValidatingInvokerTest { @@ -100,7 +101,7 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p .thenReturn(DummyService.class.getMethod(methodName, parameterTypes)); } catch (Exception e) { - fail("setTargetMethod failed: " + e.getClass().getName() + ": " + e.getMessage()); + fail("setTargetMethod failed", e); } } @@ -156,28 +157,28 @@ void invokeWithValidation() { try { invoker.invoke(exchange, params); - fail(); + fail("expected ValidationException but no exception thrown"); } catch(Exception e) { - assertThat(e, is(instanceOf(ValidationException.class))); + assertThat(e).isInstanceOf(ValidationException.class); } params = Arrays.asList(new RootParam1(new ChildParam("")), new RootParam2("ok")); try { invoker.invoke(exchange, params); - fail(); + fail("expected ValidationException but no exception thrown"); } catch(Exception e) { - assertThat(e, is(instanceOf(ValidationException.class))); + assertThat(e).isInstanceOf(ValidationException.class); } params = Arrays.asList(new RootParam1(new ChildParam("John")), new RootParam2("ok")); try { invoker.invoke(exchange, params); - fail(); + fail("expected ValidationException but no exception thrown"); } catch(Exception e) { - assertThat(e, is(instanceOf(ValidationException.class))); + assertThat(e).isInstanceOf(ValidationException.class); } verifyNoMoreInteractions(underlying); diff --git a/pom.xml b/pom.xml index 4716ba2..1cce1d2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,14 +21,26 @@ + 17 + UTF-8 UTF-8 4.0.3 4.0.3 + 2.1.2 + + 3.24.2 5.10.1 + 5.7.0 + 3.11.0 3.4.1 + 3.1.0 + 3.3.0 + 3.6.0 + 3.3.0 + 2.16.1 @@ -81,7 +93,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + ${maven-gpg-plugin.version} sign-artifacts @@ -96,7 +108,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + ${maven-source-plugin.version} attach-sources @@ -110,7 +122,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + ${maven-javadoc-plugin.version} true -Xdoclint:none @@ -150,11 +162,24 @@ import + + jakarta.mail + jakarta.mail-api + ${jakarta.mail-api.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + org.junit.jupiter junit-jupiter @@ -164,14 +189,7 @@ org.mockito mockito-core - 5.7.0 - test - - - - org.hamcrest - hamcrest - 2.2 + ${mockito.version} test @@ -183,9 +201,9 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + ${maven-compiler-plugin.version} - 17 + ${java.version} UTF-8 @@ -193,7 +211,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + ${maven-jar-plugin.version} @@ -206,7 +224,7 @@ org.codehaus.mojo versions-maven-plugin - 2.16.1 + ${versions-maven-plugin.version}