Example usage for org.springframework.boot.loader.tools Layout getLauncherClassName

List of usage examples for org.springframework.boot.loader.tools Layout getLauncherClassName

Introduction

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

Prototype

String getLauncherClassName();

Source Link

Document

Returns the launcher class name for this layout.

Usage

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

@Test
public void customLayout() throws Exception {
    TestJarFile libJar = new TestJarFile(this.temporaryFolder);
    libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
    File libJarFile = libJar.getFile();
    this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
    File file = this.testJarFile.getFile();
    Repackager repackager = new Repackager(file);
    Layout layout = mock(Layout.class);
    LibraryScope scope = mock(LibraryScope.class);
    given(layout.getLauncherClassName()).willReturn("testLauncher");
    given(layout.getLibraryDestination(anyString(), eq(scope))).willReturn("test/");
    given(layout.getLibraryDestination(anyString(), eq(LibraryScope.COMPILE))).willReturn("test-lib/");
    repackager.setLayout(layout);//from  ww  w.j  ava 2 s.co  m
    repackager.repackage((callback) -> callback.library(new Library(libJarFile, scope)));
    assertThat(hasEntry(file, "test/" + libJarFile.getName())).isTrue();
    assertThat(getManifest(file).getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo("test-lib/");
    assertThat(getManifest(file).getMainAttributes().getValue("Main-Class")).isEqualTo("testLauncher");
}

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

@Test
public void customLayoutNoBootLib() throws Exception {
    TestJarFile libJar = new TestJarFile(this.temporaryFolder);
    libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
    File libJarFile = libJar.getFile();
    this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
    File file = this.testJarFile.getFile();
    Repackager repackager = new Repackager(file);
    Layout layout = mock(Layout.class);
    LibraryScope scope = mock(LibraryScope.class);
    given(layout.getLauncherClassName()).willReturn("testLauncher");
    repackager.setLayout(layout);//from   w w  w .  j  a v  a 2 s.  c o  m
    repackager.repackage((callback) -> callback.library(new Library(libJarFile, scope)));
    assertThat(getManifest(file).getMainAttributes().getValue("Spring-Boot-Lib")).isNull();
    assertThat(getManifest(file).getMainAttributes().getValue("Main-Class")).isEqualTo("testLauncher");
}