[jscover] 02/69: Add test for pull request
Sylvestre Ledru
sylvestre at moszumanska.debian.org
Fri Aug 22 05:54:00 UTC 2014
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository jscover.
commit b7947e6ba8a0a714f71e46135d117fa196e9785d
Author: tntim96 <tntim96 at gmail.com>
Date: Wed Jun 4 10:10:19 2014 +1000
Add test for pull request
---
History.md | 4 ++++
src/main/java/jscover/Main.java | 4 ++--
src/test/java/jscover/MainParsingTest.java | 20 +++++++++++++++++++-
.../{MANIFEST-TEST.MF => MANIFEST-No-CLASS-PATH.MF} | 1 -
src/test/resources/META-INF/MANIFEST-TEST.MF | 2 +-
5 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/History.md b/History.md
index f3cda41..c274841 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,7 @@
+1.0.11 / 2014-??-??
+==================
+ * Improve error when 'Class-Path' not in manifest (https://github.com/tntim96/JSCover/pull/135)
+
1.0.10 / 2014-06-03
==================
* Add shutdown hook
diff --git a/src/main/java/jscover/Main.java b/src/main/java/jscover/Main.java
index 0164570..aab5e05 100644
--- a/src/main/java/jscover/Main.java
+++ b/src/main/java/jscover/Main.java
@@ -407,8 +407,8 @@ public class Main {
String message = "%nEnsure these JARs are in the same directory as %s.jar:%n%s";
throw new IllegalStateException(format(message, name , classPathJARs), e);
} else {
- String message = "Could not find the CLASS_PATH attribute in the manifest '%s'";
- throw new IllegalStateException(format(message, manifestName), e);
+ String message = "Could not find the '%s' attribute in the manifest '%s'";
+ throw new IllegalStateException(format(message, Attributes.Name.CLASS_PATH, manifestName), e);
}
}
}
diff --git a/src/test/java/jscover/MainParsingTest.java b/src/test/java/jscover/MainParsingTest.java
index a960f56..2bb025a 100644
--- a/src/test/java/jscover/MainParsingTest.java
+++ b/src/test/java/jscover/MainParsingTest.java
@@ -348,6 +348,7 @@ import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
+import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@@ -377,7 +378,7 @@ public class MainParsingTest {
ReflectionUtils.setField(main, "dependantClasses", dependantClasses);
try {
main.initialize();
- fail("Should have thrwn exception");
+ fail("Should have thrown exception");
} catch(IllegalStateException e) {
String message = e.getMessage();
assertThat(message, containsString("Ensure these JARs are in the same directory as JSCover.jar:"));
@@ -386,6 +387,23 @@ public class MainParsingTest {
}
@Test
+ public void shouldDetectMissingClassPath() throws IOException {
+ main.parse(new String[]{});
+ ArrayList<String> dependantClasses = new ArrayList<String>() {{
+ add("this.shouldn't.Exist");
+ }};
+ ReflectionUtils.setField(main, "manifestName", "MANIFEST-NO-CLASS-PATH.MF");
+ ReflectionUtils.setField(main, "dependantClasses", dependantClasses);
+ try {
+ main.initialize();
+ fail("Should have thrown exception");
+ } catch(IllegalStateException e) {
+ String message = e.getMessage();
+ assertThat(message, equalTo("Could not find the 'Class-Path' attribute in the manifest 'MANIFEST-NO-CLASS-PATH.MF'"));
+ }
+ }
+
+ @Test
public void shouldParseVersion() {
assertThat(main.parse(new String[]{"-V"}).printVersion(), equalTo(true));
assertThat(main.parse(new String[]{"--version"}).printVersion(), equalTo(true));
diff --git a/src/test/resources/META-INF/MANIFEST-TEST.MF b/src/test/resources/META-INF/MANIFEST-No-CLASS-PATH.MF
similarity index 76%
copy from src/test/resources/META-INF/MANIFEST-TEST.MF
copy to src/test/resources/META-INF/MANIFEST-No-CLASS-PATH.MF
index edf47bb..8889b7b 100644
--- a/src/test/resources/META-INF/MANIFEST-TEST.MF
+++ b/src/test/resources/META-INF/MANIFEST-No-CLASS-PATH.MF
@@ -4,5 +4,4 @@ Created-By: 1.6.0_11-b03 (Sun Microsystems Inc.)
Implementation-Title: JSCover
Implementation-Version: x.y.z
Main-Class: jscover.Main
-Class-Path: commons-io-1.4.jar commons-lang-2.4.jar js.jar
diff --git a/src/test/resources/META-INF/MANIFEST-TEST.MF b/src/test/resources/META-INF/MANIFEST-TEST.MF
index edf47bb..3a25f69 100644
--- a/src/test/resources/META-INF/MANIFEST-TEST.MF
+++ b/src/test/resources/META-INF/MANIFEST-TEST.MF
@@ -4,5 +4,5 @@ Created-By: 1.6.0_11-b03 (Sun Microsystems Inc.)
Implementation-Title: JSCover
Implementation-Version: x.y.z
Main-Class: jscover.Main
-Class-Path: commons-io-1.4.jar commons-lang-2.4.jar js.jar
+Class-Path: js.jar
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jscover.git
More information about the pkg-java-commits
mailing list