Search in sources :

Example 6 with OperatingSystemType

use of com.axway.ats.common.system.OperatingSystemType in project ats-framework by Axway.

the class Test_ConfigurationParser method testBackupDirectory_NoBackupName_forWindows.

@Test
public void testBackupDirectory_NoBackupName_forWindows() throws Exception {
    OperatingSystemType currentOs = OperatingSystemType.getCurrentOsType();
    simulateOS(OperatingSystemType.WINDOWS);
    try {
        InputStream _descriptorFileStream = Test_ConfigurationParser.class.getClassLoader().getResourceAsStream("test_descriptors/test_agent_descriptor_windows_backup_folder.xml");
        ConfigurationParser configParser = new ConfigurationParser();
        configParser.parse(_descriptorFileStream, jarFileAbsolutePath);
        String backupFileName = getBackupDirName((DirectoryEnvironmentUnit) configParser.getEnvironments().get(0).getEnvironmentUnits().get(2));
        if (currentOs.isWindows()) {
            assertEquals(IoUtils.normalizeDirPath("C:/agent_backup_dir/original dir2/"), backupFileName);
        } else {
            // due to file canonicalization path is interpreted as relative and gets like this:
            // /home/user/workspace/.../C:/agent_backup_dir/original dir2/
            backupFileName.endsWith(IoUtils.normalizeDirPath("C:/agent_backup_dir/original dir2/"));
        }
    } finally {
        simulateOS(currentOs);
    }
}
Also used : InputStream(java.io.InputStream) OperatingSystemType(com.axway.ats.common.system.OperatingSystemType) Test(org.junit.Test)

Example 7 with OperatingSystemType

use of com.axway.ats.common.system.OperatingSystemType in project ats-framework by Axway.

the class Test_ConfigurationParser method testBackupFolder_forUnix.

@Test
public void testBackupFolder_forUnix() throws Exception {
    OperatingSystemType currentOs = OperatingSystemType.getCurrentOsType();
    simulateOS(OperatingSystemType.LINUX);
    try {
        InputStream _descriptorFileStream = Test_ConfigurationParser.class.getClassLoader().getResourceAsStream("test_descriptors/test_agent_descriptor_unix_backup_folder.xml");
        ConfigurationParser configParser = new ConfigurationParser();
        configParser.parse(_descriptorFileStream, jarFileAbsolutePath);
        assertEquals(1, configParser.getEnvironments().get(0).getEnvironmentUnits().size());
        String backupFileName = getBackupFileName((FileEnvironmentUnit) configParser.getEnvironments().get(0).getEnvironmentUnits().get(0));
        assertEquals(IoUtils.normalizeFilePath("/var/backup/agent_backup/backup_test.txt"), backupFileName);
    } finally {
        simulateOS(currentOs);
    }
}
Also used : InputStream(java.io.InputStream) OperatingSystemType(com.axway.ats.common.system.OperatingSystemType) Test(org.junit.Test)

Aggregations

OperatingSystemType (com.axway.ats.common.system.OperatingSystemType)7 InputStream (java.io.InputStream)6 Test (org.junit.Test)6 SystemOperationException (com.axway.ats.common.system.SystemOperationException)1 AWTException (java.awt.AWTException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1