1 13 14 package se.anatom.ejbca.ca.caadmin; 15 16 import javax.naming.Context ; 17 import javax.naming.NamingException ; 18 19 import junit.framework.TestCase; 20 21 import org.apache.log4j.Logger; 22 import org.ejbca.core.ejb.ca.caadmin.ICAAdminSessionHome; 23 import org.ejbca.core.ejb.ca.caadmin.ICAAdminSessionRemote; 24 import org.ejbca.core.model.log.Admin; 25 26 31 public class TestRemoveCA extends TestCase { 32 private static Logger log = Logger.getLogger(TestCAs.class); 33 34 private ICAAdminSessionRemote cacheAdmin; 35 private static ICAAdminSessionHome cacheHome; 36 37 private static final Admin admin = new Admin(Admin.TYPE_INTERNALUSER); 38 39 44 public TestRemoveCA(String name) { 45 super(name); 46 } 47 48 protected void setUp() throws Exception { 49 50 log.debug(">setUp()"); 51 52 if (cacheAdmin == null) { 53 if (cacheHome == null) { 54 Context jndiContext = getInitialContext(); 55 Object obj1 = jndiContext.lookup("CAAdminSession"); 56 cacheHome = (ICAAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(obj1, ICAAdminSessionHome.class); 57 } 58 59 cacheAdmin = cacheHome.create(); 60 } 61 62 log.debug("<setUp()"); 63 } 64 65 protected void tearDown() throws Exception { 66 } 67 68 private Context getInitialContext() throws NamingException { 69 log.debug(">getInitialContext"); 70 71 Context ctx = new javax.naming.InitialContext (); 72 log.debug("<getInitialContext"); 73 74 return ctx; 75 } 76 77 82 public void test02removeRSACA() throws Exception { 83 log.debug(">test02removeRSACA()"); 84 boolean ret = false; 85 try { 86 cacheAdmin.removeCA(admin, "CN=TEST".hashCode()); 87 ret = true; 88 } catch (Exception pee) { 89 } 90 assertTrue("Removing RSA CA failed", ret); 91 92 log.debug("<test02removeRSACA()"); 93 } 94 95 100 public void test03removeECDSACA() throws Exception { 101 log.debug(">test03removeECDSACA()"); 102 boolean ret = false; 103 try { 104 cacheAdmin.removeCA(admin, "CN=TESTECDSA".hashCode()); 105 ret = true; 106 } catch (Exception pee) { 107 } 108 assertTrue("Removing ECDSA CA failed", ret); 109 110 try { 111 cacheAdmin.removeCA(admin, "CN=TESTECDSAImplicitlyCA".hashCode()); 112 ret = true; 113 } catch (Exception pee) { 114 } 115 assertTrue("Removing ECDSA ImplicitlyCA CA failed", ret); 116 117 log.debug("<test03removeECDSACA()"); 118 } 119 120 125 public void test04removeRSASha256WithMGF1CA() throws Exception { 126 log.debug(">test04removeRSASha256WithMGF1CA()"); 127 boolean ret = false; 128 try { 129 cacheAdmin.removeCA(admin, "CN=TESTSha256WithMGF1".hashCode()); 130 ret = true; 131 } catch (Exception pee) { 132 } 133 assertTrue("Removing RSA SHA256WithMGF1 CA failed", ret); 134 135 log.debug("<test04removeRSASha256WithMGF1CA()"); 136 } 137 138 } 139 | Popular Tags |