1 24 25 package org.objectweb.cjdbc.scenario.raidb1.driver; 26 27 import org.objectweb.cjdbc.common.sql.filters.AbstractBlobFilter; 28 import org.objectweb.cjdbc.common.sql.filters.HexaBlobFilter; 29 import org.objectweb.cjdbc.common.stream.encoding.ZipEncoding; 30 import org.objectweb.cjdbc.scenario.templates.Template; 31 32 38 public class EncodingScenario extends Template 39 { 40 41 44 protected void setUp() 45 { 46 } 47 48 51 protected void tearDown() 52 { 53 54 } 55 56 62 public void testZipEncoding() throws Exception 63 { 64 String ss = "This is a very long string, please do not cut me"; 65 byte[] zip = ZipEncoding.encode(ss.getBytes()); 66 System.out.println(new String (zip)); 67 byte[] unzip = ZipEncoding.decode(zip); 68 System.out.println(new String (unzip)); 69 assertTrue("Decompressed byte[] is not what expected",ss.equals(new String (unzip))); 70 } 71 72 73 78 public void testCompareEncoding() throws Exception 79 { 80 AbstractBlobFilter filter1 = new HexaBlobFilter(); 81 String ss = "This is a very long string, please do not cut me"; 84 85 String ss1 = filter1.encode(ss); 86 System.out.println(ss1); 87 92 String test1 = new String (filter1.decode(ss1)); 95 System.out.println(test1); 96 101 assertTrue("test1[" + test1 + "]!=original[" + ss + "]", test1 102 .equals(ss)); 103 } 107 108 } 109 | Popular Tags |