use of com.axway.ats.environment.EnvironmentUnit in project ats-framework by Axway.
the class ComponentEnvironment method restore.
public void restore(String folderPath) throws AgentException {
// All additional actions are implicitly added to the Additional Actions Queue Instance
try {
for (EnvironmentUnit environmentUnit : environmentUnits) {
environmentUnit.setTempBackupDir(folderPath);
environmentUnit.restore();
}
} catch (EnvironmentCleanupException ece) {
throw new AgentException("Could not restore environment for component '" + this.componentName + "'" + recurseCauses(ece), ece);
}
// Now execute the additional actions and clean the queue
try {
AdditionalActionsQueue.getInstance().flushAllActions();
} catch (EnvironmentCleanupException ece) {
throw new AgentException("Could not restore environment for component '" + this.componentName + "'" + recurseCauses(ece), ece);
}
}
use of com.axway.ats.environment.EnvironmentUnit in project ats-framework by Axway.
the class Test_DirectoryEnvironmentUnit method restore_aNewFileMustBeDeleted.
// TODO - investigate failing error. It is just on CI machine, only when run from Jenkins
@Ignore
@Test
public void restore_aNewFileMustBeDeleted() throws EnvironmentCleanupException, IOException {
EnvironmentUnit dirEnvUnit = new DirectoryEnvironmentUnit(restoreDirPath, backupDirPath, backupDirName);
Assert.assertTrue(dirEnvUnit.restore());
new File(restoreDirPath + "newFile.txt").createNewFile();
// now the restore is not needed
Assert.assertTrue(dirEnvUnit.restore());
}
use of com.axway.ats.environment.EnvironmentUnit in project ats-framework by Axway.
the class Test_DirectoryEnvironmentUnit method restore.
@Test
public void restore() throws EnvironmentCleanupException {
EnvironmentUnit dirEnvUnit = new DirectoryEnvironmentUnit(restoreDirPath, backupDirPath, backupDirName);
Assert.assertTrue(dirEnvUnit.restore());
}
use of com.axway.ats.environment.EnvironmentUnit in project ats-framework by Axway.
the class Test_ConfigurationParser method getEnvironmentUnitsWithPort.
@Test
public void getEnvironmentUnitsWithPort() throws Exception {
InputStream descriptorFileStream = Test_ConfigurationParser.class.getResourceAsStream("descriptor_with_port.xml");
ConfigurationParser configParser = new ConfigurationParser();
configParser.parse(descriptorFileStream, jarFileAbsolutePath);
List<EnvironmentUnit> environmentUnits = configParser.getEnvironments().get(0).getEnvironmentUnits();
assertEquals(3, environmentUnits.size());
assertEquals(DatabaseEnvironmentUnit.class, environmentUnits.get(0).getClass());
assertEquals(FileEnvironmentUnit.class, environmentUnits.get(1).getClass());
assertEquals(FileEnvironmentUnit.class, environmentUnits.get(2).getClass());
// check connection properties
DatabaseEnvironmentUnit dbUnit = (DatabaseEnvironmentUnit) configParser.getEnvironments().get(0).getEnvironmentUnits().get(0);
assertEquals("127.127.127.127", dbUnit.getDbConnection().getHost());
assertEquals("st", dbUnit.getDbConnection().getDb());
assertEquals("root", dbUnit.getDbConnection().getUser());
assertEquals("axway", dbUnit.getDbConnection().getPassword());
assertEquals("mysql".toUpperCase(), dbUnit.getDbConnection().getDbType().toString());
Map<String, Object> customDbConnectionProperties = dbUnit.getDbConnection().getCustomProperties();
assertEquals(33060, customDbConnectionProperties.get(DbKeys.PORT_KEY));
}
use of com.axway.ats.environment.EnvironmentUnit in project ats-framework by Axway.
the class ComponentEnvironment method backup.
public void backup(String folderPath) throws AgentException {
log.info("Backuping environment for component " + componentName);
try {
String currentBackupFolder = backupFolder;
if (folderPath != null) {
currentBackupFolder = folderPath;
}
//if the current backup folder already exists and is not empty, we will rename it in order to have
//a clean backup and to save the previous backup data
File backupDir = new File(currentBackupFolder);
if (backupDir.isDirectory() && backupDir.list().length > 0) {
String backupFolderPath = currentBackupFolder;
if (currentBackupFolder.endsWith("/") || currentBackupFolder.endsWith("\\")) {
backupFolderPath = currentBackupFolder.substring(0, currentBackupFolder.length() - 1);
}
backupFolderPath = backupFolderPath + BACKUP_DATE_FORMATTER.format(new Date());
backupFolderPath = IoUtils.normalizeDirPath(backupFolderPath);
log.info("In order to have a clean backup, we'll rename the current backup folder: " + backupFolderPath);
backupDir.renameTo(new File(backupFolderPath));
}
for (EnvironmentUnit environmentUnit : environmentUnits) {
environmentUnit.setTempBackupDir(folderPath);
environmentUnit.backup();
}
} catch (EnvironmentCleanupException ece) {
throw new AgentException("Could not backup environment for component " + componentName + recurseCauses(ece), ece);
}
}
Aggregations