Methods Summary |
---|
public static void | main(java.lang.String[] args)
final TestRunner runner= new TestRunner();
final TestResult result = runner.doRun(S1ASCommandTest.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 S1ASCommand() {
public void runCommand()
throws CommandException, CommandValidationException
{
setProperties(new Properties());
}
public boolean validateOptions() throws CommandValidationException
{
return true;
}
};
testCommand.setName("sampleCommand");
testCommand.runCommand();
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(S1ASCommandTest.class);
return suite;
|
protected void | tearDown()
|
public void | testCheckForFileExistence()
final File f = File.createTempFile("S1ASCommandTest_testCheckForFileExistence", ".tmp");
f.deleteOnExit();
String tempdir = System.getProperty("java.io.tmpdir");
assertTrue(testCommand.checkForFileExistence(tempdir, f.getName()).exists());
|
public void | testCheckForFileExistenceWhenNoFile()
String tempdir = System.getProperty("java.io.tmpdir");
try{
File f = testCommand.checkForFileExistence(tempdir, "FileDoesNotExist");
}catch (Exception e){
assertEquals(e.getMessage(), "CLI146 FileDoesNotExist does not exist in the file system or read permission denied.");
}
|
public void | testCreatePropertiesParam()
String propStr = "name=value";
Properties props = testCommand.createPropertiesParam(propStr);
assertEquals(props.getProperty("name"),"value");
|
public void | testCreatePropertiesParamInvalid()
String propStr = "name1=value1:value2";
try{
Properties props = testCommand.createPropertiesParam(propStr);
}catch (Exception e){
assertEquals(e.getMessage(), "CLI131 Invalid property syntax.");
}
|
public void | testCreatePropertiesParamWithEscapes()
String propStr = "user=dbuser:password=dbpassword:DatabaseName=jdbc\\:pointbase:server=http\\://localhost\\:9292";
Properties props = testCommand.createPropertiesParam(propStr);
assertEquals(props.getProperty("user"),"dbuser");
assertEquals(props.getProperty("password"), "dbpassword");
assertEquals(props.getProperty("DatabaseName"), "jdbc:pointbase");
assertEquals(props.getProperty("server"), "http://localhost:9292");
|
public void | testCreateStringArrayParam()
String paramStr = "value1:value2";
String[] params = testCommand.createStringArrayParam(paramStr);
assertEquals(params[0],"value1");
assertEquals(params[1],"value2");
|
public void | testCreateStringArrayParamWithEscapes()
String paramStr = "-XX\\:NewRatio=2";
String[] params = testCommand.createStringArrayParam(paramStr);
assertEquals(params[0],"-XX:NewRatio=2");
|
public void | testDisplayExceptionMessage()
NullPointerException npe = new NullPointerException("a null pointer");
try{
testCommand.displayExceptionMessage(npe);
}
catch (CommandException ce){
assertEquals(npe, ExceptionUtil.getRootCause(ce));
}
|
public void | testgetHost()
testCommand.setOption("host", "localhost");
assertEquals(testCommand.getHost(),"localhost");
|
public void | testgetInteractiveOptionWhenFalse()
final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
ValidCommand validCommand = cliDescriptorsReader.getCommand(null);
LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(
CLIDescriptorsReader.getInstance().getProperties());
testCommand.setOption("interactive", "false");
try{
testCommand.getInteractiveOption("test", "test");
}
catch (CommandValidationException cve){
assertEquals(cve.getMessage(), "CLI152 test is a required option.");
}
|
public void | testgetObjectName()
Vector propertyValues = new Vector();
propertyValues.add("test_objectname");
testCommand.setProperty(testCommand.OBJECT_NAME, propertyValues);
assertEquals(testCommand.getObjectName(), "test_objectname");
|
public void | testgetOperationName()
Vector propertyValues = new Vector();
propertyValues.add("testMethod");
testCommand.setProperty(testCommand.OPERATION, propertyValues);
assertEquals(testCommand.getOperationName(), "testMethod");
|
public void | testgetParamsInfo()
Vector typesValues = new Vector();
for (int i=0; i<3; i++){
typesValues.add("java.lang.String");
}
testCommand.setProperty(testCommand.PARAM_TYPES, typesValues);
Vector paramValues = new Vector();
for (int i=0; i<3; i++){
paramValues.add("x"+i);
}
testCommand.setProperty(testCommand.PARAMS, paramValues);
Object[] params = testCommand.getParamsInfo();
for (int i=0; i<params.length; i++)
assertEquals((String)params[i], "x"+i);
|
public void | testgetParamsInfoInvalid()
//#of param typess is not equal to #of param values
Vector typesValues = new Vector();
typesValues.add("java.lang.String");
typesValues.add("java.lang.String");
testCommand.setProperty(testCommand.PARAM_TYPES, typesValues);
Vector paramValues = new Vector();
for (int i=0; i<3; i++){
paramValues.add("x"+i);
}
testCommand.setProperty(testCommand.PARAMS, paramValues);
try{
Object[] params = testCommand.getParamsInfo();
}catch (CommandException ce){
assertEquals(ce.getMessage(),
"CLI174 Error in CLIDescriptor.xml -- The number of params doesn''t match the number of param-types. Solution: edit this command in CLIDescriptor.xml.");
}
|
public void | testgetPasswordFromCommandLine()
testCommand.setOption("password", "test_password");
String pwd = testCommand.getPassword(testCommand.PASSWORD, null, null,
true, false, false, false, null, null, false,
false, true, false);
assertEquals(pwd, "test_password");
|
public void | testgetPasswordFromPrefsFile()
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_PASSWORD=test_password");
pw.close();
System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
//set the readPrefsFile & readPasswordOptionFromPrefs to true
String pwd = testCommand.getPassword(testCommand.PASSWORD, null, null,
false, true, true, false, null, null, false,
false, true, false);
assertEquals(pwd, "test_password");
|
public void | testgetPasswordWhenNotSet()
String pwd = testCommand.getPassword(testCommand.PASSWORD, null, null,
false, false, false, false, null, null, false,
false, false, false);
assertEquals(pwd, null);
|
public void | testgetPort()
testCommand.setOption(testCommand.PORT, "4848");
assertEquals(testCommand.getPort(), 4848);
|
public void | testgetPortInvalid()
try{
testCommand.setOption(testCommand.PORT, "xyz");
testCommand.getPort();
}catch (Exception e){
assertEquals(e.getMessage(), "CLI136 Port xyz should be a numeric value.");
}
|
public void | testgetReturnType()
Vector propertyValues = new Vector();
propertyValues.add("java.lang.String");
testCommand.setProperty(testCommand.RETURN_TYPE, propertyValues);
assertEquals(testCommand.getReturnType(), "java.lang.String");
|
public void | testgetTypesInfo()
Vector propertyValues = new Vector();
for (int i=0; i<=3; i++){
propertyValues.add("java.lang.String");
}
testCommand.setProperty(testCommand.PARAM_TYPES, propertyValues);
String[] types = testCommand.getTypesInfo();
for (int i=0; i<types.length; i++)
assertEquals(types[i], "java.lang.String");
|
public void | testgetUserFromCommandLine()
testCommand.setOption("user", "admin");
String user = testCommand.getUser();
assertEquals(user, "admin");
|
public void | testgetUserFromPrefsFile()
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=admin");
pw.close();
System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
//set the readPrefsFile & readPasswordOptionFromPrefs to true
String user = testCommand.getUser();
assertEquals(user, "admin");
|
public void | testgetUserWhenNotSet()
try{
String adminUser = testCommand.getUser();
}catch(Exception e){
assertEquals(e.getMessage(), "CLI152 user is a required option.");
}
|
public void | testgetValuesFromASADMINPREFS()
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_PASSWORD=test_password");
pw.close();
System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
assertEquals(testCommand.getValuesFromASADMINPREFS(testCommand.PASSWORD),
"test_password");
|
public void | testisPasswordValid()
boolean isValid = testCommand.isPasswordValid("eightOrMoreCharacters");
assertEquals(isValid, true);
isValid = testCommand.isPasswordValid("7chars");
assertEquals(isValid, false);
|
public void | testreplacePattern()
Vector typesValues = new Vector();
typesValues.add("java.lang.String");
testCommand.setProperty(testCommand.PARAM_TYPES, typesValues);
testCommand.setOption("testOption", "test");
Vector paramValues = new Vector();
paramValues.add("{$testOption}");
testCommand.setProperty(testCommand.PARAMS, paramValues);
Object[] params = testCommand.getParamsInfo();
assertEquals((String)params[0], "test");
|
public void | testsetLoggerLevel()
testCommand.setOption(testCommand.TERSE, "false");
testCommand.setLoggerLevel();
assertEquals(CLILogger.getInstance().getOutputLevel(),java.util.logging.Level.FINE);
testCommand.setOption(testCommand.TERSE, "true");
testCommand.setLoggerLevel();
assertEquals(CLILogger.getInstance().getOutputLevel(),java.util.logging.Level.INFO);
|