Methods Summary |
---|
private com.sun.enterprise.config.ConfigContext | getConfigContext()
return ConfigFactory.createConfigContext(domainXml.getAbsolutePath());
|
private java.lang.String | getConfigRef()
return "server-config";
|
private java.lang.String | getDomainName()
return "testdomain";
|
private com.sun.enterprise.admin.mbeans.TargetTest$TargetData | getTargetData(java.lang.String name, TargetType type, java.lang.String configRef, boolean is1ToN, java.lang.String target, boolean checkConfigTarget)
TargetData td = new TargetData();
td.name = name;
td.type = type;
td.configRef = configRef;
td.is1ToN = is1ToN;
td.target = target;
td.checkConfigTarget = checkConfigTarget;
return td;
|
private java.lang.String | getTargetObjectName(java.lang.String name, TargetType type)
String on = null;
if (type.equals(TargetType.DOMAIN))
{
on = getDomainName() + ":type=domain,category=config";
}
else if (type.equals(TargetType.CONFIG))
{
on = getDomainName() + ":type=config,category=config,name=" + name;
}
else if (type.equals(TargetType.SERVER))
{
on = getDomainName() + ":type=server,category=config,name=" + name;
}
return on;
|
public static void | main(java.lang.String[] args)
final TestRunner runner= new TestRunner();
setDomainXml(new File(args[0]));
final TestResult result = runner.doRun(TargetTest.suite(), false);
System.exit(result.errorCount() + result.failureCount());
|
public static void | setDomainXml(java.io.File xml)
domainXml = xml;
|
protected void | setUp()
try
{
domainContext = getConfigContext();
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(TargetTest.class);
return suite;
|
protected void | tearDown()
domainContext = null;
|
public void | testTarget()
testTarget(getTargetData(null, TargetType.SERVER, getConfigRef(),
false, "server", true));
testTarget(getTargetData("server", TargetType.SERVER, getConfigRef(),
false, "server", true));
testTarget(getTargetData("domain", TargetType.DOMAIN, null, false,
"domain", false));
testTarget(getTargetData(getConfigRef(), TargetType.CONFIG,
getConfigRef(), false, getConfigRef(), true));
|
void | testTarget(com.sun.enterprise.admin.mbeans.TargetTest$TargetData td)
Target target = TargetBuilder.INSTANCE.createTarget(
td.name, domainContext);
Assert.assertTrue(target != null);
Assert.assertEquals(td.type, target.getType());
Assert.assertEquals(getTargetObjectName(td.target, td.type),
target.getTargetObjectName(new String[] { getDomainName() }));
Assert.assertEquals(td.configRef ,target.getConfigRef());
if (td.checkConfigTarget)
{
final ConfigTarget configTarget = target.getConfigTarget();
Assert.assertTrue(configTarget != null);
Assert.assertEquals(td.is1ToN, configTarget.is1ToN(target));
}
|
public void | testUnknownTarget()
try
{
Target target = TargetBuilder.INSTANCE.createTarget(
"abcd", domainContext);
Assert.assertTrue(false);
}
catch (Exception e) {}
try
{
Target target = TargetBuilder.INSTANCE.createTarget(null, null);
Assert.assertTrue(false);
}
catch (Exception e) {}
|