You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2013/04/10 12:11:00 UTC

[1/5] git commit: o Fixed an infinite loop when the buffer is empty while decoding o Formatted the code using the Java extended formatter

Updated Branches:
  refs/heads/trunk 91260fe3a -> 239902793


o Fixed an infinite loop when the buffer is empty while decoding
o Formatted the code using the Java extended formatter

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/f2745858
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/f2745858
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/f2745858

Branch: refs/heads/trunk
Commit: f274585830c82da8e989b45707472b7777f9207a
Parents: 9d151a5
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Apr 10 11:47:57 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Apr 10 11:47:57 2013 +0200

----------------------------------------------------------------------
 .../apache/mina/codec/textline/LineDelimiter.java  |   13 +------------
 .../mina/codec/textline/TextLineDecoder.java       |   15 +++++++++++----
 2 files changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/f2745858/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java b/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
index c6f858a..bc74f38 100644
--- a/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
+++ b/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
@@ -19,9 +19,6 @@
  */
 package org.apache.mina.codec.textline;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-
 /**
  * A delimiter which is appended to the end of a text line, such as
  * <tt>CR/LF</tt>. This class defines default delimiters for various
@@ -36,15 +33,7 @@ import java.io.PrintWriter;
  */
 public class LineDelimiter {
     /** the line delimiter constant of the current O/S. */
-    public static final LineDelimiter DEFAULT;
-
-    /** Compute the default delimiter on he current OS */
-    static {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        PrintWriter out = new PrintWriter(bout, true);
-        out.println();
-        DEFAULT = new LineDelimiter(new String(bout.toByteArray()));
-    }
+    public static final LineDelimiter DEFAULT = new LineDelimiter(System.getProperty("line.separator"));
 
     /**
      * A special line delimiter which is used for auto-detection of

http://git-wip-us.apache.org/repos/asf/mina/blob/f2745858/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
index 845ee24..41a3582 100644
--- a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
+++ b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
@@ -95,7 +95,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
      */
     public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
         if (charset == null) {
-            throw new IllegalArgumentException("charset parameter shuld not be null");
+            throw new IllegalArgumentException("charset parameter should not be null");
         }
 
         if (delimiter == null) {
@@ -169,6 +169,11 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
      * {@inheritDoc}
      */
     public String[] decode(ByteBuffer in, Context ctx) {
+        // Don't do anything if we don't have bytes in the buffer
+        if (!in.hasRemaining()) {
+            return null;
+        }
+
         if (LineDelimiter.AUTO.equals(delimiter)) {
             return decodeAuto(ctx, in);
         } else {
@@ -244,6 +249,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                 } finally {
                     ctx.reset();
                 }
+
                 oldPos = pos;
                 matchCount = 0;
             }
@@ -254,6 +260,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
         ctx.append(in);
 
         ctx.setMatchCount(matchCount);
+
         return decoded.toArray(new String[decoded.size()]);
     }
 
@@ -305,7 +312,6 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                     } finally {
                         ctx.reset();
                     }
-                    
 
                     oldPos = pos;
                     matchCount = 0;
@@ -341,7 +347,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
 
         /** The number of lines found so far */
         private int matchCount = 0;
-        
+
         /**
          * Overflow length
          */
@@ -368,7 +374,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
         public void setMatchCount(int matchCount) {
             this.matchCount = matchCount;
         }
-        
+
         public int getOverflowLength() {
             return overflowLength;
         }
@@ -388,6 +394,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                 buf = b;
             }
         }
+
         public void append(ByteBuffer in) {
             if (buf.position() > maxLineLength - in.remaining()) {
                 overflowLength = buf.position() + in.remaining();


[5/5] git commit: Merge commit '91260fe3a1dd35c39715a670f67c1c2cd95cf564' into trunk

Posted by el...@apache.org.
Merge commit '91260fe3a1dd35c39715a670f67c1c2cd95cf564' into trunk


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/23990279
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/23990279
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/23990279

Branch: refs/heads/trunk
Commit: 2399027933e17f9c9ebfa857e464cbddc1ff37e0
Parents: df8c579 91260fe
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Apr 10 12:10:05 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Apr 10 12:10:05 2013 +0200

----------------------------------------------------------------------
 .../mina/filter/codec/ProtocolCodecFilter.java     |    2 +-
 .../org/apache/mina/session/AbstractIoSession.java |    2 +-
 .../org/apache/mina/transport/tcp/SslTest.java     |   12 ++++--------
 3 files changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[4/5] git commit: Revert "o Fixed an infinite loop when the buffer is empty while decoding"

Posted by el...@apache.org.
Revert "o Fixed an infinite loop when the buffer is empty while decoding"

This reverts commit f274585830c82da8e989b45707472b7777f9207a.


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/df8c5798
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/df8c5798
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/df8c5798

Branch: refs/heads/trunk
Commit: df8c57981b50e1264fa073f205b05a7f362b39a5
Parents: 3ce5c6d
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Apr 10 12:09:48 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Apr 10 12:09:48 2013 +0200

----------------------------------------------------------------------
 .../apache/mina/codec/textline/LineDelimiter.java  |   13 ++++++++++++-
 .../mina/codec/textline/TextLineDecoder.java       |   15 ++++-----------
 2 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/df8c5798/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java b/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
index bc74f38..c6f858a 100644
--- a/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
+++ b/codec/src/main/java/org/apache/mina/codec/textline/LineDelimiter.java
@@ -19,6 +19,9 @@
  */
 package org.apache.mina.codec.textline;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
 /**
  * A delimiter which is appended to the end of a text line, such as
  * <tt>CR/LF</tt>. This class defines default delimiters for various
@@ -33,7 +36,15 @@ package org.apache.mina.codec.textline;
  */
 public class LineDelimiter {
     /** the line delimiter constant of the current O/S. */
-    public static final LineDelimiter DEFAULT = new LineDelimiter(System.getProperty("line.separator"));
+    public static final LineDelimiter DEFAULT;
+
+    /** Compute the default delimiter on he current OS */
+    static {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        PrintWriter out = new PrintWriter(bout, true);
+        out.println();
+        DEFAULT = new LineDelimiter(new String(bout.toByteArray()));
+    }
 
     /**
      * A special line delimiter which is used for auto-detection of

http://git-wip-us.apache.org/repos/asf/mina/blob/df8c5798/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
index 41a3582..845ee24 100644
--- a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
+++ b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
@@ -95,7 +95,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
      */
     public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
         if (charset == null) {
-            throw new IllegalArgumentException("charset parameter should not be null");
+            throw new IllegalArgumentException("charset parameter shuld not be null");
         }
 
         if (delimiter == null) {
@@ -169,11 +169,6 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
      * {@inheritDoc}
      */
     public String[] decode(ByteBuffer in, Context ctx) {
-        // Don't do anything if we don't have bytes in the buffer
-        if (!in.hasRemaining()) {
-            return null;
-        }
-
         if (LineDelimiter.AUTO.equals(delimiter)) {
             return decodeAuto(ctx, in);
         } else {
@@ -249,7 +244,6 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                 } finally {
                     ctx.reset();
                 }
-
                 oldPos = pos;
                 matchCount = 0;
             }
@@ -260,7 +254,6 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
         ctx.append(in);
 
         ctx.setMatchCount(matchCount);
-
         return decoded.toArray(new String[decoded.size()]);
     }
 
@@ -312,6 +305,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                     } finally {
                         ctx.reset();
                     }
+                    
 
                     oldPos = pos;
                     matchCount = 0;
@@ -347,7 +341,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
 
         /** The number of lines found so far */
         private int matchCount = 0;
-
+        
         /**
          * Overflow length
          */
@@ -374,7 +368,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
         public void setMatchCount(int matchCount) {
             this.matchCount = matchCount;
         }
-
+        
         public int getOverflowLength() {
             return overflowLength;
         }
@@ -394,7 +388,6 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
                 buf = b;
             }
         }
-
         public void append(ByteBuffer in) {
             if (buf.position() > maxLineLength - in.remaining()) {
                 overflowLength = buf.position() + in.remaining();


[3/5] git commit: Revert "Fixed teh tests accordingly to the modification made on the decode()"

Posted by el...@apache.org.
Revert "Fixed teh tests accordingly to the modification made on the decode()"

This reverts commit 627387292fad3f1ec56ba60fc89b90ce0ddf4d49.


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/3ce5c6db
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/3ce5c6db
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/3ce5c6db

Branch: refs/heads/trunk
Commit: 3ce5c6db5e5f12c9106e8f5bca2ca8277215c19e
Parents: 6273872
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Apr 10 12:09:16 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Apr 10 12:09:16 2013 +0200

----------------------------------------------------------------------
 .../codec/textline/AutoTextLineDecoderTest.java    |   18 +++++++-------
 .../codec/textline/UnixTextLineDecoderTest.java    |   18 +++++++-------
 .../codec/textline/WindowsTextLineDecoderTest.java |   18 +++++++-------
 3 files changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/3ce5c6db/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
index a08c65b..ca087c4 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
@@ -21,7 +21,6 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -40,9 +39,10 @@ public class AutoTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNull(results);
+        assertNotNull(results);
+        assertEquals(0, results.length);
     }
-
+    
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -52,7 +52,7 @@ public class AutoTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -63,7 +63,7 @@ public class AutoTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -74,7 +74,7 @@ public class AutoTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -96,7 +96,7 @@ public class AutoTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -105,13 +105,13 @@ public class AutoTextLineDecoderTest {
         assertEquals(sb.toString(), results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);

http://git-wip-us.apache.org/repos/asf/mina/blob/3ce5c6db/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
index 7d2eab5..2023187 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
@@ -21,7 +21,6 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -40,9 +39,10 @@ public class UnixTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNull(results);
+        assertNotNull(results);
+        assertEquals(0, results.length);
     }
-
+    
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -52,7 +52,7 @@ public class UnixTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -63,7 +63,7 @@ public class UnixTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -74,7 +74,7 @@ public class UnixTextLineDecoderTest {
         assertEquals("a string\r", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -96,7 +96,7 @@ public class UnixTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -105,13 +105,13 @@ public class UnixTextLineDecoderTest {
         assertEquals(sb.toString(), results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);

http://git-wip-us.apache.org/repos/asf/mina/blob/3ce5c6db/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
index add2cc6..727fd17 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
@@ -21,7 +21,6 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -40,9 +39,10 @@ public class WindowsTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNull(results);
+        assertNotNull(results);
+        assertEquals(0, results.length);
     }
-
+    
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -52,7 +52,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatUnixLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -62,7 +62,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(9, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -73,7 +73,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -95,7 +95,7 @@ public class WindowsTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -103,13 +103,13 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(801, context.getBuffer().position());
     }
-
+    
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 100; ++i) {
+        for(int i=0; i < 100;++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);


[2/5] git commit: Fixed teh tests accordingly to the modification made on the decode() metod, which returns null when the ByteBuffer is empty.

Posted by el...@apache.org.
Fixed teh tests accordingly to the modification made on the decode()
metod, which returns null when the ByteBuffer is empty.

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/62738729
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/62738729
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/62738729

Branch: refs/heads/trunk
Commit: 627387292fad3f1ec56ba60fc89b90ce0ddf4d49
Parents: f274585
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Apr 10 11:51:09 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Apr 10 11:51:09 2013 +0200

----------------------------------------------------------------------
 .../codec/textline/AutoTextLineDecoderTest.java    |   18 +++++++-------
 .../codec/textline/UnixTextLineDecoderTest.java    |   18 +++++++-------
 .../codec/textline/WindowsTextLineDecoderTest.java |   18 +++++++-------
 3 files changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/62738729/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
index ca087c4..a08c65b 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/AutoTextLineDecoderTest.java
@@ -21,6 +21,7 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -39,10 +40,9 @@ public class AutoTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNotNull(results);
-        assertEquals(0, results.length);
+        assertNull(results);
     }
-    
+
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -52,7 +52,7 @@ public class AutoTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -63,7 +63,7 @@ public class AutoTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -74,7 +74,7 @@ public class AutoTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder();
@@ -96,7 +96,7 @@ public class AutoTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -105,13 +105,13 @@ public class AutoTextLineDecoderTest {
         assertEquals(sb.toString(), results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder();
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);

http://git-wip-us.apache.org/repos/asf/mina/blob/62738729/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
index 2023187..7d2eab5 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/UnixTextLineDecoderTest.java
@@ -21,6 +21,7 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -39,10 +40,9 @@ public class UnixTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNotNull(results);
-        assertEquals(0, results.length);
+        assertNull(results);
     }
-    
+
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -52,7 +52,7 @@ public class UnixTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -63,7 +63,7 @@ public class UnixTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -74,7 +74,7 @@ public class UnixTextLineDecoderTest {
         assertEquals("a string\r", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
@@ -96,7 +96,7 @@ public class UnixTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -105,13 +105,13 @@ public class UnixTextLineDecoderTest {
         assertEquals(sb.toString(), results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);

http://git-wip-us.apache.org/repos/asf/mina/blob/62738729/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java b/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
index 727fd17..add2cc6 100644
--- a/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/textline/WindowsTextLineDecoderTest.java
@@ -21,6 +21,7 @@ package org.apache.mina.codec.textline;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 
@@ -39,10 +40,9 @@ public class WindowsTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         String[] results = decoder.decode(ByteBuffer.allocate(0), context);
-        assertNotNull(results);
-        assertEquals(0, results.length);
+        assertNull(results);
     }
-    
+
     @Test
     public void testThatNonLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -52,7 +52,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(8, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatUnixLineTerminatedStringReturnsEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -62,7 +62,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(9, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -73,7 +73,7 @@ public class WindowsTextLineDecoderTest {
         assertEquals("a string", results[0]);
         assertEquals(0, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatContextIsMaintainedBetweenMessages() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
@@ -95,7 +95,7 @@ public class WindowsTextLineDecoderTest {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
@@ -103,13 +103,13 @@ public class WindowsTextLineDecoderTest {
         assertEquals(0, results.length);
         assertEquals(801, context.getBuffer().position());
     }
-    
+
     @Test
     public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
         TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.WINDOWS);
         Context context = decoder.createDecoderState();
         StringBuffer sb = new StringBuffer();
-        for(int i=0; i < 100;++i) {
+        for (int i = 0; i < 100; ++i) {
             sb.append("a string");
         }
         String[] results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);