Methods Summary |
---|
boolean | exists(java.lang.Object on, java.lang.Object[] names)
for (int i = 0; i < names.length; i++)
{
if (names[i].equals(on))
{
return true;
}
}
return false;
|
javax.management.ObjectName | getAuditModule(java.lang.String name)
return new ObjectName(
getTestDomain() +
":type=audit-module,category=config,config=" + getConfigRef() +
",name=" + name);
|
javax.management.ObjectName | getAuthRealm(java.lang.String name)
return new ObjectName(
getTestDomain() +
":type=auth-realm,category=config,config=" + getConfigRef() +
",name=" + name);
|
private void | getChild(java.lang.String type, java.lang.String[] loc)
try
{
ObjectName on = configsMBean.getChild(type, loc, getTargetName());
Assert.assertEquals(getObjectName(type, loc), on);
}
catch (MBeanException mbe) {}
|
javax.management.ObjectName | getConfigMBean()
return new ObjectName(
getTestDomain() +
":type=config,category=config,name=" + getConfigRef());
|
private java.lang.String | getConfigRef()
Target target = TargetBuilder.INSTANCE.createTarget(
getTargetName(), configContext);
return target.getConfigRef();
|
javax.management.ObjectName | getEjbContainer()
return new ObjectName(
getTestDomain() +
":type=ejb-container,category=config,config=" + getConfigRef());
|
javax.management.ObjectName | getHttpListener()
return new ObjectName(
getTestDomain() +
":type=http-listener,category=config,id=mylistener,config=" +
getConfigRef());
|
javax.management.ObjectName | getHttpListener(java.lang.String listenerId)
return new ObjectName(
getTestDomain() +
":type=http-listener,category=config,id=" + listenerId +
",config=" + getConfigRef());
|
private javax.management.AttributeList | getHttpListenerAttrs()
AttributeList attrList = new AttributeList();
attrList.add(new Attribute("id", "mylistener"));
attrList.add(new Attribute("address", "abcd"));
attrList.add(new Attribute("port", "9999"));
attrList.add(new Attribute("server-name", "server-name"));
attrList.add(new Attribute("default-virtual-server", "server-name"));
return attrList;
|
javax.management.ObjectName | getHttpService()
return new ObjectName(
getTestDomain() +
":type=http-service,category=config,config=" + getConfigRef());
|
javax.management.ObjectName | getIiopListener()
return new ObjectName(
getTestDomain() +
":type=iiop-listener,category=config,id=mylistener,config=" +
getConfigRef());
|
private javax.management.AttributeList | getIiopListenerAttrs()
AttributeList attrList = new AttributeList();
attrList.add(new Attribute("id", "mylistener"));
attrList.add(new Attribute("address", "address"));
return attrList;
|
javax.management.ObjectName | getJaccProvider(java.lang.String name)
return new ObjectName(
getTestDomain() +
":type=jacc-provider,category=config,config=" + getConfigRef() +
",name=" + name);
|
javax.management.ObjectName | getJmsHost(java.lang.String name)
return new ObjectName(
getTestDomain() +
":type=jms-host,category=config,config=" + getConfigRef() +
",name=" + name);
|
javax.management.ObjectName | getObjectName(java.lang.String type, java.lang.String[] loc)
if (null == loc) { loc = new String[0]; }
String[] oTokens = new String[loc.length + 2];
oTokens[0] = getTestDomain();
oTokens[1] = getConfigRef();
for (int i = 2; i < oTokens.length; i++)
{
oTokens[i] = loc[i-2];
}
return mbeanRegistry.getMbeanObjectName(type, oTokens);
|
javax.management.ObjectName | getObjectName1(java.lang.String type, java.lang.String loc)
return getObjectName(type, new String[] {loc});
|
javax.management.ObjectName | getObjectName2(java.lang.String type, java.lang.String loc1, java.lang.String loc2)
return getObjectName(type, new String[] {loc1, loc2});
|
javax.management.ObjectName | getProfiler()
return new ObjectName(
getTestDomain() +
":type=profiler,category=config,config=" + getConfigRef());
|
private java.util.Properties | getProperties()
Properties props = new Properties();
props.put("prop1", "val1");
return props;
|
javax.management.ObjectName | getSsl(java.lang.String type, java.lang.String id)
String on = getTestDomain() + ":type=ssl,category=config,config=" +
getConfigRef();
on += "iiop-service".equals(type) ? "" : ("," + type + '=" + id);
return new ObjectName(on);
|
private Target | getTarget()
return TargetBuilder.INSTANCE.createTarget(getTargetName(),
configContext);
|
private java.lang.String | getTargetName()
return null;
|
private java.lang.String | getTestDomain()
return "testdomain";
|
javax.management.ObjectName | getThreadPool(java.lang.String threadPoolId)
return new ObjectName(
getTestDomain() +
":type=thread-pool,category=config,config=" + getConfigRef() +
",thread-pool-id=" + threadPoolId);
|
javax.management.ObjectName | getVirtualServer()
return new ObjectName(
getTestDomain() +
":type=virtual-server,category=config,id=my-virtual-server,config="
+ getConfigRef());
|
private javax.management.AttributeList | getVirtualServerAttrs()
AttributeList attrList = new AttributeList();
attrList.add(new Attribute("id", "my-virtual-server"));
attrList.add(new Attribute("hosts", "host1,host2"));
return attrList;
|
private static void | loadMBeanRegistry()
if (null == mbeanRegistry)
{
mbeanRegistry = MBeanRegistryFactory.getMBeanRegistry(
mbeanDescriptor.getAbsolutePath());
}
|
public static void | main(java.lang.String[] args)
setDomainXml(new File(args[0]));
setMBeanDescriptor(new File(args[1]));
final TestRunner runner= new TestRunner();
final TestResult result = runner.doRun(ConfigsMBeanTest.suite(), false);
System.exit(result.errorCount() + result.failureCount());
|
public static void | setDomainXml(java.io.File xml)
domainXml = xml;
|
public static void | setMBeanDescriptor(java.io.File f)
mbeanDescriptor = f;
|
protected void | setUp()
configsMBean = new MyConfigsMBean();
try
{
configContext = ConfigFactory.createConfigContext(
domainXml.getAbsolutePath());
loadMBeanRegistry();
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(ConfigsMBeanTest.class);
return suite;
|
protected void | tearDown()
configsMBean = null;
configContext = null;
mbeanRegistry = null;
|
public void | testAuditModule()
AttributeList attrs = new AttributeList();
attrs.add(new Attribute("name", "xaudit"));
attrs.add(new Attribute("classname", "audit.xaudit"));
ObjectName on = configsMBean.createAuditModule(
attrs, getProperties(), getTargetName());
Assert.assertTrue(on != null);
Assert.assertEquals(getAuditModule("xaudit"), on);
ObjectName[] onames = configsMBean.listAuditModules(getTargetName());
Assert.assertTrue(onames != null);
Assert.assertTrue(onames.length > 0);
Assert.assertTrue(exists(getAuditModule("xaudit"), onames));
boolean isDeleted = configsMBean.deleteAuditModule(
"xaudit", getTargetName());
Assert.assertTrue(isDeleted);
onames = configsMBean.listAuditModules(getTargetName());
Assert.assertTrue(!exists(getAuditModule("xaudit"), onames));
|
public void | testAuthRealm()
final String target = getTargetName();
final String realm = "myAuth";
final AttributeList al = new AttributeList();
al.add(new Attribute("name", realm));
al.add(new Attribute("classname", "myauth.Auth"));
ObjectName on = configsMBean.createAuthRealm(al, null, target);
Assert.assertTrue(on != null);
Assert.assertEquals(getAuthRealm(realm), on);
ObjectName[] authRealms = configsMBean.listAuthRealms(target);
Assert.assertTrue(authRealms != null);
Assert.assertTrue(exists(on, authRealms));
boolean deleted = configsMBean.deleteAuthRealm(realm, target);
Assert.assertTrue(deleted);
authRealms = configsMBean.listAuthRealms(target);
Assert.assertTrue(authRealms != null);
Assert.assertTrue(!exists(on, authRealms));
|
public void | testCreateConfigsMBean()
ConfigsMBean mbean = new ConfigsMBean();
Assert.assertTrue(mbean != null);
|
public void | testEjbTimerService()
ObjectName on = configsMBean.createEjbTimerService(
null, getProperties(), getTargetName());
Assert.assertTrue(on != null);
on = configsMBean.getEjbTimerService(getTargetName());
Assert.assertEquals(getObjectName("ejb-timer-service", null), on);
boolean isDeleted = configsMBean.deleteEjbTimerService(getTargetName());
Assert.assertTrue(isDeleted);
try
{
configsMBean.getEjbTimerService(getTargetName());
Assert.assertTrue(false);
}
catch (Exception e)
{
//ok
}
|
public void | testFileUser()
final String user = "ramakant3";
final String pwd = "ramakant";
final String[] grps = {"grp1"};
final String realm = "file";
configsMBean.addUser(user, pwd, grps, realm, getTargetName());
configsMBean.updateUser(user, pwd, grps, realm, getTargetName());
String[] users = configsMBean.getUserNames(realm, getTargetName());
Assert.assertTrue(users != null);
Assert.assertTrue(exists(user, users));
String[] groups = configsMBean.getGroupNames(user, realm,
getTargetName());
Assert.assertTrue(groups != null);
Assert.assertTrue(exists(grps[0], groups));
configsMBean.removeUser(user, realm, getTargetName());
users = configsMBean.getUserNames(realm, getTargetName());
Assert.assertFalse(exists(user, users));
groups = configsMBean.getGroupNames(null, realm, getTargetName());
Assert.assertFalse(exists(grps[0], groups));
|
public void | testGetChild()
getChild("http-listener", new String[] {"http-listener-1"});
getChild("ejb-container", null);
getChild("ssl", new String[] {"http-listener-1"});
getChild("ssl#", null);
getChild("ssl##", new String[]{"SSL"});
try
{
ObjectName on = configsMBean.getChild(null, null, getTargetName());
Assert.assertTrue(false);
}
catch (Exception e)
{
//ok
}
|
public void | testGetConfigMBean()
ObjectName on = configsMBean.getConfigMBean(getTarget());
Assert.assertEquals(getConfigMBean(), on);
|
public void | testGetHttpServiceMBean()
ObjectName on = configsMBean.getHttpServiceMBean(getTarget());
Assert.assertEquals(getHttpService(), on);
|
public void | testGetters()
ObjectName on = configsMBean.getHttpService(getTargetName());
Assert.assertEquals(getObjectName("http-service", null), on);
on = configsMBean.getIiopService(getTargetName());
Assert.assertEquals(getObjectName("iiop-service", null), on);
on = configsMBean.getTransactionService(getTargetName());
Assert.assertEquals(getObjectName("transaction-service", null), on);
on = configsMBean.getMonitoringService(getTargetName());
Assert.assertEquals(getObjectName("monitoring-service", null), on);
on = configsMBean.getLogService(getTargetName());
Assert.assertEquals(getObjectName("log-service", null), on);
on = configsMBean.getSecurityService(getTargetName());
Assert.assertEquals(getObjectName("security-service", null), on);
on = configsMBean.getJmsService(getTargetName());
Assert.assertEquals(getObjectName("jms-service", null), on);
on = configsMBean.getEjbContainer(getTargetName());
Assert.assertEquals(getObjectName("ejb-container", null), on);
on = configsMBean.getWebContainer(getTargetName());
Assert.assertEquals(getObjectName("web-container", null), on);
on = configsMBean.getMdbContainer(getTargetName());
Assert.assertEquals(getObjectName("mdb-container", null), on);
on = configsMBean.getJavaConfig(getTargetName());
Assert.assertEquals(getObjectName("java-config", null), on);
on = configsMBean.getHttpListener("http-listener-1", getTargetName());
Assert.assertEquals(
getObjectName1("http-listener", "http-listener-1"), on);
on = configsMBean.getVirtualServer("server", getTargetName());
Assert.assertEquals(getObjectName1("virtual-server", "server"), on);
on = configsMBean.getOrb(getTargetName());
Assert.assertEquals(getObjectName("orb", null), on);
on = configsMBean.getIiopListener("orb-listener-1", getTargetName());
Assert.assertEquals(
getObjectName1("iiop-listener", "orb-listener-1"), on);
on = configsMBean.getJmsHost("default_JMS_host", getTargetName());
Assert.assertEquals(getObjectName1("jms-host", "default_JMS_host"), on);
on = configsMBean.getAuthRealm("file", getTargetName());
Assert.assertEquals(getObjectName1("auth-realm", "file"), on);
on = configsMBean.getAuditModule("default", getTargetName());
Assert.assertEquals(getObjectName1("audit-module", "default"), on);
on = configsMBean.getJaccProvider("default", getTargetName());
Assert.assertEquals(getObjectName1("jacc-provider", "default"), on);
on = configsMBean.getModuleLogLevels(getTargetName());
Assert.assertEquals(getObjectName("module-log-levels", null), on);
on = configsMBean.getModuleMonitoringLevels(getTargetName());
Assert.assertEquals(getObjectName("module-monitoring-levels", null), on);
on = configsMBean.getThreadPool("thread-pool-1", getTargetName());
Assert.assertEquals(getObjectName1("thread-pool", "thread-pool-1"), on);
|
public void | testHttpListener()
final String target = getTargetName();
ObjectName on = configsMBean.createHttpListener(
getHttpListenerAttrs(), null, target);
Assert.assertTrue(on != null);
Assert.assertEquals(getHttpListener(), on);
ObjectName[] names = configsMBean.listHttpListeners(target);
Assert.assertTrue(names != null);
Assert.assertTrue(names.length > 0);
Assert.assertTrue(exists(getHttpListener(), names));
boolean isDeleted = configsMBean.deleteHttpListener("mylistener", null);
Assert.assertTrue(isDeleted);
names = configsMBean.listHttpListeners(target);
Assert.assertFalse(exists(getHttpListener(), names));
|
public void | testIiopListener()
final String target = getTargetName();
ObjectName on = configsMBean.createIiopListener(
getIiopListenerAttrs(), null, target);
Assert.assertTrue(on != null);
Assert.assertEquals(getIiopListener(), on);
ObjectName[] names = configsMBean.listIiopListeners(target);
Assert.assertTrue(names != null);
Assert.assertTrue(names.length > 0);
Assert.assertTrue(exists(getIiopListener(), names));
boolean isDeleted = configsMBean.deleteIiopListener("mylistener", null);
Assert.assertTrue(isDeleted);
names = configsMBean.listIiopListeners(target);
Assert.assertFalse(exists(getIiopListener(), names));
|
public void | testJaccProvider()
final AttributeList attrs = new AttributeList();
attrs.add(new Attribute("name", "provider1"));
attrs.add(new Attribute("policy-provider", "provider1"));
attrs.add(new Attribute("policy-configuration-factory-provider",
"providerfactory"));
ObjectName on = configsMBean.createJaccProvider(
attrs, getProperties(), getTargetName());
ObjectName[] onames = configsMBean.listJaccProviders(getTargetName());
Assert.assertTrue(onames != null);
Assert.assertTrue(onames.length > 0);
Assert.assertTrue(exists(getJaccProvider("provider1"), onames));
boolean isDeleted = configsMBean.deleteJaccProvider(
"provider1", getTargetName());
Assert.assertTrue(isDeleted);
onames = configsMBean.listJaccProviders(getTargetName());
Assert.assertTrue(!exists(getJaccProvider("provider1"), onames));
|
public void | testJmsHost()
final AttributeList attrs = new AttributeList();
attrs.add(new Attribute("name", "host1"));
ObjectName on = configsMBean.createJmsHost(
attrs, getProperties(), getTargetName());
Assert.assertTrue(on != null);
Assert.assertEquals(getJmsHost("host1"), on);
ObjectName[] onames = configsMBean.listJmsHosts(getTargetName());
Assert.assertTrue(onames != null);
Assert.assertTrue(onames.length > 0);
Assert.assertTrue(exists(getJmsHost("host1"), onames));
boolean isDeleted = configsMBean.deleteJmsHost("host1", getTargetName());
Assert.assertTrue(isDeleted);
onames = configsMBean.listJmsHosts(getTargetName());
Assert.assertTrue(!exists(getJmsHost("host1"), onames));
|
public void | testJvmOptions()
String[] exOpts = configsMBean.getJvmOptions(false, getTargetName());
Assert.assertTrue(exOpts != null);
String[] jvmOpts = new String[] {"-Dn1=v1", "-Dn2=v2", "-Dn3=v3"};
configsMBean.createJvmOptions(jvmOpts, false, getTargetName());
configsMBean.deleteJvmOptions(jvmOpts, false, getTargetName());
|
public void | testProfiler()
final String name = "myprofiler";
AttributeList al = new AttributeList();
al.add(new Attribute("name", name));
ObjectName on = configsMBean.createProfiler(
al, getProperties(), null);
Assert.assertTrue(on != null);
Assert.assertEquals(getProfiler(), on);
on = configsMBean.getProfiler(getTargetName());
Assert.assertEquals(getObjectName("profiler", null), on);
boolean isDeleted = configsMBean.deleteProfiler(null);
Assert.assertTrue(isDeleted);
|
public void | testSSL()
final String target = getTargetName();
try
{
configsMBean.createHttpListener(getHttpListenerAttrs(), null, target);
configsMBean.createIiopListener(getIiopListenerAttrs(), null, target);
testSSL("http-listener");
testSSL("iiop-listener");
testSSL("iiop-service");
}
finally
{
configsMBean.deleteHttpListener("mylistener", target);
configsMBean.deleteIiopListener("mylistener", target);
}
|
void | testSSL(java.lang.String type)
ObjectName ssl = null;
final String target = getTargetName();
AttributeList al = new AttributeList();
al.add(new Attribute("cert-nickname", "nick1"));
ssl = configsMBean.createSsl(al, "mylistener", type, target);
Assert.assertTrue(ssl != null);
ObjectName on = configsMBean.getSsl(type, "mylistener", target);
Assert.assertEquals(ssl, on);
boolean isDeleted = configsMBean.deleteSsl(
"mylistener", type, target);
Assert.assertTrue(isDeleted);
|
public void | testSessionConfig()
ObjectName on = null;
boolean isDeleted = false;
on = configsMBean.createSessionProperties(null, getProperties(),
getTargetName());
Assert.assertEquals(getObjectName("session-properties", null), on);
on = configsMBean.getSessionProperties(getTargetName());
Assert.assertEquals(getObjectName("session-properties", null), on);
isDeleted = configsMBean.deleteSessionProperties(getTargetName());
Assert.assertTrue(isDeleted);
on = configsMBean.createManagerProperties(null, null, getTargetName());
Assert.assertEquals(getObjectName("manager-properties", null), on);
on = configsMBean.getManagerProperties(getTargetName());
Assert.assertEquals(getObjectName("manager-properties", null), on);
isDeleted = configsMBean.deleteManagerProperties(getTargetName());
Assert.assertTrue(isDeleted);
on = configsMBean.createStoreProperties(null, null, getTargetName());
Assert.assertEquals(getObjectName("store-properties", null), on);
on = configsMBean.getStoreProperties(getTargetName());
Assert.assertEquals(getObjectName("store-properties", null), on);
isDeleted = configsMBean.deleteStoreProperties(getTargetName());
Assert.assertTrue(isDeleted);
isDeleted = configsMBean.deleteSessionConfig(getTargetName());
Assert.assertTrue(isDeleted);
|
public void | testThreadPool()
final AttributeList attrs = new AttributeList();
attrs.add(new Attribute("thread-pool-id", "testPool"));
ObjectName on = configsMBean.createThreadPool(
attrs, null, getTargetName());
ObjectName[] onames = configsMBean.listThreadPools(getTargetName());
Assert.assertTrue(onames != null);
Assert.assertTrue(onames.length > 0);
Assert.assertTrue(exists(getThreadPool("testPool"), onames));
boolean isDeleted = configsMBean.deleteThreadPool(
"testPool", getTargetName());
Assert.assertTrue(isDeleted);
onames = configsMBean.listThreadPools(getTargetName());
Assert.assertTrue(!exists(getThreadPool("testPool"), onames));
|
public void | testVirtualServer()
final String target = getTargetName();
ObjectName on = configsMBean.createVirtualServer(
getVirtualServerAttrs(), null, target);
Assert.assertTrue(on != null);
Assert.assertEquals(getVirtualServer(), on);
ObjectName[] names = configsMBean.listVirtualServers(target);
Assert.assertTrue(names != null);
Assert.assertTrue(names.length > 0);
Assert.assertTrue(exists(getVirtualServer(), names));
boolean isDeleted = configsMBean.deleteVirtualServer(
"my-virtual-server", null);
Assert.assertTrue(isDeleted);
names = configsMBean.listVirtualServers(target);
Assert.assertFalse(exists(getVirtualServer(), names));
|