|
23 | 23 | package org.jboss.as.patching.runner;
|
24 | 24 |
|
25 | 25 | import static org.jboss.as.patching.HashUtils.hashFile;
|
| 26 | +import static org.jboss.as.patching.IoUtils.NO_CONTENT; |
26 | 27 | import static org.jboss.as.patching.IoUtils.mkdir;
|
27 | 28 | import static org.jboss.as.patching.runner.PatchingAssert.assertFileContent;
|
28 | 29 | import static org.jboss.as.patching.runner.PatchingAssert.assertFileDoesNotExist;
|
|
41 | 42 | import java.io.File;
|
42 | 43 |
|
43 | 44 | import org.jboss.as.patching.installation.Identity;
|
| 45 | +import org.jboss.as.patching.metadata.ContentItem; |
44 | 46 | import org.jboss.as.patching.metadata.ContentModification;
|
| 47 | +import org.jboss.as.patching.metadata.MiscContentItem; |
| 48 | +import org.jboss.as.patching.metadata.ModificationType; |
45 | 49 | import org.jboss.as.patching.metadata.Patch;
|
46 | 50 | import org.jboss.as.patching.metadata.PatchBuilder;
|
| 51 | +import org.jboss.as.patching.tool.ContentVerificationPolicy; |
47 | 52 | import org.jboss.as.patching.tool.PatchingResult;
|
48 | 53 | import org.junit.Test;
|
49 | 54 |
|
@@ -225,5 +230,40 @@ public void testRemoveDirectoryAndRollback() throws Exception {
|
225 | 230 | assertTrue(subTwo.isFile());
|
226 | 231 | }
|
227 | 232 |
|
| 233 | + @Test |
| 234 | + public void testAddDirectory() throws Exception { |
| 235 | + |
| 236 | + final ContentItem item = new MiscContentItem("dir", new String[] { "test"}, NO_CONTENT, true, false); |
| 237 | + final ContentModification addDir = new ContentModification(item, NO_CONTENT, ModificationType.ADD); |
| 238 | + |
| 239 | + final String patchID = randomString(); |
| 240 | + final Patch patch = PatchBuilder.create() |
| 241 | + .setPatchId(patchID) |
| 242 | + .setDescription(randomString()) |
| 243 | + .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) |
| 244 | + .getParent() |
| 245 | + .addContentModification(addDir) |
| 246 | + .build(); |
| 247 | + |
| 248 | + // create the patch |
| 249 | + final File patchDir = mkdir(tempDir, patch.getPatchId()); |
| 250 | + createPatchXMLFile(patchDir, patch); |
| 251 | + final File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); |
| 252 | + |
| 253 | + // Apply |
| 254 | + PatchingResult result = executePatch(zippedPatch); |
| 255 | + assertPatchHasBeenApplied(result, patch); |
| 256 | + |
| 257 | + final File test = new File(env.getInstalledImage().getJbossHome(), "test"); |
| 258 | + assertTrue(test.exists()); |
| 259 | + assertTrue(test.isDirectory()); |
| 260 | + final File dir = new File(test, "dir"); |
| 261 | + assertTrue(dir.exists()); |
| 262 | + assertTrue(dir.isDirectory()); |
| 263 | + |
| 264 | + rollback(patchID); |
| 265 | + |
| 266 | + } |
| 267 | + |
228 | 268 | }
|
229 | 269 |
|
0 commit comments