[jboss-cvs] jboss-serialization/tests/org/jboss/serial/util ...
Clebert Suconic
csuconic at jboss.com
Tue Sep 19 13:28:37 EDT 2006
User: csuconic
Date: 06/09/19 13:28:37
Modified: tests/org/jboss/serial/util StringUtilTestCase.java
Log:
JBSER-89 Adding testcase
Revision Changes Path
1.4 +48 -1 jboss-serialization/tests/org/jboss/serial/util/StringUtilTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StringUtilTestCase.java
===================================================================
RCS file: /cvsroot/jboss/jboss-serialization/tests/org/jboss/serial/util/StringUtilTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- StringUtilTestCase.java 20 May 2006 03:02:32 -0000 1.3
+++ StringUtilTestCase.java 19 Sep 2006 17:28:37 -0000 1.4
@@ -30,8 +30,11 @@
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
/**
- * $Id: StringUtilTestCase.java,v 1.3 2006/05/20 03:02:32 csuconic Exp $
+ * $Id: StringUtilTestCase.java,v 1.4 2006/09/19 17:28:37 csuconic Exp $
*
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*/
@@ -52,6 +55,50 @@
return producedArray.length-2;
}
+ public void testLargeStringMultiByte() throws Exception
+ {
+ doLargeStringTest(32767, true);
+ }
+
+ public void testLargerStringMultiByte() throws Exception
+ {
+ doLargeStringTest(32768, true);
+ }
+
+
+ protected void doLargeStringTest(int stringSize, boolean multiByteChars) throws Exception
+ {
+ StringBuilder sb = new StringBuilder();
+
+ int startingChar = multiByteChars ? 210 : 65;
+ for (int i = 0; i < stringSize; i++) sb.append((char) (startingChar + (i % 26)));
+
+ String largeString = sb.toString();
+ assertEquals(stringSize, largeString.length());
+
+ ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
+ JBossObjectOutputStream objOut = new JBossObjectOutputStream(byteArray);
+
+ objOut.writeObject(largeString);
+ objOut.close();
+
+ ByteArrayInputStream byteInput = new ByteArrayInputStream(byteArray.toByteArray());
+ JBossObjectInputStream objInp = new JBossObjectInputStream(byteInput);
+
+ String newString = (String)objInp.readObject();
+
+ assertEquals(largeString.length(), newString.length());
+ assertEquals(largeString,newString);
+
+ }
+
+ public void testLargeString() throws Exception
+ {
+
+ }
+
+
+
public void testCalculateLen() throws Exception
{
More information about the jboss-cvs-commits
mailing list