You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/12/26 00:38:30 UTC

svn commit: r1425790 - /tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java

Author: markt
Date: Tue Dec 25 23:38:30 2012
New Revision: 1425790

URL: http://svn.apache.org/viewvc?rev=1425790&view=rev
Log:
More refactoring prior to added new tests

Modified:
    tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java

Modified: tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java?rev=1425790&r1=1425789&r2=1425790&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/websocket/TestUtf8.java Tue Dec 25 23:38:30 2012
@@ -36,36 +36,44 @@ public class TestUtf8 {
 
 
     @Test
-    public void testJvmDecoder1() throws Exception {
+    public void testJvmDecoder1() {
+        // This should trigger an error but currently passes. Once the JVM is#
+        // fixed, s/false/true/
+        doJvmDecoder(SRC_BYTES_1, false);
+    }
+
+
+    private void doJvmDecoder(byte[] src, boolean errorExpected) {
         CharsetDecoder decoder = B2CConverter.UTF_8.newDecoder()
                 .onMalformedInput(CodingErrorAction.REPORT)
                 .onUnmappableCharacter(CodingErrorAction.REPORT);
 
 
-        ByteBuffer bb = ByteBuffer.wrap(SRC_BYTES_1);
+        ByteBuffer bb = ByteBuffer.wrap(src);
         CharBuffer cb = CharBuffer.allocate(bb.limit());
 
         CoderResult cr = decoder.decode(bb, cb, true);
-        // if (!cr.isError()) {
-        if (cr.isError()) {
-            // This should fail but currently passes. Once this test fails, the
-            // JVM has been fixed and the commented out if statement above can
-            // be used.
+        if (cr.isError() != errorExpected) {
             fail();
         }
     }
 
+
     @Test
-    public void testHarmonyDecoder1() throws Exception {
+    public void testHarmonyDecoder1() {
+        doHarmonyDecoder(SRC_BYTES_1, true);
+    }
+
 
+    public void doHarmonyDecoder(byte[] src, boolean errorExpected) {
         CharsetDecoder decoder = new Utf8Decoder();
 
-        ByteBuffer bb = ByteBuffer.wrap(SRC_BYTES_1);
+        ByteBuffer bb = ByteBuffer.wrap(src);
         CharBuffer cb = CharBuffer.allocate(bb.limit());
 
         CoderResult cr = decoder.decode(bb, cb, true);
         // Confirm the custom decoder correctly reports an error
-        if (!cr.isError()) {
+        if (cr.isError() != errorExpected) {
             fail();
         }
     }



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