diff options
author | Adam Young <ayoung@redhat.com> | 2011-12-21 15:59:43 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-01-11 13:55:30 -0500 |
commit | f7a1d6a79d1b0367e556d5c53fe5e0c07c7b5c66 (patch) | |
tree | 418e2d98c4ca48d160441c506350b962b40f0def | |
parent | 518ccbe83cb097958379ba5773437ed4a59ed2db (diff) | |
download | pki-f7a1d6a79d1b0367e556d5c53fe5e0c07c7b5c66.tar.gz pki-f7a1d6a79d1b0367e556d5c53fe5e0c07c7b5c66.tar.xz pki-f7a1d6a79d1b0367e556d5c53fe5e0c07c7b5c66.zip |
GenericASN1Extension Test
-rw-r--r-- | pki/base/util/test/com/netscape/security/extensions/GenericASN1ExtensionTest.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/pki/base/util/test/com/netscape/security/extensions/GenericASN1ExtensionTest.java b/pki/base/util/test/com/netscape/security/extensions/GenericASN1ExtensionTest.java new file mode 100644 index 00000000..cc2f24c3 --- /dev/null +++ b/pki/base/util/test/com/netscape/security/extensions/GenericASN1ExtensionTest.java @@ -0,0 +1,72 @@ +package com.netscape.security.extensions; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.util.Hashtable; + +import netscape.security.extensions.GenericASN1Extension; +import netscape.security.x509.OIDMap; + +import org.junit.Assert; +import org.junit.Test; + +public class GenericASN1ExtensionTest { + + //@Test + public void testConstructorArgs() throws Exception { + String name1 = "testExtension1"; + String oid1 = "1.2.3.4"; + String pattern = ""; + Hashtable<String, String> config = new Hashtable<String, String>(); + GenericASN1Extension extension1 = new GenericASN1Extension(name1, oid1, + pattern, false, config); + Assert.assertEquals(name1, extension1.getName()); + Assert.assertNotNull(OIDMap.getClass(name1)); + + String name2 = "testExtension2"; + String oid2 = "2.4.6.8"; + GenericASN1Extension extension2 = new GenericASN1Extension(name2, oid2, + pattern, false, config); + Assert.assertEquals(name2, extension2.getName()); + Assert.assertNotNull(OIDMap.getClass(name2)); + } + + @Test + public void testConstructorJustConfig() throws Exception { + String name1 = "testExtension1"; + String oid1 = "1.2.3.4"; + String pattern = ""; + Hashtable<String, String> config = new Hashtable<String, String>(); + config.put("oid", oid1); + config.put("name", name1); + config.put("pattern", pattern); + config.put("critical", "true"); + + GenericASN1Extension extension1 = new GenericASN1Extension(config); + Assert.assertEquals(name1, extension1.getName()); + //Assert.assertNotNull(OIDMap.getClass(name1)); + + String name2 = "testExtension2"; + String oid2 = "2.4.6.8"; + config.put("oid", oid2); + config.put("name", name2); + + GenericASN1Extension extension2 = new GenericASN1Extension(config); + Assert.assertEquals(name2, extension2.getName()); + //Assert.assertNotNull(OIDMap.getClass(name2)); + OutputStream outputStream = new ByteArrayOutputStream(); + extension1.encode(outputStream ); + extension2.encode(outputStream ); + + } + + @Test + public void testConstructorDER() throws Exception { + byte[] value = new byte[0]; + GenericASN1Extension extension = new GenericASN1Extension(true, value); + + OutputStream outputStream = new ByteArrayOutputStream(); + extension.encode(outputStream ); + + } +} |