Example usage for org.springframework.boot.loader.tools Layouts.War Layouts.War

List of usage examples for org.springframework.boot.loader.tools Layouts.War Layouts.War

Introduction

In this page you can find the example usage for org.springframework.boot.loader.tools Layouts.War Layouts.War.

Prototype

Layouts.War

Source Link

Usage

From source file:org.springframework.boot.loader.tools.RepackagerTests.java

@Test
public void existingEntryThatMatchesUnpackLibraryIsMarkedForUnpack() throws IOException {
    File library = createLibrary();
    this.testJarFile.addClass("WEB-INF/classes/com/example/Application.class", ClassWithMainMethod.class);
    this.testJarFile.addFile("WEB-INF/lib/" + library.getName(), library);
    File source = this.testJarFile.getFile("war");
    File dest = this.temporaryFolder.newFile("dest.war");
    Repackager repackager = new Repackager(source);
    repackager.setLayout(new Layouts.War());
    repackager.repackage(dest,/*  ww  w. j a v a 2  s.  c  o m*/
            (callback) -> callback.library(new Library(library, LibraryScope.COMPILE, true)));
    assertThat(getEntryNames(dest)).containsSubsequence("org/springframework/boot/loader/",
            "WEB-INF/classes/com/example/Application.class", "WEB-INF/lib/" + library.getName());
    JarEntry unpackLibrary = getEntry(dest, "WEB-INF/lib/" + library.getName());
    assertThat(unpackLibrary.getComment()).startsWith("UNPACK:");
}