From 9002be8e7a0c12523eb448134f7354b3bb753edb Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 1 Sep 2020 21:30:14 +0200 Subject: [PATCH] s/Websocket/WebSocket/ Java SE as well as OkHttp use 'WebSocket' (not 'Websocket'). Let us do the same. SMACK-835. --- .../org.jivesoftware.smack/smack-config.xml | 2 +- .../smack/inttest/XmppConnectionManager.java | 4 +- .../src/test/resources/state-graph.dot | 4 +- ...nnection.java => WebSocketConnection.java} | 8 +- ...ttpWebsocket.java => OkHttpWebSocket.java} | 42 +++--- ...ctory.java => OkHttpWebSocketFactory.java} | 10 +- ...ware.smack.websocket.impl.WebSocketFactory | 1 + ...ware.smack.websocket.impl.WebsocketFactory | 1 - ...=> OkHttpWebSocketFactoryServiceTest.java} | 8 +- ...a => WebSocketConnectionAttemptState.java} | 44 +++---- ...Exception.java => WebSocketException.java} | 6 +- ...ializer.java => WebSocketInitializer.java} | 4 +- ...java => XmppWebSocketTransportModule.java} | 122 +++++++++--------- ...ppWebSocketTransportModuleDescriptor.java} | 54 ++++---- ...Nonza.java => AbstractWebSocketNonza.java} | 4 +- ...lement.java => WebSocketCloseElement.java} | 4 +- ...Element.java => WebSocketOpenElement.java} | 4 +- ...tWebsocket.java => AbstractWebSocket.java} | 8 +- ...cketFactory.java => WebSocketFactory.java} | 4 +- ...vice.java => WebSocketFactoryService.java} | 10 +- .../smack/websocket/package-info.java | 2 +- ...=> WebSocketRemoteConnectionEndpoint.java} | 8 +- ...SocketRemoteConnectionEndpointLookup.java} | 24 ++-- ... WebSocketConnectionAttemptStateTest.java} | 4 +- ...est.java => WebSocketInitializerTest.java} | 4 +- ... => XmppWebSocketTransportModuleTest.java} | 62 ++++----- ...entTest.java => WebSocketElementTest.java} | 8 +- ...etTest.java => AbstractWebSocketTest.java} | 12 +- ...ebSocketRemoteConnectionEndpointTest.java} | 8 +- ...a => WebSocketFactoryServiceTestUtil.java} | 10 +- 30 files changed, 243 insertions(+), 243 deletions(-) rename smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/{WebsocketConnection.java => WebSocketConnection.java} (87%) rename smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/{OkHttpWebsocket.java => OkHttpWebSocket.java} (82%) rename smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/{OkHttpWebsocketFactory.java => OkHttpWebSocketFactory.java} (72%) create mode 100644 smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebSocketFactory delete mode 100644 smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebsocketFactory rename smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/{OkHttpWebsocketFactoryServiceTest.java => OkHttpWebSocketFactoryServiceTest.java} (75%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/{WebsocketConnectionAttemptState.java => WebSocketConnectionAttemptState.java} (58%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/{WebsocketException.java => WebSocketException.java} (85%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/{WebsocketInitializer.java => WebSocketInitializer.java} (86%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/{XmppWebsocketTransportModule.java => XmppWebSocketTransportModule.java} (73%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/{XmppWebsocketTransportModuleDescriptor.java => XmppWebSocketTransportModuleDescriptor.java} (67%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/{AbstractWebsocketNonza.java => AbstractWebSocketNonza.java} (92%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/{WebsocketCloseElement.java => WebSocketCloseElement.java} (93%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/{WebsocketOpenElement.java => WebSocketOpenElement.java} (93%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/{AbstractWebsocket.java => AbstractWebSocket.java} (89%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/{WebsocketFactory.java => WebSocketFactory.java} (88%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/{WebsocketFactoryService.java => WebSocketFactoryService.java} (76%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/{WebsocketRemoteConnectionEndpoint.java => WebSocketRemoteConnectionEndpoint.java} (90%) rename smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/{WebsocketRemoteConnectionEndpointLookup.java => WebSocketRemoteConnectionEndpointLookup.java} (85%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/{WebsocketConnectionAttemptStateTest.java => WebSocketConnectionAttemptStateTest.java} (87%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/{WebsocketInitializerTest.java => WebSocketInitializerTest.java} (90%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/{XmppWebsocketTransportModuleTest.java => XmppWebSocketTransportModuleTest.java} (61%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/{WebsocketElementTest.java => WebSocketElementTest.java} (88%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/{AbstractWebsocketTest.java => AbstractWebSocketTest.java} (81%) rename smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/{WebsocketRemoteConnectionEndpointTest.java => WebSocketRemoteConnectionEndpointTest.java} (85%) rename smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/{WebsocketFactoryServiceTestUtil.java => WebSocketFactoryServiceTestUtil.java} (74%) diff --git a/smack-core/src/main/resources/org.jivesoftware.smack/smack-config.xml b/smack-core/src/main/resources/org.jivesoftware.smack/smack-config.xml index b80048942..e439e04e4 100644 --- a/smack-core/src/main/resources/org.jivesoftware.smack/smack-config.xml +++ b/smack-core/src/main/resources/org.jivesoftware.smack/smack-config.xml @@ -20,7 +20,7 @@ org.jivesoftware.smack.android.AndroidSmackInitializer org.jivesoftware.smack.java7.Java7SmackInitializer org.jivesoftware.smack.im.SmackImInitializer - org.jivesoftware.smack.websocket.WebsocketInitializer + org.jivesoftware.smack.websocket.WebSocketInitializer org.jivesoftware.smackx.omemo.OmemoInitializer org.jivesoftware.smackx.ox.util.OpenPgpInitializer diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/XmppConnectionManager.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/XmppConnectionManager.java index 4f5e3d6c1..c380e9831 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/XmppConnectionManager.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/XmppConnectionManager.java @@ -44,7 +44,7 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; import org.jivesoftware.smack.util.MultiMap; import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModuleDescriptor; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModuleDescriptor; import org.jivesoftware.smackx.admin.ServiceAdministrationManager; import org.jivesoftware.smackx.iqregister.AccountManager; @@ -92,7 +92,7 @@ public class XmppConnectionManager { .withNickname("modular-websocket") .applyExtraConfguration(cb -> { cb.removeAllModules(); - cb.addModule(XmppWebsocketTransportModuleDescriptor.class); + cb.addModule(XmppWebSocketTransportModuleDescriptor.class); }) .build() ); diff --git a/smack-java8-full/src/test/resources/state-graph.dot b/smack-java8-full/src/test/resources/state-graph.dot index 8c41183a5..873d8b202 100644 --- a/smack-java8-full/src/test/resources/state-graph.dot +++ b/smack-java8-full/src/test/resources/state-graph.dot @@ -32,7 +32,7 @@ digraph { "ConnectedButUnauthenticated" -> "InstantShutdown" [xlabel="5"]; "ConnectedButUnauthenticated" [ style=filled ] "EstablishingTcpConnection" -> "ConnectedButUnauthenticated" [xlabel="2"]; - "LookupRemoteConnectionEndpoints" -> "EstablishingWebsocketConnection" [xlabel="2"]; - "EstablishingWebsocketConnection" -> "ConnectedButUnauthenticated"; + "LookupRemoteConnectionEndpoints" -> "EstablishingWebSocketConnection" [xlabel="2"]; + "EstablishingWebSocketConnection" -> "ConnectedButUnauthenticated"; "Disconnected" [ style=filled ] } diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebsocketConnection.java b/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java similarity index 87% rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebsocketConnection.java rename to smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java index 035276fab..ee117dcb8 100644 --- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebsocketConnection.java +++ b/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java @@ -29,9 +29,9 @@ import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection; import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModuleDescriptor; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModuleDescriptor; -public class WebsocketConnection { +public class WebSocketConnection { public static void main(String[] args) throws SmackException, IOException, XMPPException, InterruptedException, URISyntaxException { ModularXmppClientToServerConnectionConfiguration.Builder builder = ModularXmppClientToServerConnectionConfiguration.builder(); @@ -39,8 +39,8 @@ public class WebsocketConnection { builder.setXmppAddressAndPassword(args[0], args[1]); // Set a fallback uri into websocket transport descriptor and add this descriptor into connection builder. - XmppWebsocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebsocketTransportModuleDescriptor.getBuilder(builder); - websocketBuilder.explicitlySetWebsocketEndpointAndDiscovery(new URI(args[2]), false); + XmppWebSocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebSocketTransportModuleDescriptor.getBuilder(builder); + websocketBuilder.explicitlySetWebSocketEndpointAndDiscovery(new URI(args[2]), false); builder.addModule(websocketBuilder.build()); ModularXmppClientToServerConnectionConfiguration config = builder.build(); diff --git a/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocket.java b/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocket.java similarity index 82% rename from smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocket.java rename to smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocket.java index 3e7640699..8523b350a 100644 --- a/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocket.java +++ b/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocket.java @@ -27,10 +27,10 @@ import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; import org.jivesoftware.smack.packet.TopLevelStreamElement; import org.jivesoftware.smack.util.PacketParserUtils; -import org.jivesoftware.smack.websocket.WebsocketException; -import org.jivesoftware.smack.websocket.elements.WebsocketOpenElement; -import org.jivesoftware.smack.websocket.impl.AbstractWebsocket; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpoint; +import org.jivesoftware.smack.websocket.WebSocketException; +import org.jivesoftware.smack.websocket.elements.WebSocketOpenElement; +import org.jivesoftware.smack.websocket.impl.AbstractWebSocket; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpoint; import org.jivesoftware.smack.xml.XmlPullParserException; import okhttp3.OkHttpClient; @@ -39,9 +39,9 @@ import okhttp3.Response; import okhttp3.WebSocket; import okhttp3.WebSocketListener; -public final class OkHttpWebsocket extends AbstractWebsocket { +public final class OkHttpWebSocket extends AbstractWebSocket { - private static final Logger LOGGER = Logger.getLogger(OkHttpWebsocket.class.getName()); + private static final Logger LOGGER = Logger.getLogger(OkHttpWebSocket.class.getName()); private static OkHttpClient okHttpClient = null; @@ -49,11 +49,11 @@ public final class OkHttpWebsocket extends AbstractWebsocket { private final LoggingInterceptor interceptor; private String openStreamHeader; - private WebSocket currentWebsocket; - private WebsocketConnectionPhase phase; - private WebsocketRemoteConnectionEndpoint connectedEndpoint; + private WebSocket currentWebSocket; + private WebSocketConnectionPhase phase; + private WebSocketRemoteConnectionEndpoint connectedEndpoint; - public OkHttpWebsocket(ModularXmppClientToServerConnectionInternal connectionInternal) { + public OkHttpWebSocket(ModularXmppClientToServerConnectionInternal connectionInternal) { this.connectionInternal = connectionInternal; if (okHttpClient == null) { @@ -70,8 +70,8 @@ public final class OkHttpWebsocket extends AbstractWebsocket { } @Override - public void connect(WebsocketRemoteConnectionEndpoint endpoint) throws InterruptedException, SmackException, XMPPException { - final String currentUri = endpoint.getWebsocketEndpoint().toString(); + public void connect(WebSocketRemoteConnectionEndpoint endpoint) throws InterruptedException, SmackException, XMPPException { + final String currentUri = endpoint.getWebSocketEndpoint().toString(); Request request = new Request.Builder() .url(currentUri) .header("Sec-WebSocket-Protocol", "xmpp") @@ -81,12 +81,12 @@ public final class OkHttpWebsocket extends AbstractWebsocket { @Override public void onOpen(WebSocket webSocket, Response response) { - LOGGER.log(Level.FINER, "Websocket is open"); - phase = WebsocketConnectionPhase.openFrameSent; + LOGGER.log(Level.FINER, "WebSocket is open"); + phase = WebSocketConnectionPhase.openFrameSent; if (interceptor != null) { interceptor.interceptOpenResponse(response); } - send(new WebsocketOpenElement(connectionInternal.connection.getXMPPServiceDomain())); + send(new WebSocketOpenElement(connectionInternal.connection.getXMPPServiceDomain())); } @Override @@ -105,7 +105,7 @@ public final class OkHttpWebsocket extends AbstractWebsocket { if (isOpenElement(text)) { // Converts the element received into element. openStreamHeader = getStreamFromOpenElement(text); - phase = WebsocketConnectionPhase.exchangingTopLevelStreamElements; + phase = WebSocketConnectionPhase.exchangingTopLevelStreamElements; try { connectionInternal.onStreamOpen(PacketParserUtils.getParserFor(openStreamHeader)); @@ -127,7 +127,7 @@ public final class OkHttpWebsocket extends AbstractWebsocket { @Override public void onFailure(WebSocket webSocket, Throwable t, Response response) { LOGGER.log(Level.INFO, "Exception caught", t); - WebsocketException websocketException = new WebsocketException(t); + WebSocketException websocketException = new WebSocketException(t); if (connectionInternal.connection.isConnected()) { connectionInternal.notifyConnectionError(websocketException); } else { @@ -137,7 +137,7 @@ public final class OkHttpWebsocket extends AbstractWebsocket { }; // Creates an instance of websocket through okHttpClient. - currentWebsocket = okHttpClient.newWebSocket(request, listener); + currentWebSocket = okHttpClient.newWebSocket(request, listener); // Open a new stream and wait until features are received. connectionInternal.waitForFeaturesReceived("Waiting to receive features"); @@ -151,13 +151,13 @@ public final class OkHttpWebsocket extends AbstractWebsocket { if (interceptor != null) { interceptor.interceptSentText(textToBeSent); } - currentWebsocket.send(textToBeSent); + currentWebSocket.send(textToBeSent); } @Override public void disconnect(int code, String message) { - currentWebsocket.close(code, message); - LOGGER.log(Level.INFO, "Websocket has been closed with message: " + message); + currentWebSocket.close(code, message); + LOGGER.log(Level.INFO, "WebSocket has been closed with message: " + message); } @Override diff --git a/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactory.java b/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactory.java similarity index 72% rename from smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactory.java rename to smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactory.java index 48b42e815..ea6b459bc 100644 --- a/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactory.java +++ b/smack-websocket-okhttp/src/main/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactory.java @@ -17,14 +17,14 @@ package org.jivesoftware.smack.websocket.okhttp; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; -import org.jivesoftware.smack.websocket.impl.AbstractWebsocket; -import org.jivesoftware.smack.websocket.impl.WebsocketFactory; +import org.jivesoftware.smack.websocket.impl.AbstractWebSocket; +import org.jivesoftware.smack.websocket.impl.WebSocketFactory; -public class OkHttpWebsocketFactory implements WebsocketFactory { +public class OkHttpWebSocketFactory implements WebSocketFactory { @Override - public AbstractWebsocket create(ModularXmppClientToServerConnectionInternal connectionInternal) { - return new OkHttpWebsocket(connectionInternal); + public AbstractWebSocket create(ModularXmppClientToServerConnectionInternal connectionInternal) { + return new OkHttpWebSocket(connectionInternal); } } diff --git a/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebSocketFactory b/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebSocketFactory new file mode 100644 index 000000000..cc48ccb04 --- /dev/null +++ b/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebSocketFactory @@ -0,0 +1 @@ +org.jivesoftware.smack.websocket.okhttp.OkHttpWebSocketFactory \ No newline at end of file diff --git a/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebsocketFactory b/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebsocketFactory deleted file mode 100644 index 75257214f..000000000 --- a/smack-websocket-okhttp/src/main/resources/META-INF/services/org.jivesoftware.smack.websocket.impl.WebsocketFactory +++ /dev/null @@ -1 +0,0 @@ -org.jivesoftware.smack.websocket.okhttp.OkHttpWebsocketFactory \ No newline at end of file diff --git a/smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactoryServiceTest.java b/smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactoryServiceTest.java similarity index 75% rename from smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactoryServiceTest.java rename to smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactoryServiceTest.java index d4fca586f..c1fadf85a 100644 --- a/smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebsocketFactoryServiceTest.java +++ b/smack-websocket-okhttp/src/test/java/org/jivesoftware/smack/websocket/okhttp/OkHttpWebSocketFactoryServiceTest.java @@ -16,15 +16,15 @@ */ package org.jivesoftware.smack.websocket.okhttp; -import org.jivesoftware.smack.websocket.test.WebsocketFactoryServiceTestUtil; +import org.jivesoftware.smack.websocket.test.WebSocketFactoryServiceTestUtil; import org.junit.jupiter.api.Test; -public class OkHttpWebsocketFactoryServiceTest { +public class OkHttpWebSocketFactoryServiceTest { @Test - public void createWebsocketTest() { - WebsocketFactoryServiceTestUtil.createWebsocketTest(OkHttpWebsocket.class); + public void createWebSocketTest() { + WebSocketFactoryServiceTestUtil.createWebSocketTest(OkHttpWebSocket.class); } } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptState.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptState.java similarity index 58% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptState.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptState.java index 60639d5b5..c17aedaf6 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptState.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptState.java @@ -20,44 +20,44 @@ import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModule.EstablishingWebsocketConnectionState; -import org.jivesoftware.smack.websocket.impl.AbstractWebsocket; -import org.jivesoftware.smack.websocket.impl.WebsocketFactoryService; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpoint; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModule.EstablishingWebSocketConnectionState; +import org.jivesoftware.smack.websocket.impl.AbstractWebSocket; +import org.jivesoftware.smack.websocket.impl.WebSocketFactoryService; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpoint; -public final class WebsocketConnectionAttemptState { +public final class WebSocketConnectionAttemptState { private final ModularXmppClientToServerConnectionInternal connectionInternal; - private final XmppWebsocketTransportModule.XmppWebsocketTransport.DiscoveredWebsocketEndpoints discoveredEndpoints; + private final XmppWebSocketTransportModule.XmppWebSocketTransport.DiscoveredWebSocketEndpoints discoveredEndpoints; - private WebsocketRemoteConnectionEndpoint connectedEndpoint; + private WebSocketRemoteConnectionEndpoint connectedEndpoint; - WebsocketConnectionAttemptState(ModularXmppClientToServerConnectionInternal connectionInternal, - XmppWebsocketTransportModule.XmppWebsocketTransport.DiscoveredWebsocketEndpoints discoveredWebsocketEndpoints, - EstablishingWebsocketConnectionState establishingWebsocketConnectionState) { - assert discoveredWebsocketEndpoints != null; + WebSocketConnectionAttemptState(ModularXmppClientToServerConnectionInternal connectionInternal, + XmppWebSocketTransportModule.XmppWebSocketTransport.DiscoveredWebSocketEndpoints discoveredWebSocketEndpoints, + EstablishingWebSocketConnectionState establishingWebSocketConnectionState) { + assert discoveredWebSocketEndpoints != null; this.connectionInternal = connectionInternal; - this.discoveredEndpoints = discoveredWebsocketEndpoints; + this.discoveredEndpoints = discoveredWebSocketEndpoints; } /** * Establish a websocket connection with one of the discoveredRemoteConnectionEndpoints.
* - * @return {@link AbstractWebsocket} with which connection is establised + * @return {@link AbstractWebSocket} with which connection is establised * @throws InterruptedException if the calling thread was interrupted - * @throws WebsocketException if encounters a websocket exception + * @throws WebSocketException if encounters a websocket exception */ - AbstractWebsocket establishWebsocketConnection() throws InterruptedException, WebsocketException { - List endpoints = discoveredEndpoints.result.discoveredRemoteConnectionEndpoints; + AbstractWebSocket establishWebSocketConnection() throws InterruptedException, WebSocketException { + List endpoints = discoveredEndpoints.result.discoveredRemoteConnectionEndpoints; if (endpoints.isEmpty()) { - throw new WebsocketException(new Throwable("No Endpoints discovered to establish connection")); + throw new WebSocketException(new Throwable("No Endpoints discovered to establish connection")); } List connectionFailureList = new ArrayList<>(); - AbstractWebsocket websocket = WebsocketFactoryService.createWebsocket(connectionInternal); + AbstractWebSocket websocket = WebSocketFactoryService.createWebSocket(connectionInternal); // Keep iterating over available endpoints until a connection is establised or all endpoints are tried to create a connection with. - for (WebsocketRemoteConnectionEndpoint endpoint : endpoints) { + for (WebSocketRemoteConnectionEndpoint endpoint : endpoints) { try { websocket.connect(endpoint); connectedEndpoint = endpoint; @@ -68,8 +68,8 @@ public final class WebsocketConnectionAttemptState { // If the number of entries in connectionFailureList is equal to the number of endpoints, // it means that all endpoints have been tried and have been unsuccessful. if (connectionFailureList.size() == endpoints.size()) { - WebsocketException websocketException = new WebsocketException(connectionFailureList); - throw new WebsocketException(websocketException); + WebSocketException websocketException = new WebSocketException(connectionFailureList); + throw new WebSocketException(websocketException); } } } @@ -85,7 +85,7 @@ public final class WebsocketConnectionAttemptState { * * @return connected websocket endpoint */ - public WebsocketRemoteConnectionEndpoint getConnectedEndpoint() { + public WebSocketRemoteConnectionEndpoint getConnectedEndpoint() { return connectedEndpoint; } } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketException.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketException.java similarity index 85% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketException.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketException.java index ba508001c..554bb4257 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketException.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketException.java @@ -19,16 +19,16 @@ package org.jivesoftware.smack.websocket; import java.util.Collections; import java.util.List; -public final class WebsocketException extends Exception { +public final class WebSocketException extends Exception { private static final long serialVersionUID = 1L; private final List throwableList; - public WebsocketException(List throwableList) { + public WebSocketException(List throwableList) { this.throwableList = throwableList; } - public WebsocketException(Throwable throwable) { + public WebSocketException(Throwable throwable) { this.throwableList = Collections.singletonList(throwable); } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketInitializer.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketInitializer.java similarity index 86% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketInitializer.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketInitializer.java index 18b3b17b1..b5a80839e 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebsocketInitializer.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/WebSocketInitializer.java @@ -19,10 +19,10 @@ package org.jivesoftware.smack.websocket; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.initializer.UrlInitializer; -public final class WebsocketInitializer extends UrlInitializer { +public final class WebSocketInitializer extends UrlInitializer { static { - SmackConfiguration.addModule(XmppWebsocketTransportModuleDescriptor.class); + SmackConfiguration.addModule(XmppWebSocketTransportModuleDescriptor.class); } } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModule.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java similarity index 73% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModule.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java index d3f5d9773..db80a1b6e 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModule.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java @@ -50,13 +50,13 @@ import org.jivesoftware.smack.packet.AbstractStreamOpen; import org.jivesoftware.smack.packet.TopLevelStreamElement; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModule.XmppWebsocketTransport.DiscoveredWebsocketEndpoints; -import org.jivesoftware.smack.websocket.elements.WebsocketCloseElement; -import org.jivesoftware.smack.websocket.elements.WebsocketOpenElement; -import org.jivesoftware.smack.websocket.impl.AbstractWebsocket; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpoint; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpointLookup; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpointLookup.Result; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModule.XmppWebSocketTransport.DiscoveredWebSocketEndpoints; +import org.jivesoftware.smack.websocket.elements.WebSocketCloseElement; +import org.jivesoftware.smack.websocket.elements.WebSocketOpenElement; +import org.jivesoftware.smack.websocket.impl.AbstractWebSocket; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpoint; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpointLookup; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpointLookup.Result; import org.jxmpp.jid.DomainBareJid; import org.jxmpp.jid.impl.JidCreate; @@ -65,44 +65,44 @@ import org.jxmpp.stringprep.XmppStringprepException; /** * The websocket transport module that goes with Smack's modular architecture. */ -public final class XmppWebsocketTransportModule - extends ModularXmppClientToServerConnectionModule { - private final XmppWebsocketTransport websocketTransport; +public final class XmppWebSocketTransportModule + extends ModularXmppClientToServerConnectionModule { + private final XmppWebSocketTransport websocketTransport; - private AbstractWebsocket websocket; + private AbstractWebSocket websocket; - protected XmppWebsocketTransportModule(XmppWebsocketTransportModuleDescriptor moduleDescriptor, + protected XmppWebSocketTransportModule(XmppWebSocketTransportModuleDescriptor moduleDescriptor, ModularXmppClientToServerConnectionInternal connectionInternal) { super(moduleDescriptor, connectionInternal); - websocketTransport = new XmppWebsocketTransport(connectionInternal); + websocketTransport = new XmppWebSocketTransport(connectionInternal); } @Override - protected XmppWebsocketTransport getTransport() { + protected XmppWebSocketTransport getTransport() { return websocketTransport; } - static final class EstablishingWebsocketConnectionStateDescriptor extends StateDescriptor { - private EstablishingWebsocketConnectionStateDescriptor() { - super(XmppWebsocketTransportModule.EstablishingWebsocketConnectionState.class); + static final class EstablishingWebSocketConnectionStateDescriptor extends StateDescriptor { + private EstablishingWebSocketConnectionStateDescriptor() { + super(XmppWebSocketTransportModule.EstablishingWebSocketConnectionState.class); addPredeccessor(LookupRemoteConnectionEndpointsStateDescriptor.class); addSuccessor(ConnectedButUnauthenticatedStateDescriptor.class); - // This states preference to TCP transports over this Websocket transport implementation. + // This states preference to TCP transports over this WebSocket transport implementation. declareInferiorityTo("org.jivesoftware.smack.tcp.XmppTcpTransportModule$EstablishingTcpConnectionStateDescriptor"); } @Override protected State constructState(ModularXmppClientToServerConnectionInternal connectionInternal) { - XmppWebsocketTransportModule websocketTransportModule = connectionInternal.connection.getConnectionModuleFor( - XmppWebsocketTransportModuleDescriptor.class); - return websocketTransportModule.constructEstablishingWebsocketConnectionState(this, connectionInternal); + XmppWebSocketTransportModule websocketTransportModule = connectionInternal.connection.getConnectionModuleFor( + XmppWebSocketTransportModuleDescriptor.class); + return websocketTransportModule.constructEstablishingWebSocketConnectionState(this, connectionInternal); } } - final class EstablishingWebsocketConnectionState extends State { - protected EstablishingWebsocketConnectionState(StateDescriptor stateDescriptor, + final class EstablishingWebSocketConnectionState extends State { + protected EstablishingWebSocketConnectionState(StateDescriptor stateDescriptor, ModularXmppClientToServerConnectionInternal connectionInternal) { super(stateDescriptor, connectionInternal); } @@ -110,78 +110,78 @@ public final class XmppWebsocketTransportModule @Override public AttemptResult transitionInto(WalkStateGraphContext walkStateGraphContext) throws IOException, SmackException, InterruptedException, XMPPException { - WebsocketConnectionAttemptState connectionAttemptState = new WebsocketConnectionAttemptState( - connectionInternal, discoveredWebsocketEndpoints, this); + WebSocketConnectionAttemptState connectionAttemptState = new WebSocketConnectionAttemptState( + connectionInternal, discoveredWebSocketEndpoints, this); try { - websocket = connectionAttemptState.establishWebsocketConnection(); - } catch (InterruptedException | WebsocketException e) { + websocket = connectionAttemptState.establishWebSocketConnection(); + } catch (InterruptedException | WebSocketException e) { StateTransitionResult.Failure failure = new StateTransitionResult.FailureCausedByException(e); return failure; } connectionInternal.setTransport(websocketTransport); - WebsocketRemoteConnectionEndpoint connectedEndpoint = connectionAttemptState.getConnectedEndpoint(); + WebSocketRemoteConnectionEndpoint connectedEndpoint = connectionAttemptState.getConnectedEndpoint(); - // Construct a WebsocketConnectedResult using the connected endpoint. - return new WebsocketConnectedResult(connectedEndpoint); + // Construct a WebSocketConnectedResult using the connected endpoint. + return new WebSocketConnectedResult(connectedEndpoint); } } - public EstablishingWebsocketConnectionState constructEstablishingWebsocketConnectionState( - EstablishingWebsocketConnectionStateDescriptor establishingWebsocketConnectionStateDescriptor, + public EstablishingWebSocketConnectionState constructEstablishingWebSocketConnectionState( + EstablishingWebSocketConnectionStateDescriptor establishingWebSocketConnectionStateDescriptor, ModularXmppClientToServerConnectionInternal connectionInternal) { - return new EstablishingWebsocketConnectionState(establishingWebsocketConnectionStateDescriptor, + return new EstablishingWebSocketConnectionState(establishingWebSocketConnectionStateDescriptor, connectionInternal); } - public static final class WebsocketConnectedResult extends StateTransitionResult.Success { - final WebsocketRemoteConnectionEndpoint connectedEndpoint; + public static final class WebSocketConnectedResult extends StateTransitionResult.Success { + final WebSocketRemoteConnectionEndpoint connectedEndpoint; - public WebsocketConnectedResult(WebsocketRemoteConnectionEndpoint connectedEndpoint) { - super("Websocket connection establised with endpoint: " + connectedEndpoint.getWebsocketEndpoint()); + public WebSocketConnectedResult(WebSocketRemoteConnectionEndpoint connectedEndpoint) { + super("WebSocket connection establised with endpoint: " + connectedEndpoint.getWebSocketEndpoint()); this.connectedEndpoint = connectedEndpoint; } } - private DiscoveredWebsocketEndpoints discoveredWebsocketEndpoints; + private DiscoveredWebSocketEndpoints discoveredWebSocketEndpoints; /** * Transport class for {@link ModularXmppClientToServerConnectionModule}'s websocket implementation. */ - public final class XmppWebsocketTransport extends XmppClientToServerTransport { + public final class XmppWebSocketTransport extends XmppClientToServerTransport { AsyncButOrdered> asyncButOrderedOutgoingElementsQueue; - protected XmppWebsocketTransport(ModularXmppClientToServerConnectionInternal connectionInternal) { + protected XmppWebSocketTransport(ModularXmppClientToServerConnectionInternal connectionInternal) { super(connectionInternal); asyncButOrderedOutgoingElementsQueue = new AsyncButOrdered>(); } @Override protected void resetDiscoveredConnectionEndpoints() { - discoveredWebsocketEndpoints = null; + discoveredWebSocketEndpoints = null; } @Override protected List> lookupConnectionEndpoints() { // Assert that there are no stale discovered endpoints prior performing the lookup. - assert discoveredWebsocketEndpoints == null; + assert discoveredWebSocketEndpoints == null; InternalSmackFuture websocketEndpointsLookupFuture = new InternalSmackFuture<>(); connectionInternal.asyncGo(() -> { - WebsocketRemoteConnectionEndpoint providedEndpoint = null; + WebSocketRemoteConnectionEndpoint providedEndpoint = null; // Check if there is a websocket endpoint already configured. URI uri = moduleDescriptor.getExplicitlyProvidedUri(); if (uri != null) { - providedEndpoint = new WebsocketRemoteConnectionEndpoint(uri); + providedEndpoint = new WebSocketRemoteConnectionEndpoint(uri); } - if (!moduleDescriptor.isWebsocketEndpointDiscoveryEnabled()) { + if (!moduleDescriptor.isWebSocketEndpointDiscoveryEnabled()) { // If discovery is disabled, assert that the provided endpoint isn't null. assert providedEndpoint != null; @@ -190,14 +190,14 @@ public final class XmppWebsocketTransportModule mode.equals(SecurityMode.disabled)) || (!providedEndpoint.isSecureEndpoint() && mode.equals(SecurityMode.required))) { - throw new IllegalStateException("Explicitly configured uri: " + providedEndpoint.getWebsocketEndpoint().toString() + throw new IllegalStateException("Explicitly configured uri: " + providedEndpoint.getWebSocketEndpoint().toString() + " does not comply with the configured security mode: " + mode); } // Generate Result for explicitly configured endpoint. Result manualResult = new Result(Arrays.asList(providedEndpoint), null); - LookupConnectionEndpointsResult endpointsResult = new DiscoveredWebsocketEndpoints(manualResult); + LookupConnectionEndpointsResult endpointsResult = new DiscoveredWebSocketEndpoints(manualResult); websocketEndpointsLookupFuture.setResult(endpointsResult); } else { @@ -206,14 +206,14 @@ public final class XmppWebsocketTransportModule SecurityMode mode = configuration.getSecurityMode(); // Fetch remote endpoints. - Result xep0156result = WebsocketRemoteConnectionEndpointLookup.lookup(host, mode); + Result xep0156result = WebSocketRemoteConnectionEndpointLookup.lookup(host, mode); - List discoveredEndpoints = xep0156result.discoveredRemoteConnectionEndpoints; + List discoveredEndpoints = xep0156result.discoveredRemoteConnectionEndpoints; // Generate result considering both manual and fetched endpoints. Result finalResult = new Result(discoveredEndpoints, xep0156result.getLookupFailures()); - LookupConnectionEndpointsResult endpointsResult = new DiscoveredWebsocketEndpoints(finalResult); + LookupConnectionEndpointsResult endpointsResult = new DiscoveredWebSocketEndpoints(finalResult); websocketEndpointsLookupFuture.setResult(endpointsResult); } @@ -224,7 +224,7 @@ public final class XmppWebsocketTransportModule @Override protected void loadConnectionEndpoints(LookupConnectionEndpointsSuccess lookupConnectionEndpointsSuccess) { - discoveredWebsocketEndpoints = (DiscoveredWebsocketEndpoints) lookupConnectionEndpointsSuccess; + discoveredWebSocketEndpoints = (DiscoveredWebSocketEndpoints) lookupConnectionEndpointsSuccess; } @Override @@ -233,7 +233,7 @@ public final class XmppWebsocketTransportModule @Override protected void disconnect() { - websocket.disconnect(1000, "Websocket closed normally"); + websocket.disconnect(1000, "WebSocket closed normally"); } @Override @@ -272,7 +272,7 @@ public final class XmppWebsocketTransportModule @Override public AbstractStreamOpen createStreamOpen(CharSequence to, CharSequence from, String id, String lang) { try { - return new WebsocketOpenElement(JidCreate.domainBareFrom(to)); + return new WebSocketOpenElement(JidCreate.domainBareFrom(to)); } catch (XmppStringprepException e) { Logger.getAnonymousLogger().log(Level.WARNING, "Couldn't create OpenElement", e); return null; @@ -280,7 +280,7 @@ public final class XmppWebsocketTransportModule } @Override public AbstractStreamClose createStreamClose() { - return new WebsocketCloseElement(); + return new WebSocketCloseElement(); } }; } @@ -288,15 +288,15 @@ public final class XmppWebsocketTransportModule /** * Contains {@link Result} for successfully discovered endpoints. */ - public final class DiscoveredWebsocketEndpoints implements LookupConnectionEndpointsSuccess { - final WebsocketRemoteConnectionEndpointLookup.Result result; + public final class DiscoveredWebSocketEndpoints implements LookupConnectionEndpointsSuccess { + final WebSocketRemoteConnectionEndpointLookup.Result result; - DiscoveredWebsocketEndpoints(Result result) { + DiscoveredWebSocketEndpoints(Result result) { assert result != null; this.result = result; } - public WebsocketRemoteConnectionEndpointLookup.Result getResult() { + public WebSocketRemoteConnectionEndpointLookup.Result getResult() { return result; } } @@ -305,11 +305,11 @@ public final class XmppWebsocketTransportModule * Contains list of {@link RemoteConnectionEndpointLookupFailure} when no endpoint * could be found during http lookup. */ - final class WebsocketEndpointsDiscoveryFailed implements LookupConnectionEndpointsFailed { + final class WebSocketEndpointsDiscoveryFailed implements LookupConnectionEndpointsFailed { final List lookupFailures; - WebsocketEndpointsDiscoveryFailed( - WebsocketRemoteConnectionEndpointLookup.Result result) { + WebSocketEndpointsDiscoveryFailed( + WebSocketRemoteConnectionEndpointLookup.Result result) { assert result != null; lookupFailures = Collections.unmodifiableList(result.lookupFailures); } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleDescriptor.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleDescriptor.java similarity index 67% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleDescriptor.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleDescriptor.java index 07a3e2e84..292fdceb0 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleDescriptor.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleDescriptor.java @@ -28,20 +28,20 @@ import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionModuleDescr import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; import org.jivesoftware.smack.fsm.StateDescriptor; import org.jivesoftware.smack.util.Objects; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModule.EstablishingWebsocketConnectionStateDescriptor; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModule.EstablishingWebSocketConnectionStateDescriptor; /** - * The descriptor class for {@link XmppWebsocketTransportModule}. + * The descriptor class for {@link XmppWebSocketTransportModule}. *
- * To add {@link XmppWebsocketTransportModule} to {@link ModularXmppClientToServerConnection}, + * To add {@link XmppWebSocketTransportModule} to {@link ModularXmppClientToServerConnection}, * use {@link ModularXmppClientToServerConnectionConfiguration.Builder#addModule(ModularXmppClientToServerConnectionModuleDescriptor)}. */ -public final class XmppWebsocketTransportModuleDescriptor extends ModularXmppClientToServerConnectionModuleDescriptor { - private boolean performWebsocketEndpointDiscovery; +public final class XmppWebSocketTransportModuleDescriptor extends ModularXmppClientToServerConnectionModuleDescriptor { + private boolean performWebSocketEndpointDiscovery; private URI uri; - public XmppWebsocketTransportModuleDescriptor(Builder builder) { - this.performWebsocketEndpointDiscovery = builder.performWebsocketEndpointDiscovery; + public XmppWebSocketTransportModuleDescriptor(Builder builder) { + this.performWebSocketEndpointDiscovery = builder.performWebSocketEndpointDiscovery; this.uri = builder.uri; } @@ -49,8 +49,8 @@ public final class XmppWebsocketTransportModuleDescriptor extends ModularXmppCli * Returns true if websocket endpoint discovery is true, returns false otherwise. * @return boolean */ - public boolean isWebsocketEndpointDiscoveryEnabled() { - return performWebsocketEndpointDiscovery; + public boolean isWebSocketEndpointDiscoveryEnabled() { + return performWebSocketEndpointDiscovery; } /** @@ -64,14 +64,14 @@ public final class XmppWebsocketTransportModuleDescriptor extends ModularXmppCli @Override protected Set> getStateDescriptors() { Set> res = new HashSet<>(); - res.add(EstablishingWebsocketConnectionStateDescriptor.class); + res.add(EstablishingWebSocketConnectionStateDescriptor.class); return res; } @Override protected ModularXmppClientToServerConnectionModule constructXmppConnectionModule( ModularXmppClientToServerConnectionInternal connectionInternal) { - return new XmppWebsocketTransportModule(this, connectionInternal); + return new XmppWebSocketTransportModule(this, connectionInternal); } /** @@ -86,19 +86,19 @@ public final class XmppWebsocketTransportModuleDescriptor extends ModularXmppCli } /** - * Builder class for {@link XmppWebsocketTransportModuleDescriptor}. + * Builder class for {@link XmppWebSocketTransportModuleDescriptor}. *
- * To obtain an instance of {@link XmppWebsocketTransportModuleDescriptor.Builder}, use {@link XmppWebsocketTransportModuleDescriptor#getBuilder(ModularXmppClientToServerConnectionConfiguration.Builder)} method. + * To obtain an instance of {@link XmppWebSocketTransportModuleDescriptor.Builder}, use {@link XmppWebSocketTransportModuleDescriptor#getBuilder(ModularXmppClientToServerConnectionConfiguration.Builder)} method. *
- * Use {@link Builder#explicitlySetWebsocketEndpoint(URI)} to configure the URI of an endpoint as a backup in case connection couldn't be established with endpoints through http lookup. + * Use {@link Builder#explicitlySetWebSocketEndpoint(URI)} to configure the URI of an endpoint as a backup in case connection couldn't be established with endpoints through http lookup. *
- * Use {@link Builder#explicitlySetWebsocketEndpointAndDiscovery(URI, boolean)} to configure endpoint and disallow websocket endpoint discovery through http lookup. - * By default, {@link Builder#performWebsocketEndpointDiscovery} is set to true. + * Use {@link Builder#explicitlySetWebSocketEndpointAndDiscovery(URI, boolean)} to configure endpoint and disallow websocket endpoint discovery through http lookup. + * By default, {@link Builder#performWebSocketEndpointDiscovery} is set to true. *
- * Use {@link Builder#build()} to obtain {@link XmppWebsocketTransportModuleDescriptor}. + * Use {@link Builder#build()} to obtain {@link XmppWebSocketTransportModuleDescriptor}. */ public static final class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder { - private boolean performWebsocketEndpointDiscovery = true; + private boolean performWebSocketEndpointDiscovery = true; private URI uri; private Builder( @@ -106,31 +106,31 @@ public final class XmppWebsocketTransportModuleDescriptor extends ModularXmppCli super(connectionConfigurationBuilder); } - public Builder explicitlySetWebsocketEndpoint(URI endpoint) { - return explicitlySetWebsocketEndpointAndDiscovery(endpoint, true); + public Builder explicitlySetWebSocketEndpoint(URI endpoint) { + return explicitlySetWebSocketEndpointAndDiscovery(endpoint, true); } - public Builder explicitlySetWebsocketEndpointAndDiscovery(URI endpoint, boolean performWebsocketEndpointDiscovery) { + public Builder explicitlySetWebSocketEndpointAndDiscovery(URI endpoint, boolean performWebSocketEndpointDiscovery) { Objects.requireNonNull(endpoint, "Provided endpoint URI must not be null"); this.uri = endpoint; - this.performWebsocketEndpointDiscovery = performWebsocketEndpointDiscovery; + this.performWebSocketEndpointDiscovery = performWebSocketEndpointDiscovery; return this; } - public Builder explicitlySetWebsocketEndpoint(CharSequence endpoint) throws URISyntaxException { + public Builder explicitlySetWebSocketEndpoint(CharSequence endpoint) throws URISyntaxException { URI endpointUri = new URI(endpoint.toString()); - return explicitlySetWebsocketEndpointAndDiscovery(endpointUri, true); + return explicitlySetWebSocketEndpointAndDiscovery(endpointUri, true); } - public Builder explicitlySetWebsocketEndpoint(CharSequence endpoint, boolean performWebsocketEndpointDiscovery) + public Builder explicitlySetWebSocketEndpoint(CharSequence endpoint, boolean performWebSocketEndpointDiscovery) throws URISyntaxException { URI endpointUri = new URI(endpoint.toString()); - return explicitlySetWebsocketEndpointAndDiscovery(endpointUri, performWebsocketEndpointDiscovery); + return explicitlySetWebSocketEndpointAndDiscovery(endpointUri, performWebSocketEndpointDiscovery); } @Override public ModularXmppClientToServerConnectionModuleDescriptor build() { - return new XmppWebsocketTransportModuleDescriptor(this); + return new XmppWebSocketTransportModuleDescriptor(this); } } } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebsocketNonza.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebSocketNonza.java similarity index 92% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebsocketNonza.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebSocketNonza.java index 3a95124ae..ba5203d45 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebsocketNonza.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/AbstractWebSocketNonza.java @@ -22,12 +22,12 @@ import org.jivesoftware.smack.util.XmlStringBuilder; import org.jxmpp.jid.DomainBareJid; -public abstract class AbstractWebsocketNonza implements Nonza { +public abstract class AbstractWebSocketNonza implements Nonza { public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-framing"; private static final String VERSION = "1.0"; private final DomainBareJid to; - public AbstractWebsocketNonza(DomainBareJid jid) { + public AbstractWebSocketNonza(DomainBareJid jid) { this.to = jid; } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketCloseElement.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketCloseElement.java similarity index 93% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketCloseElement.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketCloseElement.java index d455336c0..0afc675e1 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketCloseElement.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketCloseElement.java @@ -22,12 +22,12 @@ import org.jivesoftware.smack.packet.AbstractStreamClose; import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.util.XmlStringBuilder; -public final class WebsocketCloseElement extends AbstractStreamClose { +public final class WebSocketCloseElement extends AbstractStreamClose { public static final String ELEMENT = "close"; public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-framing"; public static final QName QNAME = new QName(NAMESPACE, ELEMENT); - public WebsocketCloseElement() { + public WebSocketCloseElement() { } @Override diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketOpenElement.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketOpenElement.java similarity index 93% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketOpenElement.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketOpenElement.java index 5660018cf..6805dca40 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebsocketOpenElement.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/elements/WebSocketOpenElement.java @@ -25,12 +25,12 @@ import org.jivesoftware.smack.util.XmlStringBuilder; import org.jxmpp.jid.DomainBareJid; -public final class WebsocketOpenElement extends AbstractStreamOpen { +public final class WebSocketOpenElement extends AbstractStreamOpen { public static final String ELEMENT = "open"; public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-framing"; public static final QName QNAME = new QName(NAMESPACE, ELEMENT); - public WebsocketOpenElement(DomainBareJid to) { + public WebSocketOpenElement(DomainBareJid to) { super(to, null, null, null, StreamContentNamespace.client); } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocket.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java similarity index 89% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocket.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java index 293208006..d7e76e230 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocket.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java @@ -19,11 +19,11 @@ package org.jivesoftware.smack.websocket.impl; import javax.net.ssl.SSLSession; import org.jivesoftware.smack.packet.TopLevelStreamElement; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpoint; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpoint; -public abstract class AbstractWebsocket { +public abstract class AbstractWebSocket { - protected enum WebsocketConnectionPhase { + protected enum WebSocketConnectionPhase { openFrameSent, exchangingTopLevelStreamElements } @@ -49,7 +49,7 @@ public abstract class AbstractWebsocket { return false; } - public abstract void connect(WebsocketRemoteConnectionEndpoint endpoint) throws Throwable; + public abstract void connect(WebSocketRemoteConnectionEndpoint endpoint) throws Throwable; public abstract void send(TopLevelStreamElement element); diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactory.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactory.java similarity index 88% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactory.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactory.java index 345db0d86..ddba0f2e8 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactory.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactory.java @@ -18,8 +18,8 @@ package org.jivesoftware.smack.websocket.impl; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; -public interface WebsocketFactory { +public interface WebSocketFactory { - AbstractWebsocket create(ModularXmppClientToServerConnectionInternal connectionInternal); + AbstractWebSocket create(ModularXmppClientToServerConnectionInternal connectionInternal); } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactoryService.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactoryService.java similarity index 76% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactoryService.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactoryService.java index a852c897b..0929c1d96 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebsocketFactoryService.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/WebSocketFactoryService.java @@ -21,19 +21,19 @@ import java.util.ServiceLoader; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; -public final class WebsocketFactoryService { +public final class WebSocketFactoryService { - private static final ServiceLoader SERVICE_LOADER = ServiceLoader.load(WebsocketFactory.class); + private static final ServiceLoader SERVICE_LOADER = ServiceLoader.load(WebSocketFactory.class); - public static AbstractWebsocket createWebsocket(ModularXmppClientToServerConnectionInternal connectionInternal) { + public static AbstractWebSocket createWebSocket(ModularXmppClientToServerConnectionInternal connectionInternal) { assert connectionInternal != null; - Iterator websocketFactories = SERVICE_LOADER.iterator(); + Iterator websocketFactories = SERVICE_LOADER.iterator(); if (!websocketFactories.hasNext()) { throw new IllegalStateException("No smack websocket service configured"); } - WebsocketFactory websocketFactory = websocketFactories.next(); + WebSocketFactory websocketFactory = websocketFactories.next(); return websocketFactory.create(connectionInternal); } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/package-info.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/package-info.java index 1f3049bde..35d1644de 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/package-info.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/package-info.java @@ -15,6 +15,6 @@ * limitations under the License. */ /** - * Websocket related classes for Smack. + * WebSocket related classes for Smack. */ package org.jivesoftware.smack.websocket; diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpoint.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpoint.java similarity index 90% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpoint.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpoint.java index d8bb0dca3..eab43afc3 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpoint.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpoint.java @@ -28,17 +28,17 @@ import java.util.logging.Logger; import org.jivesoftware.smack.datatypes.UInt16; import org.jivesoftware.smack.util.rce.RemoteConnectionEndpoint; -public final class WebsocketRemoteConnectionEndpoint implements RemoteConnectionEndpoint { +public final class WebSocketRemoteConnectionEndpoint implements RemoteConnectionEndpoint { private static final Logger LOGGER = Logger.getAnonymousLogger(); private final URI uri; - public WebsocketRemoteConnectionEndpoint(String uri) throws URISyntaxException { + public WebSocketRemoteConnectionEndpoint(String uri) throws URISyntaxException { this(new URI(uri)); } - public WebsocketRemoteConnectionEndpoint(URI uri) { + public WebSocketRemoteConnectionEndpoint(URI uri) { this.uri = uri; String scheme = uri.getScheme(); if (!(scheme.equals("ws") || scheme.equals("wss"))) { @@ -46,7 +46,7 @@ public final class WebsocketRemoteConnectionEndpoint implements RemoteConnection } } - public URI getWebsocketEndpoint() { + public URI getWebSocketEndpoint() { return uri; } diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointLookup.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointLookup.java similarity index 85% rename from smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointLookup.java rename to smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointLookup.java index 16ffc7f83..4ea558325 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointLookup.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointLookup.java @@ -31,11 +31,11 @@ import org.jivesoftware.smack.xml.XmlPullParserException; import org.jxmpp.jid.DomainBareJid; -public final class WebsocketRemoteConnectionEndpointLookup { +public final class WebSocketRemoteConnectionEndpointLookup { public static Result lookup(DomainBareJid domainBareJid, SecurityMode securityMode) { List lookupFailures = new ArrayList<>(1); - List discoveredRemoteConnectionEndpoints = new ArrayList<>(); + List discoveredRemoteConnectionEndpoints = new ArrayList<>(); List rcUriList = null; try { @@ -52,11 +52,11 @@ public final class WebsocketRemoteConnectionEndpointLookup { throw new IllegalStateException("No endpoints were found inside host-meta"); } - // Convert rcUriList to List + // Convert rcUriList to List Iterator iterator = rcUriList.iterator(); - List rceList = new ArrayList<>(); + List rceList = new ArrayList<>(); while (iterator.hasNext()) { - rceList.add(new WebsocketRemoteConnectionEndpoint(iterator.next())); + rceList.add(new WebSocketRemoteConnectionEndpoint(iterator.next())); } switch (securityMode) { @@ -64,9 +64,9 @@ public final class WebsocketRemoteConnectionEndpointLookup { // If security mode equals `if-possible`, give priority to secure endpoints over insecure endpoints. // Seprate secure and unsecure endpoints. - List secureEndpointsForSecurityModeIfPossible = new ArrayList<>(); - List insecureEndpointsForSecurityModeIfPossible = new ArrayList<>(); - for (WebsocketRemoteConnectionEndpoint uri : rceList) { + List secureEndpointsForSecurityModeIfPossible = new ArrayList<>(); + List insecureEndpointsForSecurityModeIfPossible = new ArrayList<>(); + for (WebSocketRemoteConnectionEndpoint uri : rceList) { if (uri.isSecureEndpoint()) { secureEndpointsForSecurityModeIfPossible.add(uri); } else { @@ -82,7 +82,7 @@ public final class WebsocketRemoteConnectionEndpointLookup { * If, SecurityMode equals to required, accept wss endpoints (secure endpoints) only or, * if SecurityMode equals to disabled, accept ws endpoints (unsecure endpoints) only. */ - for (WebsocketRemoteConnectionEndpoint uri : rceList) { + for (WebSocketRemoteConnectionEndpoint uri : rceList) { if ((securityMode.equals(SecurityMode.disabled) && !uri.isSecureEndpoint()) || (securityMode.equals(SecurityMode.required) && uri.isSecureEndpoint())) { discoveredRemoteConnectionEndpoints.add(uri); @@ -95,16 +95,16 @@ public final class WebsocketRemoteConnectionEndpointLookup { } public static final class Result { - public final List discoveredRemoteConnectionEndpoints; + public final List discoveredRemoteConnectionEndpoints; public final List lookupFailures; - public Result(List discoveredRemoteConnectionEndpoints, + public Result(List discoveredRemoteConnectionEndpoints, List lookupFailures) { this.discoveredRemoteConnectionEndpoints = discoveredRemoteConnectionEndpoints; this.lookupFailures = lookupFailures; } - public List getDiscoveredRemoteConnectionEndpoints() { + public List getDiscoveredRemoteConnectionEndpoints() { return discoveredRemoteConnectionEndpoints; } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptStateTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptStateTest.java similarity index 87% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptStateTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptStateTest.java index 59cd0adc8..fc447555e 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketConnectionAttemptStateTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketConnectionAttemptStateTest.java @@ -20,9 +20,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -public class WebsocketConnectionAttemptStateTest { +public class WebSocketConnectionAttemptStateTest { @Test public void constructorTest() { - assertThrows(AssertionError.class, () -> new WebsocketConnectionAttemptState(null, null, null)); + assertThrows(AssertionError.class, () -> new WebSocketConnectionAttemptState(null, null, null)); } } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketInitializerTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketInitializerTest.java similarity index 90% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketInitializerTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketInitializerTest.java index ce41c594e..943af9804 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebsocketInitializerTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/WebSocketInitializerTest.java @@ -22,10 +22,10 @@ import java.util.List; import org.junit.jupiter.api.Test; -public class WebsocketInitializerTest { +public class WebSocketInitializerTest { @Test public void testExtensionInitializer() { - WebsocketInitializer initializer = new WebsocketInitializer(); + WebSocketInitializer initializer = new WebSocketInitializer(); List exceptions = initializer.initialize(); assertTrue(exceptions.size() == 0); } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleTest.java similarity index 61% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleTest.java index ec745aa70..c21a93497 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebsocketTransportModuleTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModuleTest.java @@ -31,27 +31,27 @@ import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfigurati import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; import org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure; import org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure.HttpLookupFailure; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModule.XmppWebsocketTransport.DiscoveredWebsocketEndpoints; -import org.jivesoftware.smack.websocket.XmppWebsocketTransportModule.XmppWebsocketTransport.WebsocketEndpointsDiscoveryFailed; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpoint; -import org.jivesoftware.smack.websocket.rce.WebsocketRemoteConnectionEndpointLookup.Result; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModule.XmppWebSocketTransport.DiscoveredWebSocketEndpoints; +import org.jivesoftware.smack.websocket.XmppWebSocketTransportModule.XmppWebSocketTransport.WebSocketEndpointsDiscoveryFailed; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpoint; +import org.jivesoftware.smack.websocket.rce.WebSocketRemoteConnectionEndpointLookup.Result; import org.junit.jupiter.api.Test; import org.jxmpp.stringprep.XmppStringprepException; -public class XmppWebsocketTransportModuleTest { +public class XmppWebSocketTransportModuleTest { @Test - public void createWebsocketModuleConnectionInstanceTest() throws URISyntaxException, XmppStringprepException { + public void createWebSocketModuleConnectionInstanceTest() throws URISyntaxException, XmppStringprepException { ModularXmppClientToServerConnectionConfiguration.Builder builder = ModularXmppClientToServerConnectionConfiguration .builder(); builder.removeAllModules(); - builder.addModule(XmppWebsocketTransportModuleDescriptor.class); + builder.addModule(XmppWebSocketTransportModuleDescriptor.class); builder.setXmppAddressAndPassword("user5@localhost.org", "user5"); builder.setHost("localhost.org"); - XmppWebsocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebsocketTransportModuleDescriptor.getBuilder(builder); - websocketBuilder.explicitlySetWebsocketEndpointAndDiscovery(new URI("wss://localhost.org:7443/ws/"), false); + XmppWebSocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebSocketTransportModuleDescriptor.getBuilder(builder); + websocketBuilder.explicitlySetWebSocketEndpointAndDiscovery(new URI("wss://localhost.org:7443/ws/"), false); ModularXmppClientToServerConnectionConfiguration config = builder.build(); ModularXmppClientToServerConnection connection = new ModularXmppClientToServerConnection(config); @@ -60,26 +60,26 @@ public class XmppWebsocketTransportModuleTest { @Test public void createDescriptorTest() throws URISyntaxException, XmppStringprepException { - XmppWebsocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebsocketDescriptor(); + XmppWebSocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebSocketDescriptor(); assertNotNull(websocketTransportModuleDescriptor); } @Test public void websocketEndpointDiscoveryTest() throws URISyntaxException { - XmppWebsocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebsocketDescriptor(); + XmppWebSocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebSocketDescriptor(); ModularXmppClientToServerConnectionInternal connectionInternal = mock(ModularXmppClientToServerConnectionInternal.class); - XmppWebsocketTransportModule transportModule - = new XmppWebsocketTransportModule(websocketTransportModuleDescriptor, connectionInternal); + XmppWebSocketTransportModule transportModule + = new XmppWebSocketTransportModule(websocketTransportModuleDescriptor, connectionInternal); - XmppWebsocketTransportModule.XmppWebsocketTransport transport = transportModule.getTransport(); + XmppWebSocketTransportModule.XmppWebSocketTransport transport = transportModule.getTransport(); - assertThrows(AssertionError.class, () -> transport.new DiscoveredWebsocketEndpoints(null)); - assertThrows(AssertionError.class, () -> transport.new WebsocketEndpointsDiscoveryFailed(null)); + assertThrows(AssertionError.class, () -> transport.new DiscoveredWebSocketEndpoints(null)); + assertThrows(AssertionError.class, () -> transport.new WebSocketEndpointsDiscoveryFailed(null)); - WebsocketRemoteConnectionEndpoint endpoint = new WebsocketRemoteConnectionEndpoint("wss://localhost.org:7443/ws/"); + WebSocketRemoteConnectionEndpoint endpoint = new WebSocketRemoteConnectionEndpoint("wss://localhost.org:7443/ws/"); - List discoveredRemoteConnectionEndpoints = new ArrayList<>(); + List discoveredRemoteConnectionEndpoints = new ArrayList<>(); discoveredRemoteConnectionEndpoints.add(endpoint); HttpLookupFailure httpLookupFailure = new RemoteConnectionEndpointLookupFailure.HttpLookupFailure(null, null); @@ -87,38 +87,38 @@ public class XmppWebsocketTransportModuleTest { failureList.add(httpLookupFailure); Result result = new Result(discoveredRemoteConnectionEndpoints, failureList); - DiscoveredWebsocketEndpoints discoveredWebsocketEndpoints = transport.new DiscoveredWebsocketEndpoints(result); - assertNotNull(discoveredWebsocketEndpoints.getResult()); + DiscoveredWebSocketEndpoints discoveredWebSocketEndpoints = transport.new DiscoveredWebSocketEndpoints(result); + assertNotNull(discoveredWebSocketEndpoints.getResult()); - WebsocketEndpointsDiscoveryFailed endpointsDiscoveryFailed = transport.new WebsocketEndpointsDiscoveryFailed(result); + WebSocketEndpointsDiscoveryFailed endpointsDiscoveryFailed = transport.new WebSocketEndpointsDiscoveryFailed(result); assertNotNull(endpointsDiscoveryFailed.toString()); } @Test public void websocketConnectedResultTest() throws URISyntaxException { - WebsocketRemoteConnectionEndpoint connectedEndpoint = new WebsocketRemoteConnectionEndpoint("wss://localhost.org:7443/ws/"); - assertNotNull(new XmppWebsocketTransportModule.WebsocketConnectedResult(connectedEndpoint)); + WebSocketRemoteConnectionEndpoint connectedEndpoint = new WebSocketRemoteConnectionEndpoint("wss://localhost.org:7443/ws/"); + assertNotNull(new XmppWebSocketTransportModule.WebSocketConnectedResult(connectedEndpoint)); } @Test public void lookupConnectionEndpointsTest() throws URISyntaxException { - XmppWebsocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebsocketDescriptor(); + XmppWebSocketTransportModuleDescriptor websocketTransportModuleDescriptor = getWebSocketDescriptor(); ModularXmppClientToServerConnectionInternal connectionInternal = mock(ModularXmppClientToServerConnectionInternal.class); - XmppWebsocketTransportModule transportModule - = new XmppWebsocketTransportModule(websocketTransportModuleDescriptor, connectionInternal); + XmppWebSocketTransportModule transportModule + = new XmppWebSocketTransportModule(websocketTransportModuleDescriptor, connectionInternal); - XmppWebsocketTransportModule.XmppWebsocketTransport transport = transportModule.getTransport(); + XmppWebSocketTransportModule.XmppWebSocketTransport transport = transportModule.getTransport(); assertNotNull(transport.lookupConnectionEndpoints()); } - private static XmppWebsocketTransportModuleDescriptor getWebsocketDescriptor() throws URISyntaxException { + private static XmppWebSocketTransportModuleDescriptor getWebSocketDescriptor() throws URISyntaxException { ModularXmppClientToServerConnectionConfiguration.Builder builder = ModularXmppClientToServerConnectionConfiguration .builder(); - XmppWebsocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebsocketTransportModuleDescriptor.getBuilder(builder); - websocketBuilder.explicitlySetWebsocketEndpointAndDiscovery(new URI("wss://localhost.org:7443/ws/"), false); - return (XmppWebsocketTransportModuleDescriptor) websocketBuilder.build(); + XmppWebSocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebSocketTransportModuleDescriptor.getBuilder(builder); + websocketBuilder.explicitlySetWebSocketEndpointAndDiscovery(new URI("wss://localhost.org:7443/ws/"), false); + return (XmppWebSocketTransportModuleDescriptor) websocketBuilder.build(); } } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebsocketElementTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebSocketElementTest.java similarity index 88% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebsocketElementTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebSocketElementTest.java index 7c00bbeac..3c1bab3ea 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebsocketElementTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/elements/WebSocketElementTest.java @@ -23,20 +23,20 @@ import org.junit.jupiter.api.Test; import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.stringprep.XmppStringprepException; -public class WebsocketElementTest { +public class WebSocketElementTest { private static final String OPEN_ELEMENT = ""; private static final String CLOSE_ELEMENT = ""; @Test public void websocketOpenElementTest() throws XmppStringprepException { - String openElementXml = new WebsocketOpenElement(JidCreate.domainBareFrom("foodomain.foo")).toXML().toString(); + String openElementXml = new WebSocketOpenElement(JidCreate.domainBareFrom("foodomain.foo")).toXML().toString(); assertXmlSimilar(OPEN_ELEMENT, openElementXml); - assertXmlNotSimilar(CLOSE_ELEMENT, new WebsocketOpenElement(JidCreate.domainBareFrom("foodomain.foo")).toXML()); + assertXmlNotSimilar(CLOSE_ELEMENT, new WebSocketOpenElement(JidCreate.domainBareFrom("foodomain.foo")).toXML()); } @Test public void websocketCloseElementTest() throws XmppStringprepException { - String closeElementXml = new WebsocketCloseElement().toXML().toString(); + String closeElementXml = new WebSocketCloseElement().toXML().toString(); assertXmlSimilar(CLOSE_ELEMENT, closeElementXml); assertXmlNotSimilar(OPEN_ELEMENT, closeElementXml); } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocketTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java similarity index 81% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocketTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java index c1e11e6df..67c785231 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebsocketTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java @@ -22,26 +22,26 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -public final class AbstractWebsocketTest { +public final class AbstractWebSocketTest { private static final String OPEN_ELEMENT = ""; private static final String OPEN_STREAM = ""; private static final String CLOSE_ELEMENT = ""; @Test public void getStreamFromOpenElementTest() { - String generatedOpenStream = AbstractWebsocket.getStreamFromOpenElement(OPEN_ELEMENT); + String generatedOpenStream = AbstractWebSocket.getStreamFromOpenElement(OPEN_ELEMENT); assertEquals(generatedOpenStream, OPEN_STREAM); } @Test public void isOpenElementTest() { - assertTrue(AbstractWebsocket.isOpenElement(OPEN_ELEMENT)); - assertFalse(AbstractWebsocket.isOpenElement(OPEN_STREAM)); + assertTrue(AbstractWebSocket.isOpenElement(OPEN_ELEMENT)); + assertFalse(AbstractWebSocket.isOpenElement(OPEN_STREAM)); } @Test public void isCloseElementTest() { - assertTrue(AbstractWebsocket.isCloseElement(CLOSE_ELEMENT)); - assertFalse(AbstractWebsocket.isCloseElement(OPEN_STREAM)); + assertTrue(AbstractWebSocket.isCloseElement(CLOSE_ELEMENT)); + assertFalse(AbstractWebSocket.isCloseElement(OPEN_STREAM)); } } diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointTest.java similarity index 85% rename from smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointTest.java rename to smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointTest.java index 534f99de2..075abc7c4 100644 --- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebsocketRemoteConnectionEndpointTest.java +++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/rce/WebSocketRemoteConnectionEndpointTest.java @@ -25,21 +25,21 @@ import org.jivesoftware.smack.datatypes.UInt16; import org.junit.jupiter.api.Test; -public class WebsocketRemoteConnectionEndpointTest { +public class WebSocketRemoteConnectionEndpointTest { @Test public void endpointTest() throws URISyntaxException { String endpointString = "ws://fooDomain.org:7070/ws/"; - WebsocketRemoteConnectionEndpoint endpoint = new WebsocketRemoteConnectionEndpoint(endpointString); + WebSocketRemoteConnectionEndpoint endpoint = new WebSocketRemoteConnectionEndpoint(endpointString); assertEquals("fooDomain.org", endpoint.getHost()); assertEquals(UInt16.from(7070), endpoint.getPort()); - assertEquals(endpointString, endpoint.getWebsocketEndpoint().toString()); + assertEquals(endpointString, endpoint.getWebSocketEndpoint().toString()); } @Test public void faultyEndpointTest() { String faultyProtocolString = "wst://fooDomain.org:7070/ws/"; assertThrows(IllegalArgumentException.class, () -> { - new WebsocketRemoteConnectionEndpoint(faultyProtocolString); + new WebSocketRemoteConnectionEndpoint(faultyProtocolString); }); } } diff --git a/smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebsocketFactoryServiceTestUtil.java b/smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebSocketFactoryServiceTestUtil.java similarity index 74% rename from smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebsocketFactoryServiceTestUtil.java rename to smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebSocketFactoryServiceTestUtil.java index 1f4a29e60..ddafb5bf2 100644 --- a/smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebsocketFactoryServiceTestUtil.java +++ b/smack-websocket/src/testFixtures/java/org/jivesoftware/smack/websocket/test/WebSocketFactoryServiceTestUtil.java @@ -21,15 +21,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; -import org.jivesoftware.smack.websocket.impl.AbstractWebsocket; -import org.jivesoftware.smack.websocket.impl.WebsocketFactoryService; +import org.jivesoftware.smack.websocket.impl.AbstractWebSocket; +import org.jivesoftware.smack.websocket.impl.WebSocketFactoryService; -public class WebsocketFactoryServiceTestUtil { +public class WebSocketFactoryServiceTestUtil { - public static void createWebsocketTest(Class expected) { + public static void createWebSocketTest(Class expected) { ModularXmppClientToServerConnectionInternal connectionInternal = mock(ModularXmppClientToServerConnectionInternal.class); - AbstractWebsocket websocket = WebsocketFactoryService.createWebsocket(connectionInternal); + AbstractWebSocket websocket = WebSocketFactoryService.createWebSocket(connectionInternal); assertEquals(expected, websocket.getClass()); }