/* *Thesetestscomparemessageswhichcouldbelocalized,therefore *thesetestscomparemessagesonlywithEnglishlocales,and *forallotherlocales,theexitvaluesarechecked.
*/ staticvoid runTest(File jarFile, String expectedErrorMessage) {
TestResult tr = doExec(TestHelper.javaCmd, "-jar", jarFile.getAbsolutePath()); if (isEnglishLocale() && !tr.contains(expectedErrorMessage)) {
System.out.println(tr); thrownew RuntimeException("expected string not found");
} if (tr.isOK()) {
System.out.println(tr); thrownew RuntimeException("test exit with status 0");
}
}
// Missing manifest entry staticvoid test1() throws IOException {
File jarFile = new File("missingmainentry.jar");
createJar("cvf", jarFile.getName(), ".");
runTest(jarFile, "no main manifest attribute");
}
// Entry point in manifest file has .class extension staticvoid test2() throws IOException {
File jarFile = new File("extensionmainentry.jar");
createJar("Foo.class", jarFile, new File("Foo"), (String[])null);
runTest(jarFile, "Error: Could not find or load main class");
}
// Entry point in manifest file is misspelled staticvoid test3() throws IOException {
File jarFile = new File("misspelledmainentry.jar");
createJar("FooMIS", jarFile, new File("Foo"), (String[])null);
runTest(jarFile, "Error: Could not find or load main class");
}
// Main-Class attribute is misspelled in manifest file staticvoid test4() throws IOException {
File jarFile = new File("misspelledMainAttribute.jar");
File manifestFile = new File("manifest.txt");
List<String> contents = new ArrayList<>();
contents.add("MainClassName: Foo");
createFile(manifestFile, contents);
createJar("-cmf", manifestFile.getName(), jarFile.getName());
runTest(jarFile, "no main manifest attribute");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.