private File createNextCumulativePatchAddingRandomModule( String patchID, String asVersion, final String currentPatch, final String targetAsVersion, File targetDir) throws Exception { String layerPatchID = "layer" + patchID; File cpPatchDir = mkdir(tempDir, patchID); final String moduleName = "org.wildfly.test." + randomString(); // Create the version module final String versionModuleName = ProductInfo.getVersionModule(); final Module modifiedModule = PatchingTestUtil.createVersionModule(targetAsVersion); // Calculate the target hash of the currently active module final String currentLayerPatchID = "layer" + currentPatch; File originalVersionModulePath = new File(tempDir, currentPatch); originalVersionModulePath = new File(originalVersionModulePath, currentLayerPatchID); originalVersionModulePath = new File(originalVersionModulePath, Constants.MODULES); originalVersionModulePath = newFile(originalVersionModulePath, versionModuleName.split("\\.")); originalVersionModulePath = new File(originalVersionModulePath, ProductInfo.getVersionModuleSlot()); byte[] patchedAsVersionHash = HashUtils.hashFile(originalVersionModulePath); assert patchedAsVersionHash != null; final ResourceItem resourceItem1 = new ResourceItem("testFile1", "content1".getBytes()); final ResourceItem resourceItem2 = new ResourceItem("testFile2", "content2".getBytes()); Module newModule = new Module.Builder(moduleName).miscFile(resourceItem1).miscFile(resourceItem2).build(); ContentModification moduleAdded = ContentModificationUtils.addModule(cpPatchDir, layerPatchID, newModule); ContentModification versionModuleModified = ContentModificationUtils.modifyModule( cpPatchDir, layerPatchID, patchedAsVersionHash, modifiedModule); ProductConfig productConfig = new ProductConfig(PRODUCT, asVersion, "main"); Patch cpPatch = PatchBuilder.create() .setPatchId(patchID) .setDescription("A cp patch.") .upgradeIdentity( productConfig.getProductName(), productConfig.getProductVersion(), targetAsVersion) .getParent() .upgradeElement(layerPatchID, "base", false) .addContentModification(versionModuleModified) .addContentModification(moduleAdded) .getParent() .build(); createPatchXMLFile(cpPatchDir, cpPatch); return createZippedPatchFile(cpPatchDir, patchID, targetDir); }
private File createNextCumulativePatchModyfyingJbossModules( String patchID, String asVersion, final String currentPatch, final String targetAsVersion, File targetDir) throws Exception { String layerPatchID = "layer" + patchID; File cpPatchDir = mkdir(tempDir, patchID); // Also see if we can update jboss-modules final File installation = new File(AS_DISTRIBUTION); final File patchDir = new File(cpPatchDir, patchID); final ContentModification jbossModulesModification = PatchingTestUtil.updateModulesJar(installation, patchDir); // Create the version module final String versionModuleName = ProductInfo.getVersionModule(); final Module modifiedModule = PatchingTestUtil.createVersionModule(targetAsVersion); // Calculate the target hash of the currently active module final String currentLayerPatchID = "layer" + currentPatch; File originalVersionModulePath = new File(tempDir, currentPatch); originalVersionModulePath = new File(originalVersionModulePath, currentLayerPatchID); originalVersionModulePath = new File(originalVersionModulePath, Constants.MODULES); originalVersionModulePath = newFile(originalVersionModulePath, versionModuleName.split("\\.")); originalVersionModulePath = new File(originalVersionModulePath, ProductInfo.getVersionModuleSlot()); byte[] patchedAsVersionHash = HashUtils.hashFile(originalVersionModulePath); assert patchedAsVersionHash != null; ContentModification versionModuleModified = ContentModificationUtils.modifyModule( cpPatchDir, layerPatchID, patchedAsVersionHash, modifiedModule); Patch cpPatch = PatchBuilder.create() .setPatchId(patchID) .setDescription("A cp patch.") .upgradeIdentity(PRODUCT, asVersion, targetAsVersion) .getParent() .upgradeElement(layerPatchID, "base", false) .addContentModification(versionModuleModified) .getParent() .addContentModification(jbossModulesModification) .build(); createPatchXMLFile(cpPatchDir, cpPatch); return createZippedPatchFile(cpPatchDir, patchID, targetDir); }
private File createCumulativePatchAddingARandomModule( String patchID, String asVersion, final String targetAsVersion, File targetDir) throws Exception { String layerPatchID = "layer" + patchID; File cpPatchDir = mkdir(tempDir, patchID); final String moduleName = "org.wildfly.test." + randomString(); final ResourceItem resourceItem1 = new ResourceItem("testFile1", "content1".getBytes()); final ResourceItem resourceItem2 = new ResourceItem("testFile2", "content2".getBytes()); Module newModule = new Module.Builder(moduleName).miscFile(resourceItem1).miscFile(resourceItem2).build(); // Create the version module final String versionModuleName = ProductInfo.getVersionModule(); final String slot = ProductInfo.getVersionModuleSlot(); final String originalVersionModulePath = MODULES_PATH + FILE_SEPARATOR + versionModuleName.replace(".", FILE_SEPARATOR) + FILE_SEPARATOR + slot; final Module modifiedModule = PatchingTestUtil.createVersionModule(targetAsVersion); ContentModification moduleAdded = ContentModificationUtils.addModule(cpPatchDir, layerPatchID, newModule); ContentModification versionModuleModified = ContentModificationUtils.modifyModule( cpPatchDir, layerPatchID, HashUtils.hashFile(new File(originalVersionModulePath)), modifiedModule); Patch cpPatch = PatchBuilder.create() .setPatchId(patchID) .setDescription("A cp patch.") .upgradeIdentity(PRODUCT, asVersion, targetAsVersion) .getParent() .upgradeElement(layerPatchID, "base", false) .addContentModification(moduleAdded) .addContentModification(versionModuleModified) .getParent() .build(); createPatchXMLFile(cpPatchDir, cpPatch); return createZippedPatchFile(cpPatchDir, patchID, targetDir); }
private File createOneOffPatchAddingMiscFile(String patchID, String asVersion) throws Exception { File oneOffPatchDir = mkdir(tempDir, patchID); ContentModification miscFileAdded = ContentModificationUtils.addMisc( oneOffPatchDir, patchID, "test content", "awesomeDirectory", "awesomeFile"); ProductConfig productConfig = new ProductConfig(PRODUCT, asVersion, "main"); Patch oneOffPatch = PatchBuilder.create() .setPatchId(patchID) .setDescription("A one-off patch adding a misc file.") .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(miscFileAdded) .build(); createPatchXMLFile(oneOffPatchDir, oneOffPatch); return createZippedPatchFile(oneOffPatchDir, patchID); }