WebsterPlan { Archive createArchive() throws IOException { if (archiveRoot == null || !archiveRoot.isDirectory()) { throw new IllegalArgumentException("archiveRoot must be an existing directory"); } final FileArchive archive = new FileArchive(archiveRoot); if (!new File(archiveRoot, Constants.ROOT_DIR).exists()) { throw new IllegalArgumentException("archiveRoot must have a child jcr_root directory"); } final File archiveMetaInfVault = new File(archiveRoot, Constants.META_DIR); if (!archiveMetaInfVault.isDirectory()) { archiveMetaInfVault.mkdirs(); } archive.open(false); return archive; } WebsterPlan(final @NotNull FixtureProvider fixtureProvider,
                final @NotNull List<WebsterTarget> targets,
                final @Nullable File globalSegmentStore,
                final @Nullable File archiveRoot); void perform();  }
@Test(expected = IllegalArgumentException.class) public void testCreateArchive_nullArchiveRoot() throws Exception { WebsterPlan.Builder builder = new WebsterPlan.Builder(); builder.build().createArchive(); }
@Test(expected = IllegalArgumentException.class) public void testCreateArchive_nonExistArchiveRoot() throws Exception { final File testBase = new File(testOutDir, "testCreateArchive_nonExistArchiveRoot"); final File archiveRoot = new File(testBase, "notAProject"); FileUtils.deleteDirectory(archiveRoot); WebsterPlan.Builder builder = new WebsterPlan.Builder(); builder.withArchiveRoot(archiveRoot); assertFalse("archiveRoot should not exist", archiveRoot.exists()); builder.build().createArchive(); }
@Test(expected = IllegalArgumentException.class) public void testCreateArchive_noJcrRoot() throws Exception { final File testBase = new File(testOutDir, "testCreateArchive_noJcrRoot"); final File archiveSrc = new File("src/test/resources/filevault/noJcrRoot"); final File archiveRoot = new File(testBase, "noJcrRoot"); FileUtils.deleteDirectory(archiveRoot); FileUtils.copyDirectory(archiveSrc, archiveRoot); WebsterPlan.Builder builder = new WebsterPlan.Builder(); builder.withArchiveRoot(archiveRoot); assertTrue("archiveRoot should exist", archiveRoot.exists()); builder.build().createArchive(); }
@Test public void testCreateArchive_noMetaInfVault() throws Exception { final File testBase = new File(testOutDir, "testCreateArchive_noMetaInfVault"); final File archiveSrc = new File("src/test/resources/filevault/noMetaInfVault"); final File archiveRoot = new File(testBase, "noMetaInfVault"); FileUtils.deleteDirectory(archiveRoot); FileUtils.copyDirectory(archiveSrc, archiveRoot); WebsterPlan.Builder builder = new WebsterPlan.Builder(); builder.withArchiveRoot(archiveRoot); assertTrue("archiveRoot/jcr_root should exist", new File(archiveRoot, "jcr_root").exists()); assertFalse("archiveRoot/META-INF/vault should not exist", new File(archiveRoot, "META-INF/vault").exists()); builder.build().createArchive(); assertTrue("archiveRoot/META-INF/vault should exist now", new File(archiveRoot, "META-INF/vault").exists()); }