use of com.devonfw.cobigen.impl.config.upgrade.ContextConfigurationUpgrader in project cobigen by devonfw.
the class ContextConfigurationUpgraderTest method testCorrectUpgrade_v2_0_TO_LATEST.
/**
* Tests the valid upgrade of a context configuration from version v2.0 to latest version. Please make sure that
* .../ContextConfigurationUpgraderTest/valid-latest_version exists
*
* @throws Exception test fails
*/
@Test
public void testCorrectUpgrade_v2_0_TO_LATEST() throws Exception {
// preparation
File tmpTargetConfig = this.tempFolder.newFile(ConfigurationConstants.CONTEXT_CONFIG_FILENAME);
File sourceTestdata = new File(testFileRootPath + "valid-v2.0/" + ConfigurationConstants.CONTEXT_CONFIG_FILENAME);
Files.copy(sourceTestdata, tmpTargetConfig);
ContextConfigurationUpgrader sut = new ContextConfigurationUpgrader();
ContextConfigurationVersion version = sut.resolveLatestCompatibleSchemaVersion(this.tempFolder.getRoot().toPath());
assertThat(version).as("Source Version").isEqualTo(ContextConfigurationVersion.v2_0);
sut.upgradeConfigurationToLatestVersion(this.tempFolder.getRoot().toPath(), BackupPolicy.ENFORCE_BACKUP);
assertThat(tmpTargetConfig.toPath().resolveSibling("context.bak.xml").toFile()).exists().hasSameContentAs(sourceTestdata);
version = sut.resolveLatestCompatibleSchemaVersion(this.tempFolder.getRoot().toPath());
assertThat(version).as("Target version").isEqualTo(ContextConfigurationVersion.getLatest());
XMLUnit.setIgnoreWhitespace(true);
new XMLTestCase() {
}.assertXMLEqual(new FileReader(testFileRootPath + "valid-" + ContextConfigurationVersion.getLatest() + "/" + ConfigurationConstants.CONTEXT_CONFIG_FILENAME), new FileReader(tmpTargetConfig));
}
use of com.devonfw.cobigen.impl.config.upgrade.ContextConfigurationUpgrader in project cobigen by devonfw.
the class ContextConfigurationUpgraderTest method testCorrectLatestSchemaDetection.
/**
* Tests if latest context configuration is compatible to latest schema version.
*
* @throws Exception test fails
*/
@Test
public void testCorrectLatestSchemaDetection() throws Exception {
// preparation
File targetConfig = new File(testFileRootPath + "valid-" + ContextConfigurationVersion.getLatest());
ContextConfigurationVersion version = new ContextConfigurationUpgrader().resolveLatestCompatibleSchemaVersion(targetConfig.toPath());
assertThat(version).isEqualTo(ContextConfigurationVersion.getLatest());
}
Aggregations