當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassWithMainMethod類代碼示例

本文整理匯總了Java中org.springframework.boot.loader.tools.sample.ClassWithMainMethod的典型用法代碼示例。如果您正苦於以下問題:Java ClassWithMainMethod類的具體用法?Java ClassWithMainMethod怎麽用?Java ClassWithMainMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClassWithMainMethod類屬於org.springframework.boot.loader.tools.sample包,在下文中一共展示了ClassWithMainMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: duplicateLibraries

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void duplicateLibraries() throws Exception {
	TestJarFile libJar = new TestJarFile(this.temporaryFolder);
	libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
	final File libJarFile = libJar.getFile();
	this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
	File file = this.testJarFile.getFile();
	Repackager repackager = new Repackager(file);
	this.thrown.expect(IllegalStateException.class);
	this.thrown.expectMessage("Duplicate library");
	repackager.repackage(new Libraries() {
		@Override
		public void doWithLibraries(LibraryCallback callback) throws IOException {
			callback.library(new Library(libJarFile, LibraryScope.COMPILE, false));
			callback.library(new Library(libJarFile, LibraryScope.COMPILE, false));
		}
	});
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:RepackagerTests.java

示例2: customLayout

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void customLayout() throws Exception {
	TestJarFile libJar = new TestJarFile(this.temporaryFolder);
	libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
	final 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);
	final LibraryScope scope = mock(LibraryScope.class);
	given(layout.getLauncherClassName()).willReturn("testLauncher");
	given(layout.getLibraryDestination(anyString(), eq(scope))).willReturn("test/");
	repackager.setLayout(layout);
	repackager.repackage(new Libraries() {
		@Override
		public void doWithLibraries(LibraryCallback callback) throws IOException {
			callback.library(new Library(libJarFile, scope));
		}
	});
	assertThat(hasEntry(file, "test/" + libJarFile.getName())).isTrue();
	assertThat(getManifest(file).getMainAttributes().getValue("Main-Class"))
			.isEqualTo("testLauncher");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:24,代碼來源:RepackagerTests.java

示例3: addLauncherScript

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void addLauncherScript() throws Exception {
	this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
	File source = this.testJarFile.getFile();
	File dest = this.temporaryFolder.newFile("dest.jar");
	Repackager repackager = new Repackager(source);
	LaunchScript script = new MockLauncherScript("ABC");
	repackager.repackage(dest, NO_LIBRARIES, script);
	byte[] bytes = FileCopyUtils.copyToByteArray(dest);
	assertThat(new String(bytes)).startsWith("ABC");
	assertThat(hasLauncherClasses(source)).isFalse();
	assertThat(hasLauncherClasses(dest)).isTrue();
	try {
		assertThat(Files.getPosixFilePermissions(dest.toPath()))
				.contains(PosixFilePermission.OWNER_EXECUTE);
	}
	catch (UnsupportedOperationException ex) {
		// Probably running the test on Windows
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:RepackagerTests.java

示例4: customLayout

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void customLayout() throws Exception {
	TestJarFile libJar = new TestJarFile(this.temporaryFolder);
	libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
	final 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);
	final LibraryScope scope = mock(LibraryScope.class);
	given(layout.getLauncherClassName()).willReturn("testLauncher");
	given(layout.getLibraryDestination(anyString(), eq(scope))).willReturn("test/");
	repackager.setLayout(layout);
	repackager.repackage(new Libraries() {
		@Override
		public void doWithLibraries(LibraryCallback callback) throws IOException {
			callback.library(new Library(libJarFile, scope));
		}
	});
	assertThat(hasEntry(file, "test/" + libJarFile.getName()), equalTo(true));
	assertThat(getManifest(file).getMainAttributes().getValue("Main-Class"),
			equalTo("testLauncher"));
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:24,代碼來源:RepackagerTests.java

示例5: dontRecompressZips

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void dontRecompressZips() throws Exception {
	TestJarFile nested = new TestJarFile(this.temporaryFolder);
	nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
	final File nestedFile = nested.getFile();
	this.testJarFile.addFile("test/nested.jar", nestedFile);
	this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
	File file = this.testJarFile.getFile();
	Repackager repackager = new Repackager(file);
	repackager.repackage(new Libraries() {
		@Override
		public void doWithLibraries(LibraryCallback callback) throws IOException {
			callback.library(new Library(nestedFile, LibraryScope.COMPILE));
		}
	});
	JarFile jarFile = new JarFile(file);
	try {
		assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getMethod(),
				equalTo(ZipEntry.STORED));
		assertThat(jarFile.getEntry("test/nested.jar").getMethod(),
				equalTo(ZipEntry.STORED));
	}
	finally {
		jarFile.close();
	}
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:27,代碼來源:RepackagerTests.java

示例6: addLauncherScript

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void addLauncherScript() throws Exception {
	this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
	File source = this.testJarFile.getFile();
	File dest = this.temporaryFolder.newFile("dest.jar");
	Repackager repackager = new Repackager(source);
	LaunchScript script = new MockLauncherScript("ABC");
	repackager.repackage(dest, NO_LIBRARIES, script);
	byte[] bytes = FileCopyUtils.copyToByteArray(dest);
	assertThat(new String(bytes), startsWith("ABC"));
	assertThat(hasLauncherClasses(source), equalTo(false));
	assertThat(hasLauncherClasses(dest), equalTo(true));
	try {
		assertThat(Files.getPosixFilePermissions(dest.toPath()),
				hasItem(PosixFilePermission.OWNER_EXECUTE));
	}
	catch (UnsupportedOperationException ex) {
		// Probably running the test on Windows
	}
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:21,代碼來源:RepackagerTests.java

示例7: findMainClassInJar

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findMainClassInJar() throws Exception {
	this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
	assertThat(actual).isEqualTo("B");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:MainClassFinderTests.java

示例8: findMainClassInJarSubFolder

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findMainClassInJarSubFolder() throws Exception {
	this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
	this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
	assertThat(actual).isEqualTo("a.b.c.D");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:9,代碼來源:MainClassFinderTests.java

示例9: usesBreadthFirstJarSearch

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void usesBreadthFirstJarSearch() throws Exception {
	this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
	assertThat(actual).isEqualTo("a.B");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:MainClassFinderTests.java

示例10: findSingleJarSearch

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findSingleJarSearch() throws Exception {
	this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
	this.thrown.expect(IllegalStateException.class);
	this.thrown.expectMessage("Unable to find a single main class "
			+ "from the following candidates [a.B, a.b.c.E]");
	MainClassFinder.findSingleMainClass(this.testJarFile.getJarFile(), "");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:MainClassFinderTests.java

示例11: findMainClassInJarSubLocation

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findMainClassInJarSubLocation() throws Exception {
	this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(),
			"a/");
	assertThat(actual).isEqualTo("B");

}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:MainClassFinderTests.java

示例12: findMainClassInFolder

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findMainClassInFolder() throws Exception {
	this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
	assertThat(actual).isEqualTo("B");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:MainClassFinderTests.java

示例13: findMainClassInSubFolder

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findMainClassInSubFolder() throws Exception {
	this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
	this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
	assertThat(actual).isEqualTo("a.b.c.D");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:9,代碼來源:MainClassFinderTests.java

示例14: usesBreadthFirstFolderSearch

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void usesBreadthFirstFolderSearch() throws Exception {
	this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
	String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
	assertThat(actual).isEqualTo("a.B");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:MainClassFinderTests.java

示例15: findSingleFolderSearch

import org.springframework.boot.loader.tools.sample.ClassWithMainMethod; //導入依賴的package包/類
@Test
public void findSingleFolderSearch() throws Exception {
	this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
	this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
	this.thrown.expect(IllegalStateException.class);
	this.thrown.expectMessage("Unable to find a single main class "
			+ "from the following candidates [a.B, a.b.c.E]");
	MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource());
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:MainClassFinderTests.java


注:本文中的org.springframework.boot.loader.tools.sample.ClassWithMainMethod類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。