From 3f28890c11ecc3b9383dc5d7c015633ba679a990 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:52:48 -0500 Subject: [PATCH] Rename internal fields, vars, etc. so they don't include "jaxws" (#78) Rename fields, local vars, parameters, etc. so they don't include "jaxws" in them. For now, I have chosen to use "jws" to stand for Jakarta XML Web Services, which I think is easier to read than "jxws", e.g. jwsEnvironment Fix issue in README that referred tot eh old "jaxws" directory in the section on building an uber JAR. Also, rename dropwizard-jaxws-changelog.md to legacy-dropwizard-jaxws-changelog.md, mainly so that it is more clear that it is a historical artifact. Closes #77 --- README.md | 4 +- .../jakarta/xml/ws/JAXWSBundle.java | 26 ++++---- .../jakarta/xml/ws/JAXWSBundleTest.java | 66 +++++++++---------- .../jakarta/xml/ws/JAXWSEnvironmentTest.java | 36 +++++----- ...md => legacy-dropwizard-jaxws-changelog.md | 0 5 files changed, 66 insertions(+), 66 deletions(-) rename dropwizard-jaxws-changelog.md => legacy-dropwizard-jaxws-changelog.md (100%) diff --git a/README.md b/README.md index 7917dc2..055d444 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ configuration: ``` -For example on building fat jar, see `dropwizard-jaxws-example/pom.xml`. +For example on building fat jar, see `dropwizard-jakarta-xml-ws-example/pom.xml`. When using Gradle and a recent version of [shadowJar](https://github.com/johnrengelman/shadow) use the following snippet: @@ -230,6 +230,6 @@ Changelog The original repository listed its complete change log at the end of this README. -We have moved it [here](dropwizard-jaxws-changelog.md) for historical purposes. +We have moved it [here](legacy-dropwizard-jaxws-changelog.md) for historical purposes. Releases in this repository use [GitHub releases](https://github.com/kiwiproject/dropwizard-jakarta-xml-ws/releases). diff --git a/dropwizard-jakarta-xml-ws/src/main/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundle.java b/dropwizard-jakarta-xml-ws/src/main/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundle.java index e4378a0..f3c8ce5 100644 --- a/dropwizard-jakarta-xml-ws/src/main/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundle.java +++ b/dropwizard-jakarta-xml-ws/src/main/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundle.java @@ -15,7 +15,7 @@ public class JAXWSBundle implements ConfiguredBundle { protected static final String DEFAULT_PATH = "/soap"; - protected final JAXWSEnvironment jaxwsEnvironment; + protected final JAXWSEnvironment jwsEnvironment; protected final String servletPath; /** @@ -38,35 +38,35 @@ public JAXWSBundle(String servletPath) { * Create a new bundle instance using the provided JAXWSEnvironment. Service endpoints are * published relative to the provided servletPath. * - * @param servletPath Root path for service endpoints. Leading slash is required. - * @param jaxwsEnvironment Valid JAXWSEnvironment. + * @param servletPath Root path for service endpoints. Leading slash is required. + * @param jwsEnvironment Valid JAXWSEnvironment. */ - public JAXWSBundle(String servletPath, JAXWSEnvironment jaxwsEnvironment) { + public JAXWSBundle(String servletPath, JAXWSEnvironment jwsEnvironment) { checkArgument(servletPath != null, "Servlet path is null"); checkArgument(servletPath.startsWith("/"), "%s is not an absolute path", servletPath); - checkArgument(jaxwsEnvironment != null, "jaxwsEnvironment is null"); + checkArgument(jwsEnvironment != null, "jwsEnvironment is null"); this.servletPath = servletPath.endsWith("/") ? servletPath + "*" : servletPath + "/*"; - this.jaxwsEnvironment = jaxwsEnvironment; + this.jwsEnvironment = jwsEnvironment; } @Override public void initialize(Bootstrap bootstrap) { - this.jaxwsEnvironment.setInstrumentedInvokerBuilder( + this.jwsEnvironment.setInstrumentedInvokerBuilder( new InstrumentedInvokerFactory(bootstrap.getMetricRegistry())); } @Override public void run(C configuration, Environment environment) { checkArgument(environment != null, "Environment is null"); - environment.servlets().addServlet("CXF Servlet " + jaxwsEnvironment.getDefaultPath(), - jaxwsEnvironment.buildServlet()).addMapping(servletPath); + environment.servlets().addServlet("CXF Servlet " + jwsEnvironment.getDefaultPath(), + jwsEnvironment.buildServlet()).addMapping(servletPath); environment.lifecycle().addServerLifecycleListener( - server -> jaxwsEnvironment.logEndpoints()); + server -> jwsEnvironment.logEndpoints()); String publishedEndpointUrlPrefix = getPublishedEndpointUrlPrefix(configuration); if (publishedEndpointUrlPrefix != null) { - jaxwsEnvironment.setPublishedEndpointUrlPrefix(publishedEndpointUrlPrefix); + jwsEnvironment.setPublishedEndpointUrlPrefix(publishedEndpointUrlPrefix); } } @@ -78,7 +78,7 @@ public void run(C configuration, Environment environment) { */ public EndpointImpl publishEndpoint(EndpointBuilder endpointBuilder) { checkArgument(endpointBuilder != null, "EndpointBuilder is null"); - return this.jaxwsEnvironment.publishEndpoint(endpointBuilder); + return this.jwsEnvironment.publishEndpoint(endpointBuilder); } /** @@ -90,7 +90,7 @@ public EndpointImpl publishEndpoint(EndpointBuilder endpointBuilder) { */ public T getClient(ClientBuilder clientBuilder) { checkArgument(clientBuilder != null, "ClientBuilder is null"); - return jaxwsEnvironment.getClient(clientBuilder); + return jwsEnvironment.getClient(clientBuilder); } /** diff --git a/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundleTest.java b/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundleTest.java index c57ce95..c964ef4 100644 --- a/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundleTest.java +++ b/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSBundleTest.java @@ -29,7 +29,7 @@ class JAXWSBundleTest { Bootstrap bootstrap; ServletEnvironment servletEnvironment; ServletRegistration.Dynamic servlet; - JAXWSEnvironment jaxwsEnvironment; + JAXWSEnvironment jwsEnvironment; LifecycleEnvironment lifecycleEnvironment; @BeforeEach @@ -38,56 +38,56 @@ void setUp() { bootstrap = mock(Bootstrap.class); servletEnvironment = mock(ServletEnvironment.class); servlet = mock(ServletRegistration.Dynamic.class); - jaxwsEnvironment = mock(JAXWSEnvironment.class); + jwsEnvironment = mock(JAXWSEnvironment.class); lifecycleEnvironment = mock(LifecycleEnvironment.class); when(environment.servlets()).thenReturn(servletEnvironment); when(environment.lifecycle()).thenReturn(lifecycleEnvironment); when(bootstrap.getMetricRegistry()).thenReturn(mock(MetricRegistry.class)); when(servletEnvironment.addServlet(anyString(), any(HttpServlet.class))).thenReturn(servlet); - when(jaxwsEnvironment.buildServlet()).thenReturn(mock(HttpServlet.class)); - when(jaxwsEnvironment.getDefaultPath()).thenReturn("/soap"); + when(jwsEnvironment.buildServlet()).thenReturn(mock(HttpServlet.class)); + when(jwsEnvironment.getDefaultPath()).thenReturn("/soap"); } @Test void constructorArgumentChecks() { assertThatIllegalArgumentException() - .isThrownBy(() -> new JAXWSBundle<>(null, jaxwsEnvironment)) + .isThrownBy(() -> new JAXWSBundle<>(null, jwsEnvironment)) .withMessage("Servlet path is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> new JAXWSBundle<>("soap", jaxwsEnvironment)) + .isThrownBy(() -> new JAXWSBundle<>("soap", jwsEnvironment)) .withMessage("soap is not an absolute path"); assertThatIllegalArgumentException() .isThrownBy(() -> new JAXWSBundle<>("/soap", null)) - .withMessage("jaxwsEnvironment is null"); + .withMessage("jwsEnvironment is null"); - assertThatCode(() -> new JAXWSBundle<>("/soap", jaxwsEnvironment)) + assertThatCode(() -> new JAXWSBundle<>("/soap", jwsEnvironment)) .doesNotThrowAnyException(); } @Test void initializeAndRun() { - JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); + JAXWSBundle jwsBundle = new JAXWSBundle<>("/soap", jwsEnvironment); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.run(null, null)) + .isThrownBy(() -> jwsBundle.run(null, null)) .withMessage("Environment is null"); - jaxwsBundle.initialize(bootstrap); - verify(jaxwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class)); + jwsBundle.initialize(bootstrap); + verify(jwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class)); - jaxwsBundle.run(null, environment); + jwsBundle.run(null, environment); verify(servletEnvironment).addServlet(startsWith("CXF Servlet"), any(Servlet.class)); verify(lifecycleEnvironment).addServerLifecycleListener(any(ServerLifecycleListener.class)); verify(servlet).addMapping("/soap/*"); - verify(jaxwsEnvironment, never()).setPublishedEndpointUrlPrefix(anyString()); + verify(jwsEnvironment, never()).setPublishedEndpointUrlPrefix(anyString()); } @Test void initializeAndRunWithPublishedEndpointUrlPrefix() { - JAXWSBundle jaxwsBundle = new JAXWSBundle("/soap", jaxwsEnvironment) { + JAXWSBundle jwsBundle = new JAXWSBundle("/soap", jwsEnvironment) { @Override protected String getPublishedEndpointUrlPrefix(Configuration configuration) { return "http://some/prefix"; @@ -95,67 +95,67 @@ protected String getPublishedEndpointUrlPrefix(Configuration configuration) { }; assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.run(null, null)) + .isThrownBy(() -> jwsBundle.run(null, null)) .withMessage("Environment is null"); - jaxwsBundle.initialize(bootstrap); - verify(jaxwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class)); + jwsBundle.initialize(bootstrap); + verify(jwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class)); - jaxwsBundle.run(null, environment); + jwsBundle.run(null, environment); verify(servletEnvironment).addServlet(startsWith("CXF Servlet"), any(Servlet.class)); verify(lifecycleEnvironment).addServerLifecycleListener(any(ServerLifecycleListener.class)); verify(servlet).addMapping("/soap/*"); - verify(jaxwsEnvironment).setPublishedEndpointUrlPrefix("http://some/prefix"); + verify(jwsEnvironment).setPublishedEndpointUrlPrefix("http://some/prefix"); } @Test void publishEndpoint() { - JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); + JAXWSBundle jwsBundle = new JAXWSBundle<>("/soap", jwsEnvironment); Object service = new Object(); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.publishEndpoint(new EndpointBuilder("foo", null))) + .isThrownBy(() -> jwsBundle.publishEndpoint(new EndpointBuilder("foo", null))) .withMessage("Service is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.publishEndpoint(new EndpointBuilder(null, service))) + .isThrownBy(() -> jwsBundle.publishEndpoint(new EndpointBuilder(null, service))) .withMessage("Path is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.publishEndpoint(new EndpointBuilder(" ", service))) + .isThrownBy(() -> jwsBundle.publishEndpoint(new EndpointBuilder(" ", service))) .withMessage("Path is empty"); EndpointBuilder builder = mock(EndpointBuilder.class); - jaxwsBundle.publishEndpoint(builder); - verify(jaxwsEnvironment).publishEndpoint(builder); + jwsBundle.publishEndpoint(builder); + verify(jwsEnvironment).publishEndpoint(builder); } @Test void getClient() { - JAXWSBundle jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); + JAXWSBundle jwsBundle = new JAXWSBundle<>("/soap", jwsEnvironment); Class cls = Object.class; String url = "http://foo"; assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.getClient(new ClientBuilder<>(null, null))) + .isThrownBy(() -> jwsBundle.getClient(new ClientBuilder<>(null, null))) .withMessage("ServiceClass is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.getClient(new ClientBuilder<>(null, url))) + .isThrownBy(() -> jwsBundle.getClient(new ClientBuilder<>(null, url))) .withMessage("ServiceClass is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.getClient(new ClientBuilder<>(cls, null))) + .isThrownBy(() -> jwsBundle.getClient(new ClientBuilder<>(cls, null))) .withMessage("Address is null"); assertThatIllegalArgumentException() - .isThrownBy(() -> jaxwsBundle.getClient(new ClientBuilder<>(cls, " "))) + .isThrownBy(() -> jwsBundle.getClient(new ClientBuilder<>(cls, " "))) .withMessage("Address is empty"); ClientBuilder builder = new ClientBuilder<>(cls, url); - jaxwsBundle.getClient(builder); - verify(jaxwsEnvironment).getClient(builder); + jwsBundle.getClient(builder); + verify(jwsEnvironment).getClient(builder); } } diff --git a/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSEnvironmentTest.java b/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSEnvironmentTest.java index baf4b04..7673841 100644 --- a/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSEnvironmentTest.java +++ b/dropwizard-jakarta-xml-ws/src/test/java/org/kiwiproject/dropwizard/jakarta/xml/ws/JAXWSEnvironmentTest.java @@ -52,7 +52,7 @@ class JAXWSEnvironmentTest { private static final String SOAP_REQUEST_FILE_NAME = "test-soap-request.xml"; - private JAXWSEnvironment jaxwsEnvironment; + private JAXWSEnvironment jwsEnvironment; private Invoker mockInvoker; private TestUtilities testutils; private DummyService service; @@ -98,7 +98,7 @@ void setup() { mockInvokerBuilder = mock(InstrumentedInvokerFactory.class); mockUnitOfWorkInvokerBuilder = mock(UnitOfWorkInvokerFactory.class); - jaxwsEnvironment = new JAXWSEnvironment("soap") { + jwsEnvironment = new JAXWSEnvironment("soap") { /* We create BasicAuthenticationInterceptor mock manually, because Mockito provided mock does not get invoked by CXF @@ -115,28 +115,28 @@ public void handleMessage(Message message) throws Fault { }; when(mockInvokerBuilder.create(any(), any(Invoker.class))).thenReturn(mockInvoker); - jaxwsEnvironment.setInstrumentedInvokerBuilder(mockInvokerBuilder); + jwsEnvironment.setInstrumentedInvokerBuilder(mockInvokerBuilder); when(mockUnitOfWorkInvokerBuilder .create(any(), any(Invoker.class), any(SessionFactory.class))) .thenReturn(mockInvoker); - jaxwsEnvironment.setUnitOfWorkInvokerBuilder(mockUnitOfWorkInvokerBuilder); + jwsEnvironment.setUnitOfWorkInvokerBuilder(mockUnitOfWorkInvokerBuilder); mockBasicAuthInterceptorInvoked = 0; - testutils.setBus(jaxwsEnvironment.bus); + testutils.setBus(jwsEnvironment.bus); testutils.addNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"); testutils.addNamespace("a", "http://ws.xml.jakarta.dropwizard.kiwiproject.org/"); } @AfterEach void teardown() { - jaxwsEnvironment.bus.shutdown(false); + jwsEnvironment.bus.shutdown(false); } @Test void buildServlet() { - Object result = jaxwsEnvironment.buildServlet(); + Object result = jwsEnvironment.buildServlet(); assertThat(result).isInstanceOf(CXFNonSpringServlet.class); assertThat(((CXFNonSpringServlet) result).getBus()).isInstanceOf(Bus.class); } @@ -144,7 +144,7 @@ void buildServlet() { @Test void publishEndpoint() throws Exception { - Endpoint e = jaxwsEnvironment.publishEndpoint(new EndpointBuilder("local://path", service)); + Endpoint e = jwsEnvironment.publishEndpoint(new EndpointBuilder("local://path", service)); assertThat(e).isNotNull(); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); @@ -184,7 +184,7 @@ void publishEndpointWithAnotherEnvironment() throws Exception { @Test void publishEndpointWithAuthentication() throws Exception { - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .authentication(mock(BasicAuthentication.class))); @@ -204,7 +204,7 @@ void publishEndpointWithAuthentication() throws Exception { @Test void publishEndpointWithHibernateInvoker() throws Exception { - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .sessionFactory(mock(SessionFactory.class))); @@ -226,7 +226,7 @@ void publishEndpointWithCxfInterceptors() throws Exception { TestInterceptor inInterceptor2 = new TestInterceptor(Phase.PRE_INVOKE); TestInterceptor outInterceptor = new TestInterceptor(Phase.MARSHAL); - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .cxfInInterceptors(inInterceptor, inInterceptor2) .cxfOutInterceptors(outInterceptor)); @@ -258,7 +258,7 @@ void publishEndpointWithCxfInterceptors() throws Exception { @Test void publishEndpointWithMtom() throws Exception { - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .enableMtom()); @@ -278,7 +278,7 @@ void publishEndpointWithMtom() throws Exception { @Test void publishEndpointWithCustomPublishedUrl() throws Exception { - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .publishedEndpointUrl("http://external.server/external/path") ); @@ -299,7 +299,7 @@ void publishEndpointWithProperties() throws Exception { HashMap props = new HashMap<>(); props.put("key", "value"); - Endpoint e = jaxwsEnvironment.publishEndpoint( + Endpoint e = jwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .properties(props)); @@ -320,9 +320,9 @@ void publishEndpointWithProperties() throws Exception { @Test void publishEndpointWithPublishedUrlPrefix() throws WSDLException { - jaxwsEnvironment.setPublishedEndpointUrlPrefix("http://external/prefix"); + jwsEnvironment.setPublishedEndpointUrlPrefix("http://external/prefix"); - jaxwsEnvironment.publishEndpoint( + jwsEnvironment.publishEndpoint( new EndpointBuilder("/path", service) ); @@ -359,7 +359,7 @@ void getClient() { var handler = mock(Handler.class); // simple - DummyInterface clientProxy = jaxwsEnvironment.getClient( + DummyInterface clientProxy = jwsEnvironment.getClient( new ClientBuilder<>(DummyInterface.class, address) ); assertThat(clientProxy).isInstanceOf(Proxy.class); @@ -379,7 +379,7 @@ void getClient() { TestInterceptor inInterceptor2 = new TestInterceptor(Phase.PRE_INVOKE); TestInterceptor outInterceptor = new TestInterceptor(Phase.MARSHAL); - clientProxy = jaxwsEnvironment.getClient( + clientProxy = jwsEnvironment.getClient( new ClientBuilder<>(DummyInterface.class, address) .connectTimeout(123) .receiveTimeout(456) diff --git a/dropwizard-jaxws-changelog.md b/legacy-dropwizard-jaxws-changelog.md similarity index 100% rename from dropwizard-jaxws-changelog.md rename to legacy-dropwizard-jaxws-changelog.md