Search in sources :

Example 6 with Archive

use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.

the class JarLauncherTests method explodedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath.

@Test
public void explodedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
    File explodedRoot = explode(createJarArchive("archive.jar", "BOOT-INF"));
    JarLauncher launcher = new JarLauncher(new ExplodedArchive(explodedRoot, true));
    List<Archive> archives = launcher.getClassPathArchives();
    assertThat(archives).hasSize(2);
    assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(), new URL("jar:" + new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL() + "!/"));
}
Also used : ExplodedArchive(org.springframework.boot.loader.archive.ExplodedArchive) JarFileArchive(org.springframework.boot.loader.archive.JarFileArchive) ExplodedArchive(org.springframework.boot.loader.archive.ExplodedArchive) Archive(org.springframework.boot.loader.archive.Archive) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 7 with Archive

use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.

the class JarLauncherTests method archivedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath.

@Test
public void archivedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
    File jarRoot = createJarArchive("archive.jar", "BOOT-INF");
    JarLauncher launcher = new JarLauncher(new JarFileArchive(jarRoot));
    List<Archive> archives = launcher.getClassPathArchives();
    assertThat(archives).hasSize(2);
    assertThat(getUrls(archives)).containsOnly(new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/classes!/"), new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/lib/foo.jar!/"));
}
Also used : JarFileArchive(org.springframework.boot.loader.archive.JarFileArchive) ExplodedArchive(org.springframework.boot.loader.archive.ExplodedArchive) Archive(org.springframework.boot.loader.archive.Archive) JarFileArchive(org.springframework.boot.loader.archive.JarFileArchive) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Archive (org.springframework.boot.loader.archive.Archive)7 ExplodedArchive (org.springframework.boot.loader.archive.ExplodedArchive)7 JarFileArchive (org.springframework.boot.loader.archive.JarFileArchive)7 File (java.io.File)6 URL (java.net.URL)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 EntryFilter (org.springframework.boot.loader.archive.Archive.EntryFilter)1