Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/utilTests CharacterTranslationTest.java,1.39,1.
Brought to you by:
derrickoswald
From: <der...@us...> - 2004-01-14 03:10:58
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests In directory sc8-pr-cvs1:/tmp/cvs-serv31253 Modified Files: CharacterTranslationTest.java Log Message: Index: CharacterTranslationTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests/CharacterTranslationTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** CharacterTranslationTest.java 14 Jan 2004 02:53:47 -0000 1.39 --- CharacterTranslationTest.java 14 Jan 2004 03:10:55 -0000 1.40 *************** *** 153,241 **** } ! public byte[] encodedecode (byte[] bytes) ! throws ! IOException ! { ! InputStream in; ! ByteArrayOutputStream out; ! ! // encode ! in = new ByteArrayInputStream (bytes); ! out = new ByteArrayOutputStream (); ! Translate.encode (in, new PrintStream (out)); ! in.close (); ! out.close (); ! ! // decode ! in = new ByteArrayInputStream (out.toByteArray ()); ! out = new ByteArrayOutputStream (); ! Translate.decode (in, new PrintStream (out)); ! in.close (); ! out.close (); ! ! return (out.toByteArray ()); ! } ! ! public void check (byte[] reference, byte[] result) ! throws ! IOException ! { ! InputStream ref; ! InputStream in; ! int i; ! int i1; ! int i2; ! ! ref = new ByteArrayInputStream (reference); ! in = new ByteArrayInputStream (result); ! i = 0; ! do ! { ! i1 = ref.read (); ! i2 = in.read (); ! if (i1 != i2) ! fail ("byte difference detected at offset " + i); ! i++; ! } ! while (-1 != i1); ! ref.close (); ! in.close (); ! } ! ! // public void testInitialCharacterEntityReferenceCodec () // throws // IOException // { ! // byte[] data = "\u00f7 is the division sign.".getBytes (); ! // check (data, encodedecode (data)); // } - - public void testEncodeDecodePage () throws IOException - { - URL url; - URLConnection connection; - InputStream in; - ByteArrayOutputStream out; - byte[] bytes; - byte[] result; - int c; - - // get some bytes - url = new URL ("http://sourceforge.net/projects/htmlparser"); - connection = url.openConnection (); - in = connection.getInputStream (); - out = new ByteArrayOutputStream (); - while (-1 != (c = in.read ())) - out.write (c); - in.close (); - out.close (); - bytes = out.toByteArray (); - - // run it through - result = encodedecode (bytes); - - // check - check (bytes, result); - } } --- 153,241 ---- } ! // public byte[] encodedecode (byte[] bytes) // throws // IOException // { ! // InputStream in; ! // ByteArrayOutputStream out; ! // ! // // encode ! // in = new ByteArrayInputStream (bytes); ! // out = new ByteArrayOutputStream (); ! // Translate.encode (in, new PrintStream (out)); ! // in.close (); ! // out.close (); ! // ! // // decode ! // in = new ByteArrayInputStream (out.toByteArray ()); ! // out = new ByteArrayOutputStream (); ! // Translate.decode (in, new PrintStream (out)); ! // in.close (); ! // out.close (); ! // ! // return (out.toByteArray ()); ! // } ! // ! // public void check (byte[] reference, byte[] result) ! // throws ! // IOException ! // { ! // InputStream ref; ! // InputStream in; ! // int i; ! // int i1; ! // int i2; ! // ! // ref = new ByteArrayInputStream (reference); ! // in = new ByteArrayInputStream (result); ! // i = 0; ! // do ! // { ! // i1 = ref.read (); ! // i2 = in.read (); ! // if (i1 != i2) ! // fail ("byte difference detected at offset " + i); ! // i++; ! // } ! // while (-1 != i1); ! // ref.close (); ! // in.close (); ! // } ! // ! //// public void testInitialCharacterEntityReferenceCodec () ! //// throws ! //// IOException ! //// { ! //// byte[] data = "\u00f7 is the division sign.".getBytes (); ! //// check (data, encodedecode (data)); ! //// } ! // ! // public void testEncodeDecodePage () throws IOException ! // { ! // URL url; ! // URLConnection connection; ! // InputStream in; ! // ByteArrayOutputStream out; ! // byte[] bytes; ! // byte[] result; ! // int c; ! // ! // // get some bytes ! // url = new URL ("http://sourceforge.net/projects/htmlparser"); ! // connection = url.openConnection (); ! // in = connection.getInputStream (); ! // out = new ByteArrayOutputStream (); ! // while (-1 != (c = in.read ())) ! // out.write (c); ! // in.close (); ! // out.close (); ! // bytes = out.toByteArray (); ! // ! // // run it through ! // result = encodedecode (bytes); ! // ! // // check ! // check (bytes, result); // } } |