tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1510276 - /tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
Date Sun, 04 Aug 2013 17:42:15 GMT
Author: markt
Date: Sun Aug  4 17:42:15 2013
New Revision: 1510276

URL: http://svn.apache.org/r1510276
Log:
Better handling on test failure trying to debug failures on OSX with NIO.

Modified:
    tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java

Modified: tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java?rev=1510276&r1=1510275&r2=1510276&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java (original)
+++ tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java Sun Aug  4 17:42:15
2013
@@ -174,13 +174,16 @@ public class TestNonBlockingAPI extends 
             lineStart = lineEnd + 1;
             lineEnd = resultString.indexOf('\n', lineStart);
             System.out.println("Start : "  + lineStart + ", End: " + lineEnd);
-            line = resultString.substring(lineStart, lineEnd + 1);
+            if (lineEnd > lineStart) {
+                line = resultString.substring(lineStart, lineEnd + 1);
+            } else {
+                line = resultString.substring(lineStart);
+            }
             if (line.length() > 40) {
                 System.out.println(line.substring(0, 32));
             } else {
                 System.out.println(line);
                 }
-            Assert.assertTrue(line.endsWith("\r\n"));
             if (chunkSize + 2 != line.length()) {
                 System.out.println("Chunk wrong length. Was " + line.length() +
                         " Expected " + (chunkSize + 2));
@@ -188,12 +191,19 @@ public class TestNonBlockingAPI extends 
                 int pos = 0;
                 String seq = "0123456789ABCDEF";
                 // Assume starts with 0
-                while (line.subSequence(pos, pos + seq.length()).equals(seq)) {
+                while (pos + seq.length() < line.length() &&
+                        line.subSequence(pos, pos + seq.length()).equals(seq)) {
                     pos += seq.length();
                 }
-                System.out.println("Failed at position " + pos + " " +
-                        line.substring(pos, pos + seq.length()));
+                if (pos + seq.length() < line.length()) {
+                    System.out.println("Failed at position " + pos + " " +
+                            line.substring(pos, pos + seq.length()));
+                } else {
+                    System.out.println("Failed at position " + pos + " " +
+                            line.substring(pos));
+                }
             }
+            Assert.assertTrue(line.endsWith("\r\n"));
             Assert.assertEquals(chunkSize + 2, line.length());
 
             totalBodyRead += chunkSize;



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


Mime
View raw message