diff --git a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/BasicAuthenticationInterceptorTest.java b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/BasicAuthenticationInterceptorTest.java index 3677cdb..d5a0885 100644 --- a/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/BasicAuthenticationInterceptorTest.java +++ b/dropwizard-jaxws/src/test/java/com/roskart/dropwizard/jaxws/BasicAuthenticationInterceptorTest.java @@ -19,12 +19,12 @@ import org.apache.cxf.message.MessageImpl; import org.apache.cxf.transport.Conduit; import org.apache.cxf.transport.Destination; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -public class BasicAuthenticationInterceptorTest { +class BasicAuthenticationInterceptorTest { @Mock private InterceptorChain interceptorChainMock; @@ -45,15 +45,15 @@ public class BasicAuthenticationInterceptorTest { private static final String CORRECT_PASSWORD = "secret"; private static final String USERNAME = "username"; - @Before - public void setup() throws IOException { + @BeforeEach + void setup() throws IOException { MockitoAnnotations.openMocks(this); when(destinationMock.getBackChannel(any())).thenReturn(conduitMock); when(outMessageMock.getContent(OutputStream.class)).thenReturn(outputStreamMock); } @Test - public void shouldAuthenticateValidUser() { + void shouldAuthenticateValidUser() { BasicAuthenticationInterceptor target = new BasicAuthenticationInterceptor(); target.setAuthenticator(basicAuthentication); Message message = createMessageWithUsernameAndPassword(USERNAME, CORRECT_PASSWORD); @@ -64,7 +64,7 @@ public void shouldAuthenticateValidUser() { } @Test - public void shouldReturnUnathorizedCodeForInvalidCredentials() { + void shouldReturnUnathorizedCodeForInvalidCredentials() { BasicAuthenticationInterceptor target = new BasicAuthenticationInterceptor(); target.setAuthenticator(basicAuthentication); Message message = createMessageWithUsernameAndPassword(USERNAME, "foo"); @@ -75,7 +75,7 @@ public void shouldReturnUnathorizedCodeForInvalidCredentials() { } @Test - public void shouldNotCrashOnNullPassword() { + void shouldNotCrashOnNullPassword() { BasicAuthenticationInterceptor target = new BasicAuthenticationInterceptor(); target.setAuthenticator(basicAuthentication); Message message = createMessageWithUsernameAndPassword(USERNAME, null); @@ -86,7 +86,7 @@ public void shouldNotCrashOnNullPassword() { } @Test - public void shouldNotCrashOnNullUser() { + void shouldNotCrashOnNullUser() { BasicAuthenticationInterceptor target = new BasicAuthenticationInterceptor(); target.setAuthenticator(basicAuthentication); Message message = createMessageWithUsernameAndPassword(null, CORRECT_PASSWORD); 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 8713940..a143518 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 @@ -1,7 +1,7 @@ package com.roskart.dropwizard.jaxws; import org.apache.cxf.interceptor.Interceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.xml.ws.handler.Handler; @@ -10,10 +10,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; -public class ClientBuilderTest { +class ClientBuilderTest { @Test - public void buildClient() { + void buildClient() { Handler handler = mock(Handler.class); 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 848c801..3361231 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 @@ -2,19 +2,20 @@ import org.apache.cxf.interceptor.Interceptor; import org.hibernate.SessionFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; -import static org.mockito.Mockito.*; +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; -public class EndpointBuilderTest { + +class EndpointBuilderTest { @Test - public void buildEndpoint() { + void buildEndpoint() { Object service = new Object(); String path = "/foo"; String publishedUrl = "http://external/url"; 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 a11f31f..b2f17a9 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 @@ -10,18 +10,17 @@ import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.OperationInfo; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.lang.reflect.Method; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +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; -public class InstrumentedInvokerFactoryTest { +class InstrumentedInvokerFactoryTest { // Test service implementation class InstrumentedService { @@ -108,8 +107,8 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p } } - @Before - public void setUp() { + @BeforeEach + void setUp() { exchange = mock(Exchange.class); BindingOperationInfo boi = mock(BindingOperationInfo.class); @@ -126,7 +125,7 @@ public void setUp() { } @Test - public void noAnnotation() { + void noAnnotation() { Timer timer = testMetricRegistry.timer("timed"); Meter meter = testMetricRegistry.meter("metered"); @@ -147,7 +146,7 @@ public void noAnnotation() { } @Test - public void meteredAnnotation() { + void meteredAnnotation() { Timer timer = testMetricRegistry.timer("timed"); Meter meter = testMetricRegistry.meter("metered"); @@ -168,7 +167,7 @@ public void meteredAnnotation() { } @Test - public void timedAnnotation() { + void timedAnnotation() { Timer timer = testMetricRegistry.timer("timed"); Meter meter = testMetricRegistry.meter("metered"); @@ -189,7 +188,7 @@ public void timedAnnotation() { } @Test - public void exceptionMeteredAnnotation() { + void exceptionMeteredAnnotation() { Timer timer = testMetricRegistry.timer("timed"); Meter meter = testMetricRegistry.meter("metered"); 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 a942d7a..6eb5c6e 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 @@ -7,9 +7,8 @@ import io.dropwizard.core.setup.Bootstrap; import io.dropwizard.core.setup.Environment; import io.dropwizard.jetty.setup.ServletEnvironment; -import org.junit.Before; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import jakarta.servlet.Servlet; import jakarta.servlet.ServletRegistration; import jakarta.servlet.http.HttpServlet; @@ -17,10 +16,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.*; -public class JAXWSBundleTest { +class JAXWSBundleTest { Environment environment = mock(Environment.class); Bootstrap bootstrap = mock(Bootstrap.class); @@ -29,8 +28,8 @@ public class JAXWSBundleTest { JAXWSEnvironment jaxwsEnvironment = mock(JAXWSEnvironment.class); LifecycleEnvironment lifecycleEnvironment = mock(LifecycleEnvironment.class); - @Before - public void setUp() { + @BeforeEach + void setUp() { when(environment.servlets()).thenReturn(servletEnvironment); when(environment.lifecycle()).thenReturn(lifecycleEnvironment); when(bootstrap.getMetricRegistry()).thenReturn(mock(MetricRegistry.class)); @@ -40,7 +39,7 @@ public void setUp() { } @Test - public void constructorArgumentChecks() { + void constructorArgumentChecks() { try { new JAXWSBundle<>(null, null); fail(); @@ -59,7 +58,7 @@ public void constructorArgumentChecks() { } @Test - public void initializeAndRun() { + void initializeAndRun() { JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); try { @@ -80,7 +79,7 @@ public void initializeAndRun() { } @Test - public void initializeAndRunWithPublishedEndpointUrlPrefix() { + void initializeAndRunWithPublishedEndpointUrlPrefix() { JAXWSBundle jaxwsBundle = new JAXWSBundle("/soap", jaxwsEnvironment) { @Override protected String getPublishedEndpointUrlPrefix(Configuration configuration) { @@ -106,7 +105,7 @@ protected String getPublishedEndpointUrlPrefix(Configuration configuration) { } @Test - public void publishEndpoint() { + void publishEndpoint() { JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); Object service = new Object(); @@ -140,7 +139,7 @@ public void publishEndpoint() { } @Test - public void getClient() { + void getClient() { JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); 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 26f681e..60e2e9f 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 @@ -21,9 +21,9 @@ import org.apache.cxf.transport.servlet.CXFNonSpringServlet; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.hibernate.SessionFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.LoggerFactory; import org.w3c.dom.Node; @@ -53,7 +53,7 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; -public class JAXWSEnvironmentTest { +class JAXWSEnvironmentTest { private JAXWSEnvironment jaxwsEnvironment; private Invoker mockInvoker = mock(Invoker.class); @@ -88,8 +88,8 @@ public void handleMessage(Message message) throws Fault { } } - @Before - public void setup() { + @BeforeEach + void setup() { ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger("org.apache.cxf")).setLevel(Level.INFO); @@ -124,20 +124,20 @@ public void handleMessage(Message message) throws Fault { testutils.addNamespace("a", "http://jaxws.dropwizard.roskart.com/"); } - @After - public void teardown() { + @AfterEach + void teardown() { jaxwsEnvironment.bus.shutdown(false); } @Test - public void buildServlet() { + void buildServlet() { Object result = jaxwsEnvironment.buildServlet(); assertThat(result, is(instanceOf(CXFNonSpringServlet.class))); assertThat(((CXFNonSpringServlet) result).getBus(), is(instanceOf(Bus.class))); } @Test - public void publishEndpoint() throws Exception { + void publishEndpoint() throws Exception { Endpoint e = jaxwsEnvironment.publishEndpoint(new EndpointBuilder("local://path", service)); assertThat(e, is(notNullValue())); @@ -154,7 +154,7 @@ public void publishEndpoint() throws Exception { } @Test - public void publishEndpointWithAnotherEnvironment() throws Exception { + void publishEndpointWithAnotherEnvironment() throws Exception { // creating new runtime environment simulates using separate bundles JAXWSEnvironment anotherJaxwsEnvironment = new JAXWSEnvironment("soap2"); @@ -177,7 +177,7 @@ public void publishEndpointWithAnotherEnvironment() throws Exception { } @Test - public void publishEndpointWithAuthentication() throws Exception { + void publishEndpointWithAuthentication() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) @@ -197,7 +197,7 @@ public void publishEndpointWithAuthentication() throws Exception { } @Test - public void publishEndpointWithHibernateInvoker() throws Exception { + void publishEndpointWithHibernateInvoker() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) @@ -215,7 +215,7 @@ public void publishEndpointWithHibernateInvoker() throws Exception { } @Test - public void publishEndpointWithCxfInterceptors() throws Exception { + void publishEndpointWithCxfInterceptors() throws Exception { TestInterceptor inInterceptor = new TestInterceptor(Phase.UNMARSHAL); TestInterceptor inInterceptor2 = new TestInterceptor(Phase.PRE_INVOKE); @@ -251,7 +251,7 @@ public void publishEndpointWithCxfInterceptors() throws Exception { @Test - public void publishEndpointWithMtom() throws Exception { + void publishEndpointWithMtom() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) @@ -271,7 +271,7 @@ public void publishEndpointWithMtom() throws Exception { } @Test - public void publishEndpointWithCustomPublishedUrl() throws Exception { + void publishEndpointWithCustomPublishedUrl() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) @@ -289,7 +289,7 @@ public void publishEndpointWithCustomPublishedUrl() throws Exception { } @Test - public void publishEndpointWithProperties() throws Exception { + void publishEndpointWithProperties() throws Exception { HashMap props = new HashMap<>(); props.put("key", "value"); @@ -313,7 +313,7 @@ public void publishEndpointWithProperties() throws Exception { } @Test - public void publishEndpointWithPublishedUrlPrefix() throws WSDLException { + void publishEndpointWithPublishedUrlPrefix() throws WSDLException { jaxwsEnvironment.setPublishedEndpointUrlPrefix("http://external/prefix"); @@ -332,7 +332,7 @@ public void publishEndpointWithPublishedUrlPrefix() throws WSDLException { } @Test - public void publishEndpointWithInvalidArguments() throws Exception { + void publishEndpointWithInvalidArguments() throws Exception { try { jaxwsEnvironment.publishEndpoint(new EndpointBuilder("foo", null)); @@ -354,7 +354,7 @@ public void publishEndpointWithInvalidArguments() throws Exception { } @Test - public void getClient() { + void getClient() { String address = "http://address"; Handler handler = mock(Handler.class); 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 82ce2c2..8ead528 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 @@ -9,20 +9,20 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.resource.transaction.spi.TransactionStatus; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.lang.reflect.Method; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.when;; +import static org.mockito.Mockito.when; -public class UnitOfWorkInvokerFactoryTest { +class UnitOfWorkInvokerFactoryTest { class FooService { public String foo() { @@ -65,8 +65,8 @@ public Object invoke(Exchange exchange, Object o) { // CXF Exchange contains message exchange and is used by Invoker to obtain invoked method name Exchange exchange; - @Before - public void setup() { + @BeforeEach + void setup() { exchange = mock(Exchange.class); BindingOperationInfo boi = mock(BindingOperationInfo.class); when(exchange.getBindingOperationInfo()).thenReturn(boi); @@ -99,7 +99,7 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p } @Test - public void noAnnotation() { + void noAnnotation() { Invoker invoker = invokerBuilder.create(fooService, new FooInvoker(), null); this.setTargetMethod(exchange, "foo"); // simulate CXF behavior @@ -112,7 +112,7 @@ public void noAnnotation() { } @Test - public void unitOfWorkAnnotation() { + void unitOfWorkAnnotation() { // use underlying invoker which invokes fooService.unitOfWork(false) Invoker invoker = invokerBuilder.create(fooService, new UnitOfWorkInvoker(false), sessionFactory); this.setTargetMethod(exchange, "unitOfWork", boolean.class); // simulate CXF behavior @@ -127,7 +127,7 @@ public void unitOfWorkAnnotation() { } @Test - public void unitOfWorkWithException() { + void unitOfWorkWithException() { // use underlying invoker which invokes fooService.unitOfWork(true) - exception is thrown Invoker invoker = invokerBuilder.create(fooService, new UnitOfWorkInvoker(true), sessionFactory); this.setTargetMethod(exchange, "unitOfWork", boolean.class); // simulate CXF behavior 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 0a08e3b..5b22435 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 @@ -8,9 +8,8 @@ import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.OperationInfo; -import org.junit.Before; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import jakarta.validation.Validation; import jakarta.validation.Valid; import jakarta.validation.ValidationException; @@ -25,11 +24,10 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; - -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.*; -public class ValidatingInvokerTest { +class ValidatingInvokerTest { ValidatingInvoker invoker; Invoker underlying; @@ -79,8 +77,8 @@ public void asyncMethodAsync(String foo, AsyncHandler asyncHandler) { } } - @Before - public void setup() { + @BeforeEach + void setup() { underlying = mock(Invoker.class); invoker = new ValidatingInvoker(underlying, Validation.buildDefaultValidatorFactory().getValidator()); exchange = mock(Exchange.class); @@ -107,14 +105,14 @@ private void setTargetMethod(Exchange exchange, String methodName, Class... p } @Test - public void invokeWithoutParams() { + void invokeWithoutParams() { setTargetMethod(exchange, "noParams"); invoker.invoke(exchange, null); verify(underlying).invoke(exchange, null); } @Test - public void invokeWithoutValidation() { + void invokeWithoutValidation() { setTargetMethod(exchange, "noValidation", RootParam1.class, RootParam2.class); List params = Arrays.asList(null, null); @@ -127,7 +125,7 @@ public void invokeWithoutValidation() { } @Test - public void invokeWithAsycHandler() { + void invokeWithAsycHandler() { setTargetMethod(exchange, "asyncMethod", String.class); List params = Arrays.asList(null, new AsyncHandler(){ @@ -150,7 +148,7 @@ public void handleResponse(Response res) { } @Test - public void invokeWithValidation() { + void invokeWithValidation() { setTargetMethod(exchange, "withValidation", RootParam1.class, RootParam2.class); diff --git a/pom.xml b/pom.xml index e458462..4716ba2 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ 4.0.3 4.0.3 + 5.10.1 3.4.1 @@ -141,15 +142,22 @@ pom + + org.junit + junit-bom + ${junit.version} + pom + import + + - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter test