/** * Backup the current configuration as part of the patch history. * * @throws IOException for any error */ void backupConfiguration() throws IOException { final String configuration = Constants.CONFIGURATION; final File a = new File(installedImage.getAppClientDir(), configuration); final File d = new File(installedImage.getDomainDir(), configuration); final File s = new File(installedImage.getStandaloneDir(), configuration); if (a.exists()) { final File ab = new File(configBackup, Constants.APP_CLIENT); backupDirectory(a, ab); } if (d.exists()) { final File db = new File(configBackup, Constants.DOMAIN); backupDirectory(d, db); } if (s.exists()) { final File sb = new File(configBackup, Constants.STANDALONE); backupDirectory(s, sb); } }
/** * Backup the current configuration as part of the patch history. * * @throws IOException for any error */ void backupConfiguration() throws IOException { final String configuration = Constants.CONFIGURATION; final File a = new File(installedImage.getAppClientDir(), configuration); final File d = new File(installedImage.getDomainDir(), configuration); final File s = new File(installedImage.getStandaloneDir(), configuration); if (a.exists()) { final File ab = new File(configBackup, Constants.APP_CLIENT); backupDirectory(a, ab); } if (d.exists()) { final File db = new File(configBackup, Constants.DOMAIN); backupDirectory(d, db); } if (s.exists()) { final File sb = new File(configBackup, Constants.STANDALONE); backupDirectory(s, sb); } }
final File s = new File(installedImage.getStandaloneDir(), configuration); backupDirectory(bs, s);
final File s = new File(installedImage.getStandaloneDir(), configuration); backupDirectory(bs, s);
@Before public void setUp() throws Exception { // with some files in the configuration directories appClientXmlFile = touch(env.getInstalledImage().getAppClientDir(), "configuration", "appclient.xml"); dump(appClientXmlFile, "<original content of appclient configuration>"); originalAppClientHash = hashFile(appClientXmlFile); standaloneXmlFile = touch(env.getInstalledImage().getStandaloneDir(), "configuration", "standalone.xml"); dump(standaloneXmlFile, "<original content of standalone configuration>"); originalStandaloneHash = hashFile(standaloneXmlFile); domainXmlFile = touch(env.getInstalledImage().getDomainDir(), "configuration", "domain.xml"); dump(domainXmlFile, "<original content of domain configuration>"); originalDomainHash = hashFile(domainXmlFile); }
@Before public void setUp() throws Exception { // with some files in the configuration directories File appClientXmlFile = touch(env.getInstalledImage().getAppClientDir(), "configuration", "appclient.xml"); dump(appClientXmlFile, "<original content of appclient configuration>"); originalAppClientHash = hashFile(appClientXmlFile); standaloneXmlFile = touch(env.getInstalledImage().getStandaloneDir(), "configuration", "standalone.xml"); dump(standaloneXmlFile, "<original content of standalone configuration>"); originalStandaloneHash = hashFile(standaloneXmlFile); File domainXmlFile = touch(env.getInstalledImage().getDomainDir(), "configuration", "domain.xml"); dump(domainXmlFile, "<original content of domain configuration>"); originalDomainHash = hashFile(domainXmlFile); }
private void checkApplyPatchAndRollbackRestoresBackupConfiguration(File patchDir, Patch patch) throws Exception { createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); Identity identityBeforePatch = loadInstalledIdentity().getIdentity(); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); // check the AS7 config files have been backed up File backupAppclientXmlFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "configuration", "appclient", "appclient.xml"); assertFileContent(originalAppClientHash, backupAppclientXmlFile); File backupStandaloneXmlFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "configuration", "standalone", "standalone.xml"); assertFileContent(originalStandaloneHash, backupStandaloneXmlFile); File backupDomainXmlFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "configuration", "domain", "domain.xml"); assertFileContent(originalDomainHash, backupDomainXmlFile); // let's change the standalone.xml file dump(standaloneXmlFile, "<updated standalone configuration with changes from the added module>"); byte[] updatedStandaloneXmlFile = hashFile(standaloneXmlFile); tree(tempDir); PatchingResult rollbackResult = rollback(patch.getPatchId()); assertPatchHasBeenRolledBack(rollbackResult, identityBeforePatch); File rolledBackStandaloneXmlFile = assertFileExists(env.getInstalledImage().getStandaloneDir(), "configuration", "standalone.xml"); assertEquals("updated content was " + bytesToHexString(updatedStandaloneXmlFile), bytesToHexString(originalStandaloneHash), bytesToHexString(hashFile(rolledBackStandaloneXmlFile))); }
File rolledBackStandaloneXmlFile = assertFileExists(env.getInstalledImage().getStandaloneDir(), "configuration", "standalone.xml"); assertEquals(bytesToHexString(originalStandaloneHash), bytesToHexString(hashFile(rolledBackStandaloneXmlFile))); assertEquals(bytesToHexString(originalDomainHash), bytesToHexString(hashFile(rolledBackDomainXmlFile))); assertDirDoesNotExist(env.getInstalledImage().getStandaloneDir(), "configuration", "restored-configuration"); assertDirDoesNotExist(env.getInstalledImage().getAppClientDir(), "configuration", "restored-configuration"); assertDirDoesNotExist(env.getInstalledImage().getDomainDir(), "configuration", "restored-configuration");
assertRestoredConfig(env.getInstalledImage().getStandaloneDir(), "standalone.xml", updatedStandaloneXmlHash, originalStandaloneHash); assertRestoredConfig(env.getInstalledImage().getAppClientDir(), "appclient.xml", updatedAppClientXmlHash, originalAppClientHash); assertRestoredConfig(env.getInstalledImage().getDomainDir(), "domain.xml", updatedDomainXmlHash, originalDomainHash);