diff options
Diffstat (limited to 'pki/base/util/test')
12 files changed, 444 insertions, 419 deletions
diff --git a/pki/base/util/test/com/netscape/security/util/BMPStringTest.java b/pki/base/util/test/com/netscape/security/util/BMPStringTest.java index 93ce02016..ffe13b238 100644 --- a/pki/base/util/test/com/netscape/security/util/BMPStringTest.java +++ b/pki/base/util/test/com/netscape/security/util/BMPStringTest.java @@ -13,13 +13,13 @@ public class BMPStringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,12 +30,12 @@ public class BMPStringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -44,16 +44,16 @@ public class BMPStringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -64,12 +64,12 @@ public class BMPStringTest { String input = StringTestUtil.NULL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -78,16 +78,16 @@ public class BMPStringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -98,12 +98,12 @@ public class BMPStringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -112,16 +112,16 @@ public class BMPStringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -132,12 +132,12 @@ public class BMPStringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -146,16 +146,16 @@ public class BMPStringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -166,12 +166,12 @@ public class BMPStringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -180,16 +180,16 @@ public class BMPStringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -200,12 +200,12 @@ public class BMPStringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -216,25 +216,27 @@ public class BMPStringTest { System.out.println("Encoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -244,27 +246,29 @@ public class BMPStringTest { System.out.println("Decoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, string); long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/util/IA5StringTest.java b/pki/base/util/test/com/netscape/security/util/IA5StringTest.java index fca7f0103..dd0af242c 100644 --- a/pki/base/util/test/com/netscape/security/util/IA5StringTest.java +++ b/pki/base/util/test/com/netscape/security/util/IA5StringTest.java @@ -15,13 +15,13 @@ public class IA5StringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -32,12 +32,12 @@ public class IA5StringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -46,16 +46,16 @@ public class IA5StringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -66,12 +66,12 @@ public class IA5StringTest { String input = StringTestUtil.NULL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -80,13 +80,13 @@ public class IA5StringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -97,12 +97,12 @@ public class IA5StringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -111,13 +111,13 @@ public class IA5StringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -128,12 +128,12 @@ public class IA5StringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -142,13 +142,13 @@ public class IA5StringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -159,12 +159,12 @@ public class IA5StringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -173,18 +173,18 @@ public class IA5StringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -195,18 +195,18 @@ public class IA5StringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(DerValue.tag_UTF8String, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); System.out.println(" - expected: IOException"); try { String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -217,24 +217,26 @@ public class IA5StringTest { System.out.println("Encoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS; long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -244,26 +246,28 @@ public class IA5StringTest { System.out.println("Decoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, string); long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/util/JSSUtil.java b/pki/base/util/test/com/netscape/security/util/JSSUtil.java index fc899d560..bbbabbf14 100644 --- a/pki/base/util/test/com/netscape/security/util/JSSUtil.java +++ b/pki/base/util/test/com/netscape/security/util/JSSUtil.java @@ -19,26 +19,26 @@ public class JSSUtil { ASN1Value value; switch (tag) { - case DerValue.tag_BMPString: - value = new BMPString(string); - break; - case DerValue.tag_IA5String: - value = new IA5String(string); - break; - case DerValue.tag_PrintableString: - value = new PrintableString(string); - break; - case DerValue.tag_T61String: - value = new TeletexString(string); - break; - case DerValue.tag_UniversalString: - value = new UniversalString(string); - break; - case DerValue.tag_UTF8String: - value = new UTF8String(string); - break; - default: - throw new Exception("Unsupported tag: "+tag); + case DerValue.tag_BMPString: + value = new BMPString(string); + break; + case DerValue.tag_IA5String: + value = new IA5String(string); + break; + case DerValue.tag_PrintableString: + value = new PrintableString(string); + break; + case DerValue.tag_T61String: + value = new TeletexString(string); + break; + case DerValue.tag_UniversalString: + value = new UniversalString(string); + break; + case DerValue.tag_UTF8String: + value = new UTF8String(string); + break; + default: + throw new Exception("Unsupported tag: " + tag); } return ASN1Util.encode(value); } @@ -47,26 +47,26 @@ public class JSSUtil { ASN1Template template; switch (tag) { - case DerValue.tag_BMPString: - template = new BMPString.Template(); - break; - case DerValue.tag_IA5String: - template = new IA5String.Template(); - break; - case DerValue.tag_PrintableString: - template = new PrintableString.Template(); - break; - case DerValue.tag_T61String: - template = new TeletexString.Template(); - break; - case DerValue.tag_UniversalString: - template = new UniversalString.Template(); - break; - case DerValue.tag_UTF8String: - template = new UTF8String.Template(); - break; - default: - throw new Exception("Unsupported tag: "+tag); + case DerValue.tag_BMPString: + template = new BMPString.Template(); + break; + case DerValue.tag_IA5String: + template = new IA5String.Template(); + break; + case DerValue.tag_PrintableString: + template = new PrintableString.Template(); + break; + case DerValue.tag_T61String: + template = new TeletexString.Template(); + break; + case DerValue.tag_UniversalString: + template = new UniversalString.Template(); + break; + case DerValue.tag_UTF8String: + template = new UTF8String.Template(); + break; + default: + throw new Exception("Unsupported tag: " + tag); } return ASN1Util.decode(new Tag(Tag.UNIVERSAL, tag), template, bytes).toString(); } diff --git a/pki/base/util/test/com/netscape/security/util/PrintableStringTest.java b/pki/base/util/test/com/netscape/security/util/PrintableStringTest.java index 6f0ba1d2a..5808a2650 100644 --- a/pki/base/util/test/com/netscape/security/util/PrintableStringTest.java +++ b/pki/base/util/test/com/netscape/security/util/PrintableStringTest.java @@ -15,13 +15,13 @@ public class PrintableStringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -32,12 +32,12 @@ public class PrintableStringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -46,18 +46,18 @@ public class PrintableStringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -66,13 +66,13 @@ public class PrintableStringTest { public void testDecodingNullCharacters() throws Exception { byte[] data = { 0x13, 0x01, 0x00 }; - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); String expected = ""; // skip null chars (bug 359010) - System.out.println(" - expected: ["+expected+"]"); + System.out.println(" - expected: [" + expected + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(expected, output); } @@ -81,13 +81,13 @@ public class PrintableStringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -98,12 +98,12 @@ public class PrintableStringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -112,18 +112,18 @@ public class PrintableStringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -134,18 +134,18 @@ public class PrintableStringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(DerValue.tag_UTF8String, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); System.out.println(" - expected: IOException"); try { String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -154,18 +154,18 @@ public class PrintableStringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -176,18 +176,18 @@ public class PrintableStringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(DerValue.tag_UTF8String, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); System.out.println(" - expected: IOException"); try { String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -196,18 +196,18 @@ public class PrintableStringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, StringTestUtil.MULTIBYTE_CHARS); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -218,18 +218,18 @@ public class PrintableStringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(DerValue.tag_UTF8String, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); System.out.println(" - expected: IOException"); try { String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -243,18 +243,20 @@ public class PrintableStringTest { long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -269,18 +271,20 @@ public class PrintableStringTest { long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/util/StringTestUtil.java b/pki/base/util/test/com/netscape/security/util/StringTestUtil.java index cb536e7b3..16810581c 100644 --- a/pki/base/util/test/com/netscape/security/util/StringTestUtil.java +++ b/pki/base/util/test/com/netscape/security/util/StringTestUtil.java @@ -9,7 +9,7 @@ public class StringTestUtil { public final static String NULL_CHARS = "\u0000"; public final static String PRINTABLE_CHARS = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 \'()+,-./:=?"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 \'()+,-./:=?"; public final static String NON_PRINTABLE_CHARS = "\"\\"; @@ -20,8 +20,9 @@ public class StringTestUtil { public static String toString(byte[] array) { StringBuffer sb = new StringBuffer(); - for (int i=0; i<array.length; i++) { - if (i > 0) sb.append(" "); + for (int i = 0; i < array.length; i++) { + if (i > 0) + sb.append(" "); sb.append(Integer.toHexString(0xff & array[i] | 0x100).substring(1).toUpperCase()); } @@ -39,7 +40,7 @@ public class StringTestUtil { int length = value.length() - 2; DerOutputStream os = new DerOutputStream(); - os.putTag((byte)0, false, tag); + os.putTag((byte) 0, false, tag); os.putLength(length); os.write(tmp, 2, length); @@ -72,7 +73,7 @@ public class StringTestUtil { case DerValue.tag_UTF8String: return is.getDerValue().getUTF8String(); default: - throw new Exception("Unsupported tag: "+tag); + throw new Exception("Unsupported tag: " + tag); } } } diff --git a/pki/base/util/test/com/netscape/security/util/TeletexStringTest.java b/pki/base/util/test/com/netscape/security/util/TeletexStringTest.java index fc205455f..69f46c220 100644 --- a/pki/base/util/test/com/netscape/security/util/TeletexStringTest.java +++ b/pki/base/util/test/com/netscape/security/util/TeletexStringTest.java @@ -15,13 +15,13 @@ public class TeletexStringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -32,12 +32,12 @@ public class TeletexStringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -46,16 +46,16 @@ public class TeletexStringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -66,12 +66,12 @@ public class TeletexStringTest { String input = StringTestUtil.NULL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -80,13 +80,13 @@ public class TeletexStringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -97,12 +97,12 @@ public class TeletexStringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -111,13 +111,13 @@ public class TeletexStringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -128,12 +128,12 @@ public class TeletexStringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -142,13 +142,13 @@ public class TeletexStringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -159,12 +159,12 @@ public class TeletexStringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -173,18 +173,18 @@ public class TeletexStringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); System.out.println(" - expected: IOException"); try { byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -195,18 +195,18 @@ public class TeletexStringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(DerValue.tag_UTF8String, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); System.out.println(" - expected: IOException"); try { String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IOException); } } @@ -217,24 +217,26 @@ public class TeletexStringTest { System.out.println("Encoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS; long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -244,26 +246,28 @@ public class TeletexStringTest { System.out.println("Decoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, string); long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/util/UTF8StringTest.java b/pki/base/util/test/com/netscape/security/util/UTF8StringTest.java index 7f98c17c5..6bffb28b6 100644 --- a/pki/base/util/test/com/netscape/security/util/UTF8StringTest.java +++ b/pki/base/util/test/com/netscape/security/util/UTF8StringTest.java @@ -13,13 +13,13 @@ public class UTF8StringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, ""); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, ""); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,12 +30,12 @@ public class UTF8StringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -44,16 +44,16 @@ public class UTF8StringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -64,12 +64,12 @@ public class UTF8StringTest { String input = StringTestUtil.NULL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -78,13 +78,13 @@ public class UTF8StringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -95,12 +95,12 @@ public class UTF8StringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -109,13 +109,13 @@ public class UTF8StringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -126,12 +126,12 @@ public class UTF8StringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -140,13 +140,13 @@ public class UTF8StringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -157,12 +157,12 @@ public class UTF8StringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -171,13 +171,13 @@ public class UTF8StringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -188,12 +188,12 @@ public class UTF8StringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -204,25 +204,27 @@ public class UTF8StringTest { System.out.println("Encoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -232,27 +234,29 @@ public class UTF8StringTest { System.out.println("Decoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, string); long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/util/UniversalStringTest.java b/pki/base/util/test/com/netscape/security/util/UniversalStringTest.java index 53d45920d..5f09f1f8e 100644 --- a/pki/base/util/test/com/netscape/security/util/UniversalStringTest.java +++ b/pki/base/util/test/com/netscape/security/util/UniversalStringTest.java @@ -13,13 +13,13 @@ public class UniversalStringTest { public void testEncodingEmptyString() throws Exception { String string = ""; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,12 +30,12 @@ public class UniversalStringTest { String input = ""; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -44,16 +44,16 @@ public class UniversalStringTest { public void testEncodingNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -64,12 +64,12 @@ public class UniversalStringTest { String input = StringTestUtil.NULL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -78,13 +78,13 @@ public class UniversalStringTest { public void testEncodingPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -95,12 +95,12 @@ public class UniversalStringTest { String input = StringTestUtil.PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -109,13 +109,13 @@ public class UniversalStringTest { public void testEncodingNonPrintableCharacters() throws Exception { String string = StringTestUtil.NON_PRINTABLE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -126,12 +126,12 @@ public class UniversalStringTest { String input = StringTestUtil.NON_PRINTABLE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+input+"]"); + System.out.println(" - expected: [" + input + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+output+"]"); + System.out.println(" - actual : [" + output + "]"); Assert.assertEquals(input, output); } @@ -140,13 +140,13 @@ public class UniversalStringTest { public void testEncodingControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Encoding: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Encoding: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -157,12 +157,12 @@ public class UniversalStringTest { String input = StringTestUtil.CONTROL_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -171,13 +171,13 @@ public class UniversalStringTest { public void testEncodingMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Encoding: ["+string+"]"); + System.out.println("Encoding: [" + string + "]"); byte[] expected = JSSUtil.encode(tag, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = StringTestUtil.encode(tag, string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -188,12 +188,12 @@ public class UniversalStringTest { String input = StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, input); - System.out.println("Decoding: ["+StringTestUtil.toString(data)+"]"); + System.out.println("Decoding: [" + StringTestUtil.toString(data) + "]"); - System.out.println(" - expected: ["+StringTestUtil.toString(input.getBytes())+"]"); + System.out.println(" - expected: [" + StringTestUtil.toString(input.getBytes()) + "]"); String output = StringTestUtil.decode(tag, data); - System.out.println(" - actual : ["+StringTestUtil.toString(output.getBytes())+"]"); + System.out.println(" - actual : [" + StringTestUtil.toString(output.getBytes()) + "]"); Assert.assertEquals(input, output); } @@ -204,25 +204,27 @@ public class UniversalStringTest { System.out.println("Encoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + JSSUtil.encode(tag, string); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.encode(tag, string); + for (int i = 0; i < 10000; i++) + StringTestUtil.encode(tag, string); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } @@ -232,27 +234,29 @@ public class UniversalStringTest { System.out.println("Decoding time:"); String string = StringTestUtil.NULL_CHARS + - StringTestUtil.PRINTABLE_CHARS + - StringTestUtil.NON_PRINTABLE_CHARS + - StringTestUtil.CONTROL_CHARS + - StringTestUtil.MULTIBYTE_CHARS; + StringTestUtil.PRINTABLE_CHARS + + StringTestUtil.NON_PRINTABLE_CHARS + + StringTestUtil.CONTROL_CHARS + + StringTestUtil.MULTIBYTE_CHARS; byte[] data = JSSUtil.encode(tag, string); long t0 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) JSSUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + JSSUtil.decode(tag, data); long t1 = System.currentTimeMillis(); - for (int i=0; i<10000; i++) StringTestUtil.decode(tag, data); + for (int i = 0; i < 10000; i++) + StringTestUtil.decode(tag, data); long t2 = System.currentTimeMillis(); long time1 = t1 - t0; long time2 = t2 - t1; - System.out.println(" - JSS : "+time1+" ms"); + System.out.println(" - JSS : " + time1 + " ms"); System.out.println(" - Internal: " + time2 + " ms"); } } diff --git a/pki/base/util/test/com/netscape/security/x509/DirStrConverterTest.java b/pki/base/util/test/com/netscape/security/x509/DirStrConverterTest.java index 2abf05714..0549dec9c 100644 --- a/pki/base/util/test/com/netscape/security/x509/DirStrConverterTest.java +++ b/pki/base/util/test/com/netscape/security/x509/DirStrConverterTest.java @@ -15,13 +15,13 @@ public class DirStrConverterTest { public void testEmptyString() throws Exception { String string = ""; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,13 +30,13 @@ public class DirStrConverterTest { public void testNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_T61String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -45,13 +45,13 @@ public class DirStrConverterTest { public void testPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -60,13 +60,13 @@ public class DirStrConverterTest { public void testControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_T61String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -75,13 +75,13 @@ public class DirStrConverterTest { public void testMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_UniversalString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -90,15 +90,15 @@ public class DirStrConverterTest { public void testPrintableCharactersWithTags() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string, new byte[] { - DerValue.tag_IA5String, DerValue.tag_UTF8String + DerValue.tag_IA5String, DerValue.tag_UTF8String }); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -107,15 +107,15 @@ public class DirStrConverterTest { public void testMultibyteCharactersWithTags() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_UTF8String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new DirStrConverter(), string, new byte[] { - DerValue.tag_IA5String, DerValue.tag_UTF8String + DerValue.tag_IA5String, DerValue.tag_UTF8String }); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } diff --git a/pki/base/util/test/com/netscape/security/x509/GenericValueConverterTest.java b/pki/base/util/test/com/netscape/security/x509/GenericValueConverterTest.java index 1962d1bfa..46ea86cc7 100644 --- a/pki/base/util/test/com/netscape/security/x509/GenericValueConverterTest.java +++ b/pki/base/util/test/com/netscape/security/x509/GenericValueConverterTest.java @@ -15,13 +15,13 @@ public class GenericValueConverterTest { public void testEmptyString() throws Exception { String string = ""; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,13 +30,13 @@ public class GenericValueConverterTest { public void testNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -45,13 +45,13 @@ public class GenericValueConverterTest { public void testPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -60,13 +60,13 @@ public class GenericValueConverterTest { public void testControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -75,16 +75,16 @@ public class GenericValueConverterTest { public void testMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_BMPString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); actual = StringTestUtil.normalizeUnicode(actual); - System.out.println(" - norm. : "+StringTestUtil.toString(actual)); + System.out.println(" - norm. : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -93,15 +93,15 @@ public class GenericValueConverterTest { public void testPrintableCharactersWithTags() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_T61String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string, new byte[] { - DerValue.tag_T61String, DerValue.tag_UniversalString + DerValue.tag_T61String, DerValue.tag_UniversalString }); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -110,15 +110,15 @@ public class GenericValueConverterTest { public void testMultibyteCharactersWithTags() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_UniversalString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new GenericValueConverter(), string, new byte[] { - DerValue.tag_T61String, DerValue.tag_UniversalString + DerValue.tag_T61String, DerValue.tag_UniversalString }); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } diff --git a/pki/base/util/test/com/netscape/security/x509/IA5StringConverterTest.java b/pki/base/util/test/com/netscape/security/x509/IA5StringConverterTest.java index a7361ccbf..ba99218ad 100644 --- a/pki/base/util/test/com/netscape/security/x509/IA5StringConverterTest.java +++ b/pki/base/util/test/com/netscape/security/x509/IA5StringConverterTest.java @@ -15,13 +15,13 @@ public class IA5StringConverterTest { public void testEmptyString() throws Exception { String string = ""; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new IA5StringConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,13 +30,13 @@ public class IA5StringConverterTest { public void testNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new IA5StringConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -45,13 +45,13 @@ public class IA5StringConverterTest { public void testPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new IA5StringConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -60,13 +60,13 @@ public class IA5StringConverterTest { public void testControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_IA5String, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new IA5StringConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -75,18 +75,18 @@ public class IA5StringConverterTest { public void testMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); System.out.println(" - expected: IllegalArgumentException"); try { byte[] actual = ConverterTestUtil.convert(new IA5StringConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IllegalArgumentException); } } diff --git a/pki/base/util/test/com/netscape/security/x509/PrintableConverterTest.java b/pki/base/util/test/com/netscape/security/x509/PrintableConverterTest.java index e85d11824..a7acc9c90 100644 --- a/pki/base/util/test/com/netscape/security/x509/PrintableConverterTest.java +++ b/pki/base/util/test/com/netscape/security/x509/PrintableConverterTest.java @@ -15,13 +15,13 @@ public class PrintableConverterTest { public void testEmptyString() throws Exception { String string = ""; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new PrintableConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -30,18 +30,18 @@ public class PrintableConverterTest { public void testNullCharacters() throws Exception { String string = StringTestUtil.NULL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); System.out.println(" - expected: IllegalArgumentException"); try { byte[] actual = ConverterTestUtil.convert(new PrintableConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IllegalArgumentException); } } @@ -50,13 +50,13 @@ public class PrintableConverterTest { public void testPrintableCharacters() throws Exception { String string = StringTestUtil.PRINTABLE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); byte[] expected = JSSUtil.encode(DerValue.tag_PrintableString, string); - System.out.println(" - expected: "+StringTestUtil.toString(expected)); + System.out.println(" - expected: " + StringTestUtil.toString(expected)); byte[] actual = ConverterTestUtil.convert(new PrintableConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.assertArrayEquals(expected, actual); } @@ -65,18 +65,18 @@ public class PrintableConverterTest { public void testControlCharacters() throws Exception { String string = StringTestUtil.CONTROL_CHARS; - System.out.println("Converting: ["+StringTestUtil.toString(string.getBytes())+"]"); + System.out.println("Converting: [" + StringTestUtil.toString(string.getBytes()) + "]"); System.out.println(" - expected: IllegalArgumentException"); try { byte[] actual = ConverterTestUtil.convert(new PrintableConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IllegalArgumentException); } } @@ -85,18 +85,18 @@ public class PrintableConverterTest { public void testMultibyteCharacters() throws Exception { String string = StringTestUtil.MULTIBYTE_CHARS; - System.out.println("Converting: ["+string+"]"); + System.out.println("Converting: [" + string + "]"); System.out.println(" - expected: IllegalArgumentException"); try { byte[] actual = ConverterTestUtil.convert(new PrintableConverter(), string); - System.out.println(" - actual : "+StringTestUtil.toString(actual)); + System.out.println(" - actual : " + StringTestUtil.toString(actual)); Assert.fail(); } catch (Exception e) { - System.out.println(" - actual : "+e.getClass().getSimpleName()); + System.out.println(" - actual : " + e.getClass().getSimpleName()); Assert.assertTrue(e instanceof IllegalArgumentException); } } |