commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1132387 - /commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Date Sun, 05 Jun 2011 12:36:35 GMT
Author: sebb
Date: Sun Jun  5 12:36:35 2011
New Revision: 1132387

URL: http://svn.apache.org/viewvc?rev=1132387&view=rev
Log:
Simplify and avoid NPE warning

Modified:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java?rev=1132387&r1=1132386&r2=1132387&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Sun Jun  5 12:36:35 2011
@@ -37,9 +37,9 @@ extends TestCase implements TelnetNotifi
      * used in testing for clarity.
      */
     private class TestConnection {
-        TelnetTestSimpleServer server;
-        TelnetClient client;
-        int port;
+        private final TelnetTestSimpleServer server;
+        private final TelnetClient client;
+        private final int port;
         TestConnection(
                 TelnetTestSimpleServer server,
                 TelnetClient client,
@@ -89,6 +89,8 @@ extends TestCase implements TelnetNotifi
                         client = new TelnetClient();
                         // redundant but makes code clearer.
                         client.setReaderThread(true);
+                        client.connect("127.0.0.1", port);
+                        STANDARD = new TestConnection(server, client, port);
                         break;
                     case 1:
                         client = new TelnetClient();
@@ -102,32 +104,21 @@ extends TestCase implements TelnetNotifi
                         client.addOptionHandler(ttopt);
                         client.addOptionHandler(echoopt);
                         client.addOptionHandler(gaopt);
+                        client.connect("127.0.0.1", port);
+                        OPTIONS = new TestConnection(server, client, port);
                         break;
                     case 2:
                         client = new TelnetClient("ANSI");
+                        client.connect("127.0.0.1", port);
+                        ANSI = new TestConnection(server, client, port);
                         break;
                     case 3:
                         client = new TelnetClient();
                         client.setReaderThread(false);
-                        break;
-               }
-               client.connect("127.0.0.1", port);
-               switch (socket) {
-                    case 0:
-                        STANDARD = new TestConnection(server, client, port);
-                        break;
-                    case 1:
-                        OPTIONS = new TestConnection(server, client, port);
-                        break;
-                    case 2:
-                        ANSI = new TestConnection(server, client, port);
-                        break;
-                    case 3:
+                        client.connect("127.0.0.1", port);
                         NOREAD = new TestConnection(server, client, port);
                         break;
-
                }
-
                // only increment socket number on success
                socket++;
            } catch (IOException e) {



Mime
View raw message