Skip to content

Commit

Permalink
switch embedded package construction to use a new overload in
Browse files Browse the repository at this point in the history
TestPackageUtil.
  • Loading branch information
adamcin committed Aug 28, 2020
1 parent 15da77b commit 913c73a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
21 changes: 0 additions & 21 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-to-embedded</id>
<phase>generate-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy
file="${project.build.testOutputDirectory}/jackrabbit-filevault-${vault-api.version}/${vault.test-packages.src}/package_1.0.zip"
tofile="src/test/resources/with-embedded-package/jcr_root/apps/with-embedded/install/package_1.0.zip" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ public void testReadInstallableResourceFromNode_slingOsgiConfig() throws Excepti

@Test
public void testReadInstallableResourceFromNode_package() throws Exception {
final File withEmbeddedPackage = TestPackageUtil.prepareTestPackageFromFolder("with-embedded-package.zip",
new File("src/test/resources/with-embedded-package"));

// first prepare the embedded file, which is copied to the test packages root directory with the given filename
final File embeddedPackageFile = TestPackageUtil.prepareTestPackage("package_1.0.zip");
// declare the path inside the embedding package
final String packagePath = "/apps/with-embedded/install/package_1.0.zip";
// prepare the outer package, passing the embedded package zip entry name and prepared File location as a map
// of additional entries.
final File withEmbeddedPackage = TestPackageUtil.prepareTestPackageFromFolder("with-embedded-package.zip",
new File("target/test-classes/with-embedded-package"),
Collections.singletonMap("jcr_root" + packagePath, embeddedPackageFile));

VaultPackage vaultPackage = mock(VaultPackage.class);
PackageId embeddedId = new PackageId("com.test", "embedded", "1.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,19 @@ public static File getCaliperPackage() {

public static File prepareTestPackageFromFolder(final @NotNull String filename,
final @NotNull File srcFolder) throws IOException {
return prepareTestPackageFromFolder(filename, srcFolder, Collections.emptyMap());
}

public static File prepareTestPackageFromFolder(final @NotNull String filename,
final @NotNull File srcFolder,
final @NotNull Map<String, File> additionalEntries) throws IOException {
final File absFile = srcFolder.getAbsoluteFile();
if (!absFile.isDirectory()) {
throw new IOException("expected directory in srcFolder parameter for test package filename "
+ filename + ", srcFolder exists " + srcFolder);
}
File file = new File(testPackagesRoot.toFile(), filename);
buildJarFromDir(absFile, file.getAbsoluteFile(), Collections.emptyMap());
buildJarFromDir(absFile, file.getAbsoluteFile(), additionalEntries);

return file;
}
Expand Down

0 comments on commit 913c73a

Please sign in to comment.