@Override public DirectoryStructure getDirectoryStructure() { return identity.getDirectoryStructure(); } }, Collections.<String>emptyList(), structure == null ? null : structure.getInstalledImage());
@Override public DirectoryStructure getDirectoryStructure() { return identity.getDirectoryStructure(); } }, Collections.<String>emptyList(), structure == null ? null : structure.getInstalledImage());
public DirectoryStructure getStructure() { return target.getDirectoryStructure(); }
public DirectoryStructure getStructure() { return target.getDirectoryStructure(); }
public static File[] getModuleRoot(final PatchableTarget target) { try { return PatchUtils.getModulePath(target.getDirectoryStructure(), target.loadTargetInfo()); } catch (IOException e) { throw new RuntimeException(e); } }
private static boolean isAgedOut(InstalledIdentity installedIdentity, final Patch metadata) { for (PatchElement pe : metadata.getElements()) { final PatchElementProvider peProvider = pe.getProvider(); final PatchableTarget layer = peProvider.isAddOn() ? installedIdentity.getAddOn(peProvider.getName()) : installedIdentity.getLayer(peProvider.getName()); if (layer == null) { // if an identity is missing a layer that means either it was re-configured and the layer // was removed // or the layer in the patch is optional and may be missing on the disk // we haven't had this case yet, not sure how critical this is to terminate the process of // cleaning up throw new IllegalStateException(PatchLogger.ROOT_LOGGER.layerNotFound(peProvider.getName())); } final File patchDir = layer.getDirectoryStructure().getModulePatchDirectory(pe.getId()); if (!patchDir.exists()) { return true; } } return false; }
private static boolean isAgedOut(InstalledIdentity installedIdentity, final Patch metadata) { for (PatchElement pe : metadata.getElements()) { final PatchElementProvider peProvider = pe.getProvider(); final PatchableTarget layer = peProvider.isAddOn() ? installedIdentity.getAddOn(peProvider.getName()) : installedIdentity.getLayer(peProvider.getName()); if (layer == null) { // if an identity is missing a layer that means either it was re-configured and the layer // was removed // or the layer in the patch is optional and may be missing on the disk // we haven't had this case yet, not sure how critical this is to terminate the process of // cleaning up throw new IllegalStateException(PatchLogger.ROOT_LOGGER.layerNotFound(peProvider.getName())); } final File patchDir = layer.getDirectoryStructure().getModulePatchDirectory(pe.getId()); if (!patchDir.exists()) { return true; } } return false; }
static void assertModule(final String patchID, final PatchableTarget target, final ModuleItem item) { final File[] mp = TestUtils.getModuleRoot(target); final File currentPatch = target.getDirectoryStructure().getModulePatchDirectory(patchID); final File module = PatchContentLoader.getModulePath(currentPatch, item); assertModulePath(mp, item, module); }
break; case MISC: final File home = target.getDirectoryStructure().getInstalledImage().getJbossHome(); final ModificationCondition condition = modification.getCondition(); if(condition != null) {
@Test public void testWrongModuleContent() throws Exception { final PatchingTestBuilder builder = createDefaultBuilder(); // Add some random content ContentModificationUtils.addModule(builder.getRoot(), "base-patch-001", "test.module", randomString()); // Override the hash with a wrong one final ModuleItem item = new ModuleItem("test.module", "main", WRONG_HASH); final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD); final PatchingTestStepBuilder step1 = builder.createStepBuilder(); step1.oneOffPatchIdentity(PRODUCT_VERSION) .setPatchId("oo1") .oneOffPatchElement("base-patch-001", "base", false) .addContentModification(wrongModification) .getParent() .addFileWithRandomContent(null, "test", "content"); // try { apply(step1); Assert.fail("should have failed"); } catch (PatchingException e) { Assert.assertFalse(builder.hasFile("test", "content")); final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity(); final PatchableTarget base = identity.getLayer("base"); Assert.assertFalse(base.getDirectoryStructure().getModulePatchDirectory("base-patch-001").exists()); Assert.assertFalse(identity.getInstalledImage().getPatchHistoryDir("oo1").exists()); } }
@Test public void testWrongMiscContent() throws Exception { final PatchingTestBuilder builder = createDefaultBuilder(); ContentModificationUtils.addMisc(builder.getRoot(), "oo2", "test-content", "wrong-content"); final MiscContentItem item = new MiscContentItem("wrong-content", new String[0], WRONG_HASH); final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD); final PatchingTestStepBuilder step1 = builder.createStepBuilder(); step1.oneOffPatchIdentity(PRODUCT_VERSION) .setPatchId("oo2") .oneOffPatchElement("base-patch-002", "base", false) .addModuleWithRandomContent("other.test", null) .getParent() .addFileWithRandomContent(null, "test", "content") .addContentModification(wrongModification) ; // try { apply(step1); Assert.fail("should have failed"); } catch (PatchingException e) { Assert.assertFalse(builder.hasFile("test", "content")); Assert.assertFalse(builder.hasFile("wrong-content")); final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity(); final PatchableTarget base = identity.getLayer("base"); Assert.assertFalse(base.getDirectoryStructure().getModulePatchDirectory("base-patch-002").exists()); Assert.assertFalse(identity.getInstalledImage().getPatchHistoryDir("oo2").exists()); } }