Methods Summary |
---|
private java.lang.String | createDomainFileSystem(java.lang.String domainParent, java.lang.String domainName)
final File domainParentDir = new File(System.getProperty("java.io.tmpdir"), domainParent);
domainParentDir.mkdir();
domainParentDir.deleteOnExit();
if (domainName == null) return domainParentDir.getPath();
final File domainDir = new File(domainParentDir, domainName);
domainDir.mkdir();
domainDir.deleteOnExit();
final File binDir = new File(domainDir, PEFileLayout.BIN_DIR);
binDir.mkdir();
binDir.deleteOnExit();
//System.out.println(PEFileLayout.START_SERV_OS);
final File f = new File(binDir, PEFileLayout.START_SERV_OS);
f.createNewFile();
f.deleteOnExit();
return domainParentDir.getPath();
|
public static void | main(java.lang.String[] args)
final TestRunner runner= new TestRunner();
final TestResult result = runner.doRun(BaseLifeCycleCommandTest.suite(), false);
System.exit(result.errorCount() + result.failureCount());
|
private void | nyi()
fail("Not Yet Implemented");
|
protected void | setUp()
//Properties systemProperties = new java.util.Propertis();
//systemProperties.put("com.sun.aas.configRoot",)
//String configProperty = SystemPropertyConstants.CONFIG_ROOT_PROPERTY;
//System.out.println(configProperty + " = " + System.getProperty(configProperty));
final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
ValidCommand validCommand = cliDescriptorsReader.getCommand(null);
LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(
CLIDescriptorsReader.getInstance().getProperties());
testCommand = new BaseLifeCycleCommand() {
public void runCommand()
throws CommandException, CommandValidationException {
}
public boolean validateOptions() throws CommandValidationException {
return true;
}
};
testCommand.setName("sampleCommand");
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(BackupCommandsTest.class);
return suite;
|
protected void | tearDown()
|
public void | testIsSpaceInPathFalse()
assertEquals(testCommand.isSpaceInPath("StringHasNospace"), false);
|
public void | testIsSpaceInPathTrue()
assertEquals(testCommand.isSpaceInPath("String has space"), true);
|
public void | testgetAdminUserFromCommandLine()
testCommand.setOption("adminuser", "userFromCommandLine");
String adminUser = testCommand.getAdminUser();
assertEquals(adminUser, "userFromCommandLine");
|
public void | testgetAdminUserFromPrefsFile()
final String enc = "ISO-8859-1";
final File f = new File(System.getProperty("java.io.tmpdir"),
testCommand.ASADMINPREFS);
f.deleteOnExit();
final PrintWriter pw = new PrintWriter(
new OutputStreamWriter(new FileOutputStream(f), enc));
pw.println("AS_ADMIN_ADMINUSER=adminuserFromPrefsFile");
pw.close();
System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
String adminUser = testCommand.getAdminUser();
assertEquals(adminUser, "adminuserFromPrefsFile");
|
public void | testgetAdminUserFromPrefsFileUsingUserOption()
final String enc = "ISO-8859-1";
final File f = new File(System.getProperty("java.io.tmpdir"),
testCommand.ASADMINPREFS);
f.deleteOnExit();
final PrintWriter pw = new PrintWriter(
new OutputStreamWriter(new FileOutputStream(f), enc));
pw.println("AS_ADMIN_USER=userFromPrefsFile");
pw.close();
System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
String adminUser = testCommand.getAdminUser();
assertEquals(adminUser, "userFromPrefsFile");
|
public void | testgetAdminUserWhenNotSet()
try{
String adminUser = testCommand.getAdminUser();
}catch(Exception e){
assertEquals(e.getMessage(), "CLI152 adminuser is a required option.");
}
|
public void | testgetDomainNameFromFileSystem()
String domainName = "test_domain";
String dirName = createDomainFileSystem("testgetDomainNameFromFileSystem", domainName);
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, dirName);
assertEquals(testCommand.getDomainName(), domainName);
|
public void | testgetDomainNameFromFileSystemWhenNone()
String dirName = "domainsDirXYZ";
File domaindir = new File(System.getProperty("java.io.tmpdir"), dirName);
try{
domaindir.mkdir();
domaindir.deleteOnExit();
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, domaindir.getAbsolutePath());
String domainName = testCommand.getDomainName();
} catch (Exception e)
{
assertEquals(e.getMessage(), "CLI142 No domains in " +
domaindir.getAbsolutePath() + ".");
}
|
public void | testgetDomainNameFromFileSystemWithMultipleDomains()
String dirName = "";
try{
String domainName1 = "test_domain1";
dirName = createDomainFileSystem("testgetDomainNameFromFileSystemWithMultipleDomains", domainName1);
String domainName2 = "test_domain2";
createDomainFileSystem("testgetDomainNameFromFileSystemWithMultipleDomains", domainName2);
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, dirName);
String domainName = testCommand.getDomainName();
} catch (Exception e)
{
assertEquals(e.getMessage(), "There is more than one domain in " +
dirName +
". Please use operand to specify the domain.");
}
|
public void | testgetDomainNameOperandFromCommandLine()
Vector operands = new Vector();
operands.add("test_domain");
testCommand.setOperands(operands);
//assuming there is a default domain
|
public void | testgetDomainNameOptionFromCommandLine()
testCommand.setOption("domain", "test_domain");
//assuming there is a default domain
assertEquals(testCommand.getDomainName(), "test_domain");
|
public void | testgetDomainNameWhenZero()
try{
Vector operands = new Vector();
operands.add("UndefinedDomain");
testCommand.setOperands(operands);
testCommand.getDomainName();
} catch (Exception e)
{
assertEquals(e.getMessage(), "CLI156 Could not start the domain UndefinedDomain.");
}
|
public void | testgetDomainsRootFromCommandLine()
testCommand.setOption("domaindir", "test_domain");
assertEquals(testCommand.getDomainsRoot(), "test_domain");
|
public void | testgetDomainsRootFromSystemProperty()
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, "test_domain");
assertEquals(testCommand.getDomainsRoot(), "test_domain");
|
public void | testgetDomainsWhenMultiple()
String domainName1 = "test_domain1";
String dirName = createDomainFileSystem("testgetDomainsWhenMultiple", domainName1);
String domainName2 = "test_domain2";
createDomainFileSystem("testgetDomainsWhenMultiple", domainName2);
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, dirName);
String[] domains = testCommand.getDomains();
assertEquals(domains[0], domainName1);
assertEquals(domains[1], domainName2);
|
public void | testgetDomainsWhenOne()
String domainName = "test_domain1";
String dirName = createDomainFileSystem("testgetDomainsWhenOne", domainName);
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, dirName);
String[] domains = testCommand.getDomains();
assertEquals(domains[0], domainName);
|
public void | testgetDomainsWhenZero()
String dirName = createDomainFileSystem("testgetDomainsWhenZero", null);
System.setProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY, dirName);
String[] domains = testCommand.getDomains();
assertEquals(domains.length, 0);
|
public void | testisWindows()
String os = System.getProperty("os.name").toLowerCase();
assertEquals(testCommand.isWindows(), (os.indexOf("windows") != -1) ? true : false);
|