This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 6364efcb63 Code clean-up. Formatting. No functional change.
6364efcb63 is described below

commit 6364efcb635f46279c1fb40fcdf03f5a0011aed6
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Mar 8 18:27:34 2023 +0000

    Code clean-up. Formatting. No functional change.
---
 .../websocket/pojo/TestEncodingDecoding.java       | 128 ++++++++++-----------
 .../websocket/pojo/TestPojoEndpointBase.java       |  11 +-
 .../websocket/pojo/TestPojoMethodMapping.java      |  23 ++--
 .../apache/tomcat/websocket/pojo/TesterUtil.java   |   3 +-
 4 files changed, 77 insertions(+), 88 deletions(-)

diff --git a/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java 
b/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java
index b3166be31a..597b240e34 100644
--- a/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java
+++ b/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java
@@ -74,7 +74,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
 
     @Test
-    public void testProgrammaticEndPoints() throws Exception{
+    public void testProgrammaticEndPoints() throws Exception {
         Tomcat tomcat = getTomcatInstance();
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -96,8 +96,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         // Should not take very long
         int i = 0;
         while (i < WAIT_LOOPS) {
-            if (MsgStringMessageHandler.received.size() > 0 &&
-                    client.received.size() > 0) {
+            if (MsgStringMessageHandler.received.size() > 0 && 
client.received.size() > 0) {
                 break;
             }
             i++;
@@ -109,10 +108,8 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Assert.assertEquals(1, client.received.size());
 
         // Check correct messages were received
-        Assert.assertEquals(MESSAGE_ONE,
-                ((MsgString) 
MsgStringMessageHandler.received.peek()).getData());
-        Assert.assertEquals(MESSAGE_ONE,
-                new String(((MsgByte) client.received.peek()).getData()));
+        Assert.assertEquals(MESSAGE_ONE, ((MsgString) 
MsgStringMessageHandler.received.peek()).getData());
+        Assert.assertEquals(MESSAGE_ONE, new String(((MsgByte) 
client.received.peek()).getData()));
         session.close();
     }
 
@@ -131,8 +128,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
         tomcat.start();
 
@@ -159,21 +155,19 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Assert.assertEquals(1, client.received.size());
 
         // Check correct messages were received
-        Assert.assertEquals(MESSAGE_ONE,
-                ((MsgString) server.received.peek()).getData());
-        Assert.assertEquals(MESSAGE_ONE,
-                ((MsgString) client.received.peek()).getData());
+        Assert.assertEquals(MESSAGE_ONE, ((MsgString) 
server.received.peek()).getData());
+        Assert.assertEquals(MESSAGE_ONE, ((MsgString) 
client.received.peek()).getData());
         session.close();
 
         // Should not take very long but some failures have been seen
-        i = testEvent(MsgStringEncoder.class.getName()+":init", 0);
-        i = testEvent(MsgStringDecoder.class.getName()+":init", i);
-        i = testEvent(MsgByteEncoder.class.getName()+":init", i);
-        i = testEvent(MsgByteDecoder.class.getName()+":init", i);
-        i = testEvent(MsgStringEncoder.class.getName()+":destroy", i);
-        i = testEvent(MsgStringDecoder.class.getName()+":destroy", i);
-        i = testEvent(MsgByteEncoder.class.getName()+":destroy", i);
-        i = testEvent(MsgByteDecoder.class.getName()+":destroy", i);
+        i = testEvent(MsgStringEncoder.class.getName() + ":init", 0);
+        i = testEvent(MsgStringDecoder.class.getName() + ":init", i);
+        i = testEvent(MsgByteEncoder.class.getName() + ":init", i);
+        i = testEvent(MsgByteDecoder.class.getName() + ":init", i);
+        i = testEvent(MsgStringEncoder.class.getName() + ":destroy", i);
+        i = testEvent(MsgStringDecoder.class.getName() + ":destroy", i);
+        i = testEvent(MsgByteEncoder.class.getName() + ":destroy", i);
+        i = testEvent(MsgByteDecoder.class.getName() + ":destroy", i);
     }
 
 
@@ -191,8 +185,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
         tomcat.start();
 
@@ -240,8 +233,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
         tomcat.start();
 
@@ -287,8 +279,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
         tomcat.start();
 
@@ -334,7 +325,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
     }
 
 
-    @ClientEndpoint(decoders=ListStringDecoder.class, 
encoders=ListStringEncoder.class)
+    @ClientEndpoint(decoders = ListStringDecoder.class, encoders = 
ListStringEncoder.class)
     public static class GenericsClient {
         private final Queue<Object> received = new ConcurrentLinkedQueue<>();
 
@@ -345,8 +336,8 @@ public class TestEncodingDecoding extends TomcatBaseTest {
     }
 
 
-    @ClientEndpoint(decoders={MsgStringDecoder.class, MsgByteDecoder.class},
-            encoders={MsgStringEncoder.class, MsgByteEncoder.class})
+    @ClientEndpoint(decoders = { MsgStringDecoder.class, MsgByteDecoder.class 
}, encoders = { MsgStringEncoder.class,
+            MsgByteEncoder.class })
     public static class Client {
 
         private final Queue<Object> received = new ConcurrentLinkedQueue<>();
@@ -357,7 +348,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         }
 
         @OnMessage
-        public void  rx(MsgByte in) {
+        public void rx(MsgByte in) {
             received.add(in);
         }
     }
@@ -376,10 +367,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
     }
 
 
-    @ServerEndpoint(value=PATH_GENERICS_EP,
-            decoders=ListStringDecoder.class,
-            encoders=ListStringEncoder.class,
-            configurator=SingletonConfigurator.class)
+    @ServerEndpoint(value = PATH_GENERICS_EP, decoders = 
ListStringDecoder.class, encoders = ListStringEncoder.class, configurator = 
SingletonConfigurator.class)
     public static class GenericsServer {
 
         private final Queue<Object> received = new ConcurrentLinkedQueue<>();
@@ -393,8 +381,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
     }
 
 
-    @ServerEndpoint(value=PATH_MESSAGES_EP,
-            configurator=SingletonConfigurator.class)
+    @ServerEndpoint(value = PATH_MESSAGES_EP, configurator = 
SingletonConfigurator.class)
     public static class MessagesServer {
 
         private final Queue<String> received = new ConcurrentLinkedQueue<>();
@@ -415,8 +402,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
     }
 
 
-    @ServerEndpoint(value=PATH_BATCHED_EP,
-            configurator=SingletonConfigurator.class)
+    @ServerEndpoint(value = PATH_BATCHED_EP, configurator = 
SingletonConfigurator.class)
     public static class BatchedServer {
 
         private final Queue<String> received = new ConcurrentLinkedQueue<>();
@@ -438,10 +424,8 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         }
     }
 
-    @ServerEndpoint(value=PATH_ANNOTATED_EP,
-            decoders={MsgStringDecoder.class, MsgByteDecoder.class},
-            encoders={MsgStringEncoder.class, MsgByteEncoder.class},
-            configurator=SingletonConfigurator.class)
+    @ServerEndpoint(value = PATH_ANNOTATED_EP, decoders = { 
MsgStringDecoder.class, MsgByteDecoder.class }, encoders = {
+            MsgStringEncoder.class, MsgByteEncoder.class }, configurator = 
SingletonConfigurator.class)
     public static class Server {
 
         private final Queue<Object> received = new ConcurrentLinkedQueue<>();
@@ -461,19 +445,18 @@ public class TestEncodingDecoding extends TomcatBaseTest {
             return in;
         }
 
-        public static void addLifeCycleEvent(String event){
+        public static void addLifeCycleEvent(String event) {
             lifeCyclesCalled.put(event, Boolean.TRUE);
         }
 
-        public static boolean isLifeCycleEventCalled(String event){
+        public static boolean isLifeCycleEventCalled(String event) {
             Boolean called = lifeCyclesCalled.get(event);
             return called == null ? false : called.booleanValue();
         }
     }
 
 
-    public static class MsgByteMessageHandler implements
-            MessageHandler.Whole<MsgByte> {
+    public static class MsgByteMessageHandler implements 
MessageHandler.Whole<MsgByte> {
 
         public static final Queue<Object> received = new 
ConcurrentLinkedQueue<>();
         private final Session session;
@@ -521,17 +504,23 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
 
     public static class ProgrammaticEndpoint extends Endpoint {
-       @Override
-       public void onOpen(Session session, EndpointConfig config) {
-           session.addMessageHandler(new MsgStringMessageHandler(session));
-       }
+        @Override
+        public void onOpen(Session session, EndpointConfig config) {
+            session.addMessageHandler(new MsgStringMessageHandler(session));
+        }
     }
 
 
     public static class MsgString {
         private volatile String data;
-        public String getData() { return data; }
-        public void setData(String data) { this.data = data; }
+
+        public String getData() {
+            return data;
+        }
+
+        public void setData(String data) {
+            this.data = data;
+        }
     }
 
 
@@ -582,8 +571,14 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
     public static class MsgByte {
         private volatile byte[] data;
-        public byte[] getData() { return data; }
-        public void setData(byte[] data) { this.data = data; }
+
+        public byte[] getData() {
+            return data;
+        }
+
+        public void setData(byte[] data) {
+            this.data = data;
+        }
     }
 
 
@@ -616,7 +611,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
         @Override
         public void init(EndpointConfig endpointConfig) {
-             Server.addLifeCycleEvent(getClass().getName() + ":init");
+            Server.addLifeCycleEvent(getClass().getName() + ":init");
         }
 
         @Override
@@ -661,7 +656,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         public String encode(List<String> str) throws EncodeException {
             StringBuffer sbuf = new StringBuffer();
             sbuf.append('[');
-            for (String s: str){
+            for (String s : str) {
                 sbuf.append(s).append(',');
             }
             sbuf.deleteCharAt(sbuf.lastIndexOf(",")).append(']');
@@ -674,7 +669,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
         @Override
         public void init(EndpointConfig endpointConfig) {
-             Server.addLifeCycleEvent(getClass().getName() + ":init");
+            Server.addLifeCycleEvent(getClass().getName() + ":init");
         }
 
         @Override
@@ -685,7 +680,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         @Override
         public List<String> decode(String str) throws DecodeException {
             List<String> lst = new ArrayList<>(1);
-            str = str.substring(1,str.length()-1);
+            str = str.substring(1, str.length() - 1);
             String[] strings = str.split(",");
             lst.addAll(Arrays.asList(strings));
             return lst;
@@ -703,16 +698,15 @@ public class TestEncodingDecoding extends TomcatBaseTest {
         @Override
         public void contextInitialized(ServletContextEvent sce) {
             super.contextInitialized(sce);
-            ServerContainer sc =
-                    (ServerContainer) sce.getServletContext().getAttribute(
-                            org.apache.tomcat.websocket.server.Constants.
-                            SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
+            ServerContainer sc = (ServerContainer) 
sce.getServletContext().getAttribute(
+                    
org.apache.tomcat.websocket.server.Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
             try {
                 sc.addEndpoint(new ServerEndpointConfig() {
                     @Override
                     public Map<String, Object> getUserProperties() {
                         return Collections.emptyMap();
                     }
+
                     @Override
                     public List<Class<? extends Encoder>> getEncoders() {
                         List<Class<? extends Encoder>> encoders = new 
ArrayList<>(2);
@@ -720,6 +714,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
                         encoders.add(MsgByteEncoder.class);
                         return encoders;
                     }
+
                     @Override
                     public List<Class<? extends Decoder>> getDecoders() {
                         List<Class<? extends Decoder>> decoders = new 
ArrayList<>(2);
@@ -727,22 +722,27 @@ public class TestEncodingDecoding extends TomcatBaseTest {
                         decoders.add(MsgByteDecoder.class);
                         return decoders;
                     }
+
                     @Override
                     public List<String> getSubprotocols() {
                         return Collections.emptyList();
                     }
+
                     @Override
                     public String getPath() {
                         return PATH_PROGRAMMATIC_EP;
                     }
+
                     @Override
                     public List<Extension> getExtensions() {
                         return Collections.emptyList();
                     }
+
                     @Override
                     public Class<?> getEndpointClass() {
                         return ProgrammaticEndpoint.class;
                     }
+
                     @Override
                     public Configurator getConfigurator() {
                         return new ServerEndpointConfig.Configurator() {
@@ -757,7 +757,7 @@ public class TestEncodingDecoding extends TomcatBaseTest {
 
 
     @Test
-    public void testUnsupportedObject() throws Exception{
+    public void testUnsupportedObject() throws Exception {
         Tomcat tomcat = getTomcatInstance();
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
diff --git a/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java 
b/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java
index 2177ac44f5..503640019c 100644
--- a/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java
+++ b/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java
@@ -58,8 +58,7 @@ public class TestPojoEndpointBase extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
 
         tomcat.start();
@@ -89,8 +88,7 @@ public class TestPojoEndpointBase extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
 
         tomcat.start();
@@ -109,15 +107,14 @@ public class TestPojoEndpointBase extends TomcatBaseTest {
     public static class OnOpenServerEndpoint {
 
         @OnOpen
-        public void onOpen(@SuppressWarnings("unused") Session session,
-                EndpointConfig config) {
+        public void onOpen(@SuppressWarnings("unused") Session session, 
EndpointConfig config) {
             if (config == null) {
                 throw new RuntimeException();
             }
         }
 
         @OnError
-        public void onError(@SuppressWarnings("unused") Throwable t){
+        public void onError(@SuppressWarnings("unused") Throwable t) {
             throw new RuntimeException();
         }
     }
diff --git a/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java 
b/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java
index 14b916d28c..8ac63dd56e 100644
--- a/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java
+++ b/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java
@@ -61,15 +61,13 @@ public class TestPojoMethodMapping extends TomcatBaseTest {
         Tomcat.addServlet(ctx, "default", new DefaultServlet());
         ctx.addServletMappingDecoded("/", "default");
 
-        WebSocketContainer wsContainer =
-                ContainerProvider.getWebSocketContainer();
+        WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
 
 
         tomcat.start();
 
         SimpleClient client = new SimpleClient();
-        URI uri = new URI("ws://localhost:" + getPort() + "/" + PARAM_ONE +
-                "/" + PARAM_TWO + "/" + PARAM_THREE);
+        URI uri = new URI("ws://localhost:" + getPort() + "/" + PARAM_ONE + 
"/" + PARAM_TWO + "/" + PARAM_THREE);
 
         Session session = wsContainer.connectToServer(client, uri);
         session.getBasicRemote().sendText("NO-OP");
@@ -98,29 +96,25 @@ public class TestPojoMethodMapping extends TomcatBaseTest {
     }
 
 
-    @ServerEndpoint(value="/{one}/{two}/{three}",
-            configurator=SingletonConfigurator.class)
+    @ServerEndpoint(value = "/{one}/{two}/{three}", configurator = 
SingletonConfigurator.class)
     public static final class Server {
 
         private final List<String> errors = new ArrayList<>();
         private volatile boolean closed;
 
         @OnOpen
-        public void onOpen(@PathParam("one") String p1, @PathParam("two")int 
p2,
-                @PathParam("three")boolean p3) {
+        public void onOpen(@PathParam("one") String p1, @PathParam("two") int 
p2, @PathParam("three") boolean p3) {
             checkParams("onOpen", p1, p2, p3);
         }
 
         @OnMessage
-        public void onMessage(@SuppressWarnings("unused") String msg,
-                @PathParam("one") String p1, @PathParam("two")int p2,
-                @PathParam("three")boolean p3) {
+        public void onMessage(@SuppressWarnings("unused") String msg, 
@PathParam("one") String p1,
+                @PathParam("two") int p2, @PathParam("three") boolean p3) {
             checkParams("onMessage", p1, p2, p3);
         }
 
         @OnClose
-        public void onClose(@PathParam("one") String p1,
-                @PathParam("two")int p2, @PathParam("three")boolean p3) {
+        public void onClose(@PathParam("one") String p1, @PathParam("two") int 
p2, @PathParam("three") boolean p3) {
             checkParams("onClose", p1, p2, p3);
             closed = true;
         }
@@ -141,8 +135,7 @@ public class TestPojoMethodMapping extends TomcatBaseTest {
 
         private void checkParam(String method, String expected, String actual) 
{
             if (!expected.equals(actual)) {
-                errors.add("Method [" + method + "]. Expected [" + expected +
-                        "] was + [" + actual + "]");
+                errors.add("Method [" + method + "]. Expected [" + expected + 
"] was + [" + actual + "]");
             }
         }
     }
diff --git a/test/org/apache/tomcat/websocket/pojo/TesterUtil.java 
b/test/org/apache/tomcat/websocket/pojo/TesterUtil.java
index 4c5db6d45e..ee48faffa1 100644
--- a/test/org/apache/tomcat/websocket/pojo/TesterUtil.java
+++ b/test/org/apache/tomcat/websocket/pojo/TesterUtil.java
@@ -48,8 +48,7 @@ public class TesterUtil {
         }
 
         @Override
-        public <T> T getEndpointInstance(Class<T> clazz)
-                throws InstantiationException {
+        public <T> T getEndpointInstance(Class<T> clazz) throws 
InstantiationException {
             @SuppressWarnings("unchecked")
             T result = (T) instance;
             return result;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to