1 7 package org.jboss.test; 8 9 import junit.framework.TestCase; 10 import junit.framework.TestSuite; 11 12 import org.jboss.security.Util; 13 14 19 public class UtilTestCase extends TestCase 20 { 21 public UtilTestCase(String name) 22 { 23 super(name); 24 } 25 26 28 public void testBase64() throws Exception 29 { 30 System.out.println("testBase64"); 31 byte[] test = "echoman".getBytes(); 32 String b64_1 = Util.encodeBase64(test); 33 System.out.println("b64_1 = "+b64_1); 34 35 sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); 36 String b64_2 = encoder.encode(test); 37 System.out.println("b64_2 = "+b64_2); 38 super.assertEquals("encodeBase64 == BASE64Encoder", b64_1, b64_2); 39 } 40 41 43 public void testBase16() throws Exception 44 { 45 System.out.println("testBase16"); 46 byte[] test = "echoman".getBytes(); 47 String b16_1 = Util.encodeBase16(test); 48 System.out.println("b16_1 = "+b16_1); 49 50 java.math.BigInteger encoder = new java.math.BigInteger (test); 51 String b16_2 = encoder.toString(16); 52 System.out.println("b16_2 = "+b16_2); 53 super.assertEquals("encodeBase16 == BigInteger", b16_1, b16_2); 54 } 55 56 public static void main(java.lang.String [] args) 57 { 58 System.setErr(System.out); 59 TestSuite suite = new TestSuite(UtilTestCase.class); 60 junit.textui.TestRunner.run(suite); 61 } 62 } 63 | Popular Tags |