Skip to content

Commit

Permalink
Fix exec tool test for assumed node osFamily
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Nov 11, 2011
1 parent 9a98fc0 commit eab617f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
40 changes: 25 additions & 15 deletions core/src/test/java/com/dtolabs/rundeck/core/cli/TestExecTool.java
Expand Up @@ -99,6 +99,8 @@ public void tearDown() throws Exception {
FrameworkProject d2 = getFrameworkInstance().getFrameworkProjectMgr().createFrameworkProject(
TEST_EXEC_TOOL_PROJ2);
FileUtils.deleteDir(d2.getBaseDir());


getFrameworkInstance().getFrameworkProjectMgr().remove(TEST_EXEC_TOOL_PROJ2);
// ExecutionServiceFactory.resetDefaultExecutorClasses();
getFrameworkInstance().setService(CommandInterpreterService.SERVICE_NAME, null);
Expand Down Expand Up @@ -244,11 +246,11 @@ public void testFilterNodes() {
{
ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT, "-X", "strongbad,homestar",
"-I", "os-family=unix"});
"-I", "os-family=fakeos"});
Map exmap = main.parseExcludeArgs(nodeKeys);
Map incmap = main.parseIncludeArgs(nodeKeys);
final Collection c = main.filterNodes().getNodes();
assertEquals("wrong size", 2, c.size());
assertEquals("wrong size", 1, c.size());
}
}

Expand Down Expand Up @@ -284,14 +286,14 @@ public void testDefaultNodeFormatter() {
{
ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT, "-X", "strongbad,homestar",
"-I", "os-family=unix"});
"-I", "os-family=fakeos"});
Map exmap = main.parseExcludeArgs(nodeKeys);
Map incmap = main.parseIncludeArgs(nodeKeys);
final Collection c = main.filterNodes().getNodes();
assertEquals("wrong size", 2, c.size());
assertEquals("wrong size", 1, c.size());
final String result = new ExecTool.DefaultNodeFormatter().formatResults(c).toString();
assertNotNull(result);
assertEquals("doesn't contain correct result", "cheat test1", result);
assertEquals("doesn't contain correct result", "cheat", result);
}
}

Expand Down Expand Up @@ -334,15 +336,15 @@ public void testListAction() {
{
ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT, "-v", "-X", "strongbad,homestar",
"-I", "os-family=unix"});
"-I", "os-family=fakeos"});
Map exmap = main.parseExcludeArgs(nodeKeys);
Map incmap = main.parseIncludeArgs(nodeKeys);
final Collection c = main.filterNodes().getNodes();
final TestFormatter formatter = new TestFormatter();
main.setNodeFormatter(formatter);
main.listAction();
assertNotNull(formatter.nodes);
assertEquals(2, formatter.nodes.size());
assertEquals(1, formatter.nodes.size());
}
}

Expand Down Expand Up @@ -841,16 +843,24 @@ public void testWriteInputToFile() throws Exception {
ExecTool main = newExecTool();
File t = File.createTempFile(TEST_EXEC_TOOL_PROJECT, ".txt");
t.deleteOnExit();

OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(t));
osw.write(testData);
osw.flush();
osw.close();
FileOutputStream fos=new FileOutputStream(t);
try{
OutputStreamWriter osw = new OutputStreamWriter(fos);
osw.write(testData);
osw.flush();
osw.close();
}finally{
fos.close();
}

InputStream ins = new FileInputStream(t);
File temp = main.writeInputToFile(ins);
//compare file contents
assertTrue("File contents were not the same (data " + index + ")", utils.contentEquals(t, temp, true));
try{
File temp = main.writeInputToFile(ins);
//compare file contents
assertTrue("File contents were not the same (data " + index + ")", utils.contentEquals(t, temp, true));
}finally{
ins.close();
}
}
}

Expand Down
Expand Up @@ -18,7 +18,7 @@
<node name="homestar" type="Node" description="this is the testnode1 node" tags="boring,priority1"
hostname="homestar"
osArch="arm"
osFamily="unix"
osFamily="fakeos"
osName="Testux"
osVersion="10.5.1"
username="username1"
Expand All @@ -28,7 +28,7 @@
<node name="cheat" type="Node" description="registered Node asdf" tags="boring"
hostname="the@cheat"
osArch="i386"
osFamily="unix"
osFamily="fakeos"
osName="Testux"
osVersion="5.1"
>
Expand All @@ -37,7 +37,7 @@
<node name="strongbad" type="Node" description="This is the third test node" tags="priority1,elf"
hostname="strongbad"
osArch="i686"
osFamily="unix"
osFamily="fakeos"
osName="Mac OS Xzz"
osVersion="3.7"
>
Expand Down

0 comments on commit eab617f

Please sign in to comment.