jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/http/test HTTPMessageGeneratorTestCase.java,1.1,1.2 HTTPParserImplTestCase.java,1.5,1.6

[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/http/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2537/components/http/impl/src/test/org/jicarilla/http/test

Modified Files:
	HTTPMessageGeneratorTestCase.java HTTPParserImplTestCase.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: HTTPMessageGeneratorTestCase.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/http/test/HTTPMessageGeneratorTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- HTTPMessageGeneratorTestCase.java	19 Jan 2004 21:58:08 -0000	1.1
+++ HTTPMessageGeneratorTestCase.java	26 Feb 2004 16:51:55 -0000	1.2
@@ -118,7 +118,7 @@
         generator.setMessage( null );
         assertNull( generator.getMessage() );
 
-        HTTPMessage msg = new HTTPMessage();
+        final HTTPMessage msg = new HTTPMessage();
         generator.setMessage( msg );
         assertEquals( msg, generator.getMessage() );
 

Index: HTTPParserImplTestCase.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/http/test/HTTPParserImplTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- HTTPParserImplTestCase.java	19 Feb 2004 17:28:40 -0000	1.5
+++ HTTPParserImplTestCase.java	26 Feb 2004 16:51:55 -0000	1.6
@@ -57,15 +57,15 @@
     // ----------------------------------------------------------------------
     //  Properties
     // ----------------------------------------------------------------------
-    HTTPHandler handler;
-    HTTPErrorHandler errorHandler;
-    HTTPParser parser;
+    protected HTTPHandler handler;
+    protected HTTPErrorHandler errorHandler;
+    protected HTTPParser parser;
 
-    MockControl handlerControl;
-    MockControl errorHandlerControl;
+    protected MockControl handlerControl;
+    protected MockControl errorHandlerControl;
 
-    InputStream stream;
-    ReadableByteChannel channel;
+    protected InputStream stream;
+    protected ReadableByteChannel channel;
 
     // ----------------------------------------------------------------------
     //  Set up and tear down
@@ -139,9 +139,10 @@
                 -10
         );
 
+        int tooBigForSure = 100;
         parser.parse(
                 NioUtil.toByteBuffer( "GET "),
-                100
+                tooBigForSure
         );
     }
 
@@ -205,7 +206,7 @@
 
     public void testParseForwardsHandlerException() throws Exception
     {
-        RuntimeException ex = new RuntimeException();
+        final RuntimeException ex = new RuntimeException();
 
         handler.newMessage();
         handler.foundStartLineFirstField( NioUtil.toByteBuffer( "GET" ) );
@@ -246,7 +247,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
@@ -290,7 +291,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
 "GET / HTTP/1.1" + HTTPEncoding.CR + HTTPEncoding.LF +
 "Host: localhost:8080" + HTTPEncoding.CR + HTTPEncoding.LF +
 "User-Agent:      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624" + HTTPEncoding.CR + HTTPEncoding.LF +
@@ -324,7 +325,7 @@
 
         errorHandlerControl.replay();
 
-        String request = "WEIRDUNKNOWNMETHOD /some=contrived?but/valid%20URLRRLRLR/&thisisFun HTTP/10.12" +
+        final String request = "WEIRDUNKNOWNMETHOD /some=contrived?but/valid%20URLRRLRLR/&thisisFun HTTP/10.12" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
 
@@ -345,7 +346,7 @@
 
         errorHandlerControl.replay();
 
-        String request = "HTTP/1.0 200 OK" + HTTPEncoding.CR + HTTPEncoding.LF;
+        final String request = "HTTP/1.0 200 OK" + HTTPEncoding.CR + HTTPEncoding.LF;
 
         doParse( request );
 
@@ -364,7 +365,7 @@
 
         errorHandlerControl.replay();
 
-        String request = "HTTP/13.140 800 Custom Status Code" + HTTPEncoding.CR + HTTPEncoding.LF;
+        final String request = "HTTP/13.140 800 Custom Status Code" + HTTPEncoding.CR + HTTPEncoding.LF;
         doParse( request );
 
         errorHandlerControl.verify();
@@ -407,7 +408,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "A: b" +
@@ -456,7 +457,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost:8080" +
@@ -489,7 +490,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost:8080" +
@@ -527,7 +528,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost:8080" +
@@ -568,7 +569,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost:8080" +
@@ -597,7 +598,7 @@
 
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
                 "" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF +
@@ -626,7 +627,7 @@
         //errorHandler.exceptionOccurred( new HTTPException() );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost:8080" +
@@ -690,7 +691,7 @@
 
         errorHandlerControl.replay();
 
-        String[] request = new String[]
+        final String[] request = new String[]
         {
             "GE", "T /", " HTT", "P", "/1.0",
                 ""+HTTPEncoding.CR,
@@ -699,7 +700,7 @@
         };
         for( int i = 0; i < request.length; i++ )
         {
-            String s = request[i];
+            final String s = request[i];
             doParse( s );
         }
 
@@ -741,7 +742,7 @@
 
         errorHandlerControl.replay();
 
-        String[] request = new String[]
+        final String[] request = new String[]
         {
             "GE", "T /", " HTT", "P", "/1.1",
                 ""+HTTPEncoding.CR,
@@ -767,7 +768,7 @@
         };
         for( int i = 0; i < request.length; i++ )
         {
-            String s = request[i];
+            final String s = request[i];
             doParse( s );
         }
 
@@ -796,7 +797,7 @@
 
         errorHandlerControl.replay();
 
-        String[] request = new String[]
+        final String[] request = new String[]
         {
                 "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
@@ -812,7 +813,7 @@
         };
         for( int i = 0; i < request.length; i++ )
         {
-            String s = request[i];
+            final String s = request[i];
             doParse( s );
         }
 
@@ -830,14 +831,14 @@
         handler.newMessage();
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GE" + Iso646.BELL + "T / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
@@ -860,14 +861,14 @@
         handler.foundStartLineFirstField( NioUtil.toByteBuffer( "GET" ) );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET /" + Iso646.BELL + "bla HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
@@ -891,14 +892,14 @@
         handler.foundStartLineSecondField( NioUtil.toByteBuffer( "/" ) );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HT" + Iso646.BELL + "TP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
@@ -921,14 +922,14 @@
         handler.foundStartLineFirstField( NioUtil.toByteBuffer( "GET" ) );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET " +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 HTTPEncoding.CR + HTTPEncoding.LF;
@@ -953,14 +954,14 @@
         handler.foundStartLineThirdField( NioUtil.toByteBuffer( "HTTP/1.0" ) );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Ho" + Iso646.CANCEL + "st: localhost" +
@@ -987,14 +988,14 @@
         handler.foundHeaderName( NioUtil.toByteBuffer( "Host" ) );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_400_Bad_Request
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: local" + Iso646.BACKSPACE + "host" +
@@ -1026,14 +1027,14 @@
         handlerControl.setReturnValue( -10 );
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_411_Length_Required
         );
         errorHandler.exceptionOccurred( ex );
         errorHandlerControl.setThrowable( ex );
         errorHandlerControl.replay();
 
-        String request =
+        final String request =
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost" +
@@ -1056,7 +1057,7 @@
     {
         handlerControl.replay();
 
-        HTTPException ex = new HTTPException(
+        final HTTPException ex = new HTTPException(
                 HTTPEncoding.STATUS_413_Request_Entity_Too_Large
         );
         errorHandler.exceptionOccurred( ex );
@@ -1067,7 +1068,8 @@
             "GET / HTTP/1.0" +
                 HTTPEncoding.CR + HTTPEncoding.LF +
                 "Host: localhost";
-        byte[] garbage = new byte[10005];
+        int garabageSize = 10005;
+        final byte[] garbage = new byte[garabageSize];
         for( int i = 0; i < garbage.length; i++ )
             garbage[i] = Iso646.LATIN_CAPITAL_LETTER_A;
 
@@ -1080,7 +1082,6 @@
         }
         catch( HTTPException th )
         {
-            System.out.println( th.getMessage() );
         }
 
         errorHandlerControl.verify();
@@ -1091,39 +1092,40 @@
     //  Helper Methods
     // ----------------------------------------------------------------------
 
-    protected ByteBuffer createBuffer( String request ) throws Exception
+    protected ByteBuffer createBuffer( final String request ) throws Exception
     {
         stream = new StringBufferInputStream( request );
         channel = Channels.newChannel( stream );
 
-        ByteBuffer buf = ByteBuffer.allocate( request.length() );
+        final ByteBuffer buf = ByteBuffer.allocate( request.length() );
 
-        int read = channel.read( buf );
+        final int read = channel.read( buf );
         buf.limit( read );
         buf.rewind();
 
         return buf;
     }
 
-    protected void doParse( String request ) throws Exception
+    protected void doParse( final String request ) throws Exception
     {
         parser.parse( createBuffer( request ) );
     }
 
-    protected void doParseFile( String fileName ) throws Exception
+    private final static int BUFFER_SIZE = 2^14;
+    protected void doParseFile( final String fileName ) throws Exception
     {
-        File f = new File("");
-        FileInputStream stream = new FileInputStream( f.getAbsolutePath() + "/src/test/com/leosimons/http/test/request.log");
-        FileChannel streamChannel = stream.getChannel();
+        final File f = new File("");
+        final FileInputStream stream = new FileInputStream( f.getAbsolutePath() + "/src/test/com/leosimons/http/test/request.log");
+        final FileChannel streamChannel = stream.getChannel();
 
-        ByteBuffer buf = ByteBuffer.allocate( 2^14 );
+        ByteBuffer buf = ByteBuffer.allocate( BUFFER_SIZE );
         int read = 0;
 
         while( (read = streamChannel.read( buf )) != -1 )
         {
             buf.rewind();
             parser.parse( buf, read );
-            buf = ByteBuffer.allocate( 2^14 );
-        };
+            buf = ByteBuffer.allocate( BUFFER_SIZE );
+        }
     }
 }



-------------------------------------------------------
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.