use of com.axway.ats.environment.file.DirectoryEnvironmentUnit 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.file.DirectoryEnvironmentUnit in project ats-framework by Axway.
the class ConfigurationParser method parseDirectoryEnvironment.
/**
* Parse the directory environment node in the Agent descriptor.
*
* @param directoryEnvironmentNode the directory environment node.
* @throws AgentException on error.
*/
private EnvironmentUnit parseDirectoryEnvironment(Node directoryEnvironmentNode, String backupFolder) {
String originalDir = directoryEnvironmentNode.getAttributes().getNamedItem("path").getNodeValue();
originalDir = IoUtils.normalizeDirPath(originalDir);
String backupName;
if (directoryEnvironmentNode.getAttributes().getNamedItem("backupName") != null) {
backupName = directoryEnvironmentNode.getAttributes().getNamedItem("backupName").getNodeValue();
} else {
// remove the last slash and get the directory name as a file name
backupName = IoUtils.getFileName(originalDir.substring(0, originalDir.length() - 1));
}
// get the optional addition actions to executed on directory restore
List<AdditionalAction> additionalActions = parseAdditionalActions(directoryEnvironmentNode);
DirectoryEnvironmentUnit directoryEnvironment = new DirectoryEnvironmentUnit(originalDir, backupFolder, backupName);
directoryEnvironment.addAdditionalActions(additionalActions);
return directoryEnvironment;
}
use of com.axway.ats.environment.file.DirectoryEnvironmentUnit in project ats-framework by Axway.
the class ComponentEnvironment method getNewCopy.
public ComponentEnvironment getNewCopy() {
ComponentEnvironment newComponentEnvironment = new ComponentEnvironment(this.componentName, this.environmentName, null, this.backupFolder);
List<EnvironmentUnit> newEnvironmentUnits = new ArrayList<EnvironmentUnit>();
for (EnvironmentUnit environmentUnit : this.environmentUnits) {
EnvironmentUnit newEnvironmentUnit;
if (environmentUnit instanceof DatabaseEnvironmentUnit) {
newEnvironmentUnit = ((DatabaseEnvironmentUnit) environmentUnit).getNewCopy();
} else if (environmentUnit instanceof FileEnvironmentUnit) {
newEnvironmentUnit = ((FileEnvironmentUnit) environmentUnit).getNewCopy();
} else {
// it is instance of DirectoryEnvironmentUnit
newEnvironmentUnit = ((DirectoryEnvironmentUnit) environmentUnit).getNewCopy();
}
newEnvironmentUnits.add(newEnvironmentUnit);
}
newComponentEnvironment.environmentUnits = newEnvironmentUnits;
return newComponentEnvironment;
}
Aggregations