jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/net/test SocketServerImplTestCase.java,1.4,1.5

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/net/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2537/components/http/impl/src/test/org/jicarilla/net/test

Modified Files:
	SocketServerImplTestCase.java 
Log Message:
Ran some code analysis tools on the code and changed approximately 200 small things based on that. Nothing shocking (I hope!)

Index: SocketServerImplTestCase.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/net/test/SocketServerImplTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- SocketServerImplTestCase.java	25 Jan 2004 22:12:49 -0000	1.4
+++ SocketServerImplTestCase.java	26 Feb 2004 16:51:56 -0000	1.5
@@ -56,6 +56,9 @@
  */
 public class SocketServerImplTestCase extends TestCase
 {
+    public final static int port = 8088;
+    public final static int backlog = 50;
+    public final static int threads = 50;
     protected SocketServerConfig conf;
     protected ExceptionListener exceptionListener;
     protected ObjectPool eventPool;
@@ -65,7 +68,7 @@
 
     public void setUp() throws Exception
     {
-        conf = new SocketServerConfig( "localhost", 8088, 50, 50 );
+        conf = new SocketServerConfig( "localhost", port, backlog, threads );
         exceptionListener = new NoopExceptionListener();
         eventPool = new SoftReferenceObjectPool( new EventFactory() );
         channelPool = new SoftReferenceObjectPool( new BasePoolableObjectFactory()
@@ -77,13 +80,13 @@
             });
         errorHandler = new Sink()
             {
-                public void put( Object o )
+                public void put( final Object o )
                 {
-                    Event e = (Event)o;
+                    final Event e = (Event)o;
                     e.getChannel();
                 }
 
-                public boolean offer( Object o, long l )
+                public boolean offer( final Object o, final long l )
                 {
                     return true;
                 }
@@ -94,13 +97,14 @@
     {
     }
 
+    private final static int lifecycleSleepTime = 200;
     public void testLifecycle() throws Throwable
     {
-        SocketServerImpl server = new SocketServerImpl(
+        final SocketServerImpl server = new SocketServerImpl(
                 conf, exceptionListener, eventPool, channelPool, errorHandler, threadPool );
 
         server.initialize();
-        Thread.sleep(200);
+        Thread.sleep(lifecycleSleepTime);
         server.dispose();
     }
 
@@ -126,32 +130,32 @@
         public static SocketChannel s;
         public static int received = 0;
 
-        public void put( Object o ) throws InterruptedException
+        public void put( final Object o ) throws InterruptedException
         {
             received++;
-            Event e = (Event)o;
+            final Event e = (Event)o;
             s = e.getChannel();
         }
 
-        public boolean offer( Object o, long l ) throws InterruptedException
+        public boolean offer( final Object o, final long l ) throws InterruptedException
         {
             received++;
-            Event e = (Event)o;
+            final Event e = (Event)o;
             s = e.getChannel();
             return true;
         }
     }
     protected class SavingSocketServerImpl extends SocketServerImpl
     {
-        public SavingSocketServerImpl( SocketServerConfig conf, ExceptionListener exceptionListener,
-            ObjectPool eventPool, ObjectPool channelPool, Sink errorHandler, PooledExecutor threadPool )
+        protected SavingSocketServerImpl( final SocketServerConfig conf, final ExceptionListener exceptionListener,
+            final ObjectPool eventPool, final ObjectPool channelPool, final Sink errorHandler, final PooledExecutor threadPool )
             throws Exception
         {
             super( conf, exceptionListener, eventPool, channelPool, errorHandler, threadPool );
         }
         public SocketChannel s;
 
-        public void handleRequest( SocketChannel c )
+        public void handleRequest( final SocketChannel c )
                 throws SocketServerException, InterruptedException
         {
             s = c;
@@ -159,6 +163,7 @@
         }
     }
 
+    public final static int sleepTime = 500;
     public void testStageRecievesCorrectChannel() throws Throwable
     {
         //ErrorSink errorHander = new ErrorSink();
@@ -169,25 +174,25 @@
                     return new SavingQueue();
                 }
             });
-        SavingSocketServerImpl server = new SavingSocketServerImpl(
+        final SavingSocketServerImpl server = new SavingSocketServerImpl(
                 conf, exceptionListener, eventPool, channelPool, errorHandler, threadPool );
 
         server.initialize();
 
-        SocketChannel sc = SocketChannel.open();
-        sc.socket().connect( new InetSocketAddress( "localhost", 8088 ) );
-        char[] str = "Hi!".toCharArray();
-        ByteBuffer msg = ByteBuffer.allocate( str.length );
+        final SocketChannel sc = SocketChannel.open();
+        sc.socket().connect( new InetSocketAddress( "localhost", port ) );
+        final char[] str = "Hi!".toCharArray();
+        final ByteBuffer msg = ByteBuffer.allocate( str.length );
         for( int i = 0; i < str.length; i++ )
             msg.put( (byte)str[i] );
         msg.rewind();
         sc.write( msg );
 
-        Thread.sleep(500);
+        Thread.sleep(sleepTime);
 
         server.handleRequest( sc );
 
-        Thread.sleep(500);
+        Thread.sleep(sleepTime);
 
         assertSame( sc, SavingQueue.s );
         assertEquals( 2, SavingQueue.received );



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.