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);
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);
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)));
}