use of com.axway.ats.environment.process.SystemProcessAction in project ats-framework by Axway.
the class Test_ConfigurationParser method testAdditionalActionOfFileEnvironmentUnit.
@Test
public void testAdditionalActionOfFileEnvironmentUnit() throws Exception {
InputStream _descriptorFileStream = Test_ConfigurationParser.class.getClassLoader().getResourceAsStream("test_descriptors/test_agent_descriptor_with_additional_actions.xml");
ConfigurationParser configParser = new ConfigurationParser();
configParser.parse(_descriptorFileStream, jarFileAbsolutePath);
List<EnvironmentUnit> environmentUnits = configParser.getEnvironments().get(0).getEnvironmentUnits();
assertEquals(3, environmentUnits.size());
// check unit 1
FileEnvironmentUnit fUnit1 = (FileEnvironmentUnit) environmentUnits.get(0);
assertEquals(0, fUnit1.getAdditionalActions().size());
// check unit 2
FileEnvironmentUnit fUnit2 = (FileEnvironmentUnit) environmentUnits.get(1);
assertEquals(1, fUnit2.getAdditionalActions().size());
SystemProcessAction proc1 = (SystemProcessAction) fUnit2.getAdditionalActions().get(0);
assertEquals(3, proc1.getSleepInterval());
assertEquals(" shell command 'proc1'", proc1.getDescription());
// check unit 3
FileEnvironmentUnit fUnit3 = (FileEnvironmentUnit) environmentUnits.get(2);
assertEquals(2, fUnit3.getAdditionalActions().size());
SystemProcessAction proc2 = (SystemProcessAction) fUnit3.getAdditionalActions().get(0);
assertEquals(5, proc2.getSleepInterval());
assertEquals(" shell command 'proc1'", proc2.getDescription());
SystemProcessAction proc3 = (SystemProcessAction) fUnit3.getAdditionalActions().get(1);
assertEquals(0, proc3.getSleepInterval());
assertEquals(" shell command 'proc2'", proc3.getDescription());
}
use of com.axway.ats.environment.process.SystemProcessAction in project ats-framework by Axway.
the class Test_ConfigurationParser method testParsingMoreEnvironments.
@Test
public void testParsingMoreEnvironments() throws Exception {
InputStream _descriptorFileStream = Test_ConfigurationParser.class.getClassLoader().getResourceAsStream("test_descriptors/test_agent_descriptor_with_more_env.xml");
ConfigurationParser configParser = new ConfigurationParser();
configParser.parse(_descriptorFileStream, jarFileAbsolutePath);
List<ComponentEnvironment> environments = configParser.getEnvironments();
assertEquals(2, environments.size());
assertEquals("env1", environments.get(0).getEnvironmentName());
assertEquals("env2", environments.get(1).getEnvironmentName());
assertEquals(2, environments.get(0).getEnvironmentUnits().size());
assertEquals(1, environments.get(1).getEnvironmentUnits().size());
// check unit 1 of env1
FileEnvironmentUnit fUnit1 = (FileEnvironmentUnit) environments.get(0).getEnvironmentUnits().get(0);
assertEquals(0, fUnit1.getAdditionalActions().size());
// check unit 2 of env1
FileEnvironmentUnit fUnit2 = (FileEnvironmentUnit) environments.get(0).getEnvironmentUnits().get(1);
assertEquals(1, fUnit2.getAdditionalActions().size());
SystemProcessAction proc1 = (SystemProcessAction) fUnit2.getAdditionalActions().get(0);
assertEquals(3, proc1.getSleepInterval());
assertEquals(" shell command 'proc1'", proc1.getDescription());
// check unit 1 of env2
assertTrue(environments.get(1).getEnvironmentUnits().get(0) instanceof DirectoryEnvironmentUnit);
}
use of com.axway.ats.environment.process.SystemProcessAction in project ats-framework by Axway.
the class ConfigurationParser method parseAdditionalActions.
/**
* @param environmentNode
* @return
*/
private List<AdditionalAction> parseAdditionalActions(Node environmentNode) {
NodeList environmentNodeChildren = environmentNode.getChildNodes();
List<AdditionalAction> actions = new ArrayList<AdditionalAction>();
for (int i = 0; i < environmentNodeChildren.getLength(); i++) {
Node environmentNodeChild = environmentNodeChildren.item(i);
if (environmentNodeChild.getNodeName().equals("action")) {
String shellCommand;
int sleepInterval;
Node shellCommandNode = environmentNodeChild.getAttributes().getNamedItem("command");
Node sleepNode = environmentNodeChild.getAttributes().getNamedItem("sleep");
if (shellCommandNode != null && sleepNode != null) {
shellCommand = shellCommandNode.getNodeValue();
sleepInterval = Integer.parseInt(sleepNode.getNodeValue().trim());
actions.add(new SystemProcessAction(shellCommand, sleepInterval));
}
}
}
return actions;
}
Aggregations