Skip to content

Commit

Permalink
#63: improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Jun 12, 2011
1 parent ff2defc commit 61043ab
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.net.URI;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,66 @@ public class TestPlannerImpl extends GroovyTestCase
{
assertNull(planner.computeDeploymentPlan(Type.SEQUENTIAL, null))

Plan<ActionDescriptor> plan = plan(Type.SEQUENTIAL,
delta(m([agent: 'a1', mountPoint: 'm1', script: 's1']),
m([agent: 'a1', mountPoint: 'm1', script: 's1'])))
[Type.SEQUENTIAL, Type.PARALLEL].each { Type type ->
Plan<ActionDescriptor> p = plan(type,
delta(m([agent: 'a1', mountPoint: 'm1', script: 's1']),
m([agent: 'a1', mountPoint: 'm1', script: 's1'])))

println plan.toXml()
assertEquals(type, p.step.type)
assertEquals(0, p.leafStepsCount)
}
}

/**
* When delta means deploy (not in current)
*/
public void testDeploymentPlanDeploy()
{
Plan<ActionDescriptor> plan = plan(Type.SEQUENTIAL,
delta(m([agent: 'a1', mountPoint: 'm1', script: 's1']),
m()))

println plan.toXml()
Plan<ActionDescriptor> p = plan(Type.SEQUENTIAL,
delta(m([agent: 'a1', mountPoint: 'm1', script: 's1']),
m()))

assertEquals(Type.SEQUENTIAL, p.step.type)
assertEquals(4, p.leafStepsCount)
assertEquals("""<?xml version="1.0"?>
<plan>
<sequential>
<sequential>
<leaf description="TODO script lifecycle: INSTALL_SCRIPT" agent="a1" mountPoint="a1" scriptLifecycle="install_script" />
<leaf description="TODO script action: install" agent="a1" mountPoint="a1" scriptTransition="install" />
<leaf description="TODO script action: configure" agent="a1" mountPoint="a1" scriptTransition="configure" />
<leaf description="TODO script action: start" agent="a1" mountPoint="a1" scriptTransition="start" />
</sequential>
</sequential>
</plan>
""", p.toXml())
// TODO HIGH YP: add more tests
}

/**
* When delta means undeploy (not in expected)
*/
public void testDeploymentPlanUnDeploy()
{
Plan<ActionDescriptor> plan = plan(Type.SEQUENTIAL,
delta(m(),
m([agent: 'a1', mountPoint: 'm1', script: 's1'])))

println plan.toXml()
Plan<ActionDescriptor> p = plan(Type.SEQUENTIAL,
delta(m(),
m([agent: 'a1', mountPoint: 'm1', script: 's1'])))

assertEquals(Type.SEQUENTIAL, p.step.type)
assertEquals(4, p.leafStepsCount)
assertEquals("""<?xml version="1.0"?>
<plan>
<sequential>
<sequential>
<leaf description="TODO script action: stop" agent="a1" mountPoint="m1" scriptTransition="stop" />
<leaf description="TODO script action: unconfigure" agent="a1" mountPoint="m1" scriptTransition="unconfigure" />
<leaf description="TODO script action: uninstall" agent="a1" mountPoint="m1" scriptTransition="uninstall" />
<leaf description="TODO script lifecycle: UNINSTALL_SCRIPT" agent="a1" mountPoint="m1" scriptLifecycle="uninstall_script" />
</sequential>
</sequential>
</plan>
""", p.toXml())
// TODO HIGH YP: add more tests
}

private SystemModel m(Map... entries)
Expand Down

0 comments on commit 61043ab

Please sign in to comment.