1 13 14 package se.anatom.ejbca.ra.raadmin; 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.ra.raadmin.IRaAdminSessionHome; 23 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionRemote; 24 import org.ejbca.core.model.log.Admin; 25 import org.ejbca.core.model.ra.raadmin.GlobalConfiguration; 26 27 32 public class TestGlobalConfiguration extends TestCase { 33 private static Logger log = Logger.getLogger(TestGlobalConfiguration.class); 34 35 private IRaAdminSessionRemote cacheAdmin; 36 37 private static IRaAdminSessionHome cacheHome; 38 39 private static GlobalConfiguration original = null; 40 41 42 47 public TestGlobalConfiguration(String name) { 48 super(name); 49 } 50 51 protected void setUp() throws Exception { 52 53 log.debug(">setUp()"); 54 55 if (cacheAdmin == null) { 56 if (cacheHome == null) { 57 Context jndiContext = getInitialContext(); 58 Object obj1 = jndiContext.lookup("RaAdminSession"); 59 cacheHome = (IRaAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(obj1, IRaAdminSessionHome.class); 60 61 } 62 63 cacheAdmin = cacheHome.create(); 64 } 65 66 67 log.debug("<setUp()"); 68 } 69 70 protected void tearDown() throws Exception { 71 } 72 73 private Context getInitialContext() throws NamingException { 74 log.debug(">getInitialContext"); 75 76 Context ctx = new javax.naming.InitialContext (); 77 log.debug("<getInitialContext"); 78 79 return ctx; 80 } 81 82 83 88 public void test01AddGlobalConfiguration() throws Exception { 89 log.debug(">test01AddGlobalConfiguration()"); 90 91 Admin administrator = new Admin(Admin.TYPE_INTERNALUSER); 92 93 original = this.cacheAdmin.loadGlobalConfiguration(administrator); 95 96 GlobalConfiguration conf = new GlobalConfiguration(); 97 conf.setEjbcaTitle("TESTTITLE"); 98 this.cacheAdmin.saveGlobalConfiguration(administrator, conf); 99 100 log.debug("<test01AddGlobalConfiguration()"); 101 } 102 103 108 public void test02ModifyGlobalConfiguration() throws Exception { 109 log.debug(">test01ModifyGlobalConfiguration()"); 110 111 Admin administrator = new Admin(Admin.TYPE_INTERNALUSER); 112 113 GlobalConfiguration conf = this.cacheAdmin.loadGlobalConfiguration(administrator); 114 assertTrue("Error Retreiving Global Configuration.", conf.getEjbcaTitle().equals("TESTTITLE")); 115 116 conf.setEjbcaTitle("TESTTITLE2"); 117 this.cacheAdmin.saveGlobalConfiguration(administrator, conf); 118 119 this.cacheAdmin.saveGlobalConfiguration(administrator, original); 121 122 log.debug("<test01ModifyGlobalConfiguration()"); 123 } 124 125 126 } 127 | Popular Tags |