Skip to content

Commit b377e18

Browse files
committed
Remove Hamcrest compile dependency
Use hamcrest-junit 2.0.0.0 instead Fixes junit-team#1145
1 parent b2c7be7 commit b377e18

File tree

110 files changed

+196
-1815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+196
-1815
lines changed

.classpath

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<classpathentry kind="src" path="src/test/resources"/>
66
<classpathentry kind="src" path="src/main/resources"/>
77
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
8-
<classpathentry exported="true" kind="lib" path="lib/hamcrest-core-1.3.jar" sourcepath="lib/hamcrest-core-1.3-sources.jar"/>
8+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
9+
<classpathentry kind="lib" path="lib/java-hamcrest-2.0.0.0.jar" sourcepath="lib/java-hamcrest-2.0.0.0-sources.jar"/>
10+
<classpathentry kind="lib" path="lib/hamcrest-junit-2.0.0.0.jar" sourcepath="lib/hamcrest-junit-2.0.0.0-sources.jar"/>
911
<classpathentry kind="output" path="bin"/>
1012
</classpath>

lib/hamcrest-core-1.3-sources.jar

-31.9 KB
Binary file not shown.

lib/hamcrest-core-1.3.jar

-44 KB
Binary file not shown.
8.84 KB
Binary file not shown.

lib/hamcrest-junit-2.0.0.0.jar

14 KB
Binary file not shown.

lib/java-hamcrest-2.0.0.0-sources.jar

74.3 KB
Binary file not shown.

lib/java-hamcrest-2.0.0.0.jar

110 KB
Binary file not shown.

pom.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,21 @@
110110
<dependencies>
111111
<dependency>
112112
<groupId>org.hamcrest</groupId>
113-
<artifactId>hamcrest-core</artifactId>
114-
<version>1.3</version>
113+
<artifactId>java-hamcrest</artifactId>
114+
<version>2.0.0.0</version>
115+
<scope>test</scope>
116+
</dependency>
117+
<dependency>
118+
<groupId>org.hamcrest</groupId>
119+
<artifactId>hamcrest-junit</artifactId>
120+
<version>2.0.0.0</version>
121+
<scope>test</scope>
122+
<exclusions>
123+
<exclusion>
124+
<groupId>junit</groupId>
125+
<artifactId>junit</artifactId>
126+
</exclusion>
127+
</exclusions>
115128
</dependency>
116129
</dependencies>
117130

@@ -303,10 +316,6 @@
303316
<minmemory>32m</minmemory>
304317
<maxmemory>128m</maxmemory>
305318
<failOnError>true</failOnError>
306-
<includeDependencySources>true</includeDependencySources>
307-
<dependencySourceIncludes>
308-
<dependencySourceInclude>org.hamcrest:hamcrest-core:*</dependencySourceInclude>
309-
</dependencySourceIncludes>
310319
</configuration>
311320
</plugin>
312321
<plugin>
@@ -355,10 +364,6 @@
355364
<plugin>
356365
<artifactId>maven-project-info-reports-plugin</artifactId>
357366
<version>2.7</version>
358-
<configuration>
359-
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
360-
<!-- waiting for MPIR-267 -->
361-
</configuration>
362367
<reportSets>
363368
<reportSet>
364369
<reports>
@@ -407,10 +412,6 @@
407412
<minmemory>32m</minmemory>
408413
<maxmemory>128m</maxmemory>
409414
<failOnError>true</failOnError>
410-
<includeDependencySources>true</includeDependencySources>
411-
<dependencySourceIncludes>
412-
<dependencySourceInclude>org.hamcrest:hamcrest-core:*</dependencySourceInclude>
413-
</dependencySourceIncludes>
414415
</configuration>
415416
<reportSets>
416417
<reportSet>

src/main/java/org/junit/Assert.java

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.junit;
22

3-
import org.hamcrest.Matcher;
4-
import org.hamcrest.MatcherAssert;
53
import org.junit.internal.ArrayComparisonFailure;
64
import org.junit.internal.ExactComparisonCriteria;
75
import org.junit.internal.InexactComparisonCriteria;
@@ -893,66 +891,4 @@ public static void assertEquals(Object[] expecteds, Object[] actuals) {
893891
assertArrayEquals(expecteds, actuals);
894892
}
895893

896-
/**
897-
* Asserts that <code>actual</code> satisfies the condition specified by
898-
* <code>matcher</code>. If not, an {@link AssertionError} is thrown with
899-
* information about the matcher and failing value. Example:
900-
*
901-
* <pre>
902-
* assertThat(0, is(1)); // fails:
903-
* // failure message:
904-
* // expected: is &lt;1&gt;
905-
* // got value: &lt;0&gt;
906-
* assertThat(0, is(not(1))) // passes
907-
* </pre>
908-
*
909-
* <code>org.hamcrest.Matcher</code> does not currently document the meaning
910-
* of its type parameter <code>T</code>. This method assumes that a matcher
911-
* typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only
912-
* to values that could be assigned to a variable of type <code>T</code>.
913-
*
914-
* @param <T> the static type accepted by the matcher (this can flag obvious
915-
* compile-time problems such as {@code assertThat(1, is("a"))}
916-
* @param actual the computed value being compared
917-
* @param matcher an expression, built of {@link Matcher}s, specifying allowed
918-
* values
919-
* @see org.hamcrest.CoreMatchers
920-
* @see org.hamcrest.MatcherAssert
921-
*/
922-
public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
923-
assertThat("", actual, matcher);
924-
}
925-
926-
/**
927-
* Asserts that <code>actual</code> satisfies the condition specified by
928-
* <code>matcher</code>. If not, an {@link AssertionError} is thrown with
929-
* the reason and information about the matcher and failing value. Example:
930-
*
931-
* <pre>
932-
* assertThat(&quot;Help! Integers don't work&quot;, 0, is(1)); // fails:
933-
* // failure message:
934-
* // Help! Integers don't work
935-
* // expected: is &lt;1&gt;
936-
* // got value: &lt;0&gt;
937-
* assertThat(&quot;Zero is one&quot;, 0, is(not(1))) // passes
938-
* </pre>
939-
*
940-
* <code>org.hamcrest.Matcher</code> does not currently document the meaning
941-
* of its type parameter <code>T</code>. This method assumes that a matcher
942-
* typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only
943-
* to values that could be assigned to a variable of type <code>T</code>.
944-
*
945-
* @param reason additional information about the error
946-
* @param <T> the static type accepted by the matcher (this can flag obvious
947-
* compile-time problems such as {@code assertThat(1, is("a"))}
948-
* @param actual the computed value being compared
949-
* @param matcher an expression, built of {@link Matcher}s, specifying allowed
950-
* values
951-
* @see org.hamcrest.CoreMatchers
952-
* @see org.hamcrest.MatcherAssert
953-
*/
954-
public static <T> void assertThat(String reason, T actual,
955-
Matcher<? super T> matcher) {
956-
MatcherAssert.assertThat(reason, actual, matcher);
957-
}
958894
}

src/main/java/org/junit/Assume.java

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package org.junit;
22

3-
import static java.util.Arrays.asList;
4-
import static org.hamcrest.CoreMatchers.everyItem;
5-
import static org.hamcrest.CoreMatchers.is;
6-
import static org.hamcrest.CoreMatchers.notNullValue;
7-
import static org.hamcrest.CoreMatchers.nullValue;
8-
9-
import org.hamcrest.Matcher;
10-
113
/**
124
* A set of methods useful for stating assumptions about the conditions in which a test is meaningful.
135
* A failed assumption does not mean the code is broken, but that the test provides no useful information. Assume
@@ -38,7 +30,7 @@ public class Assume {
3830
* If called with an expression evaluating to {@code false}, the test will halt and be ignored.
3931
*/
4032
public static void assumeTrue(boolean b) {
41-
assumeThat(b, is(true));
33+
assumeTrue(null, b);
4234
}
4335

4436
/**
@@ -70,53 +62,37 @@ public static void assumeFalse(String message, boolean b) {
7062
* If called with one or more null elements in <code>objects</code>, the test will halt and be ignored.
7163
*/
7264
public static void assumeNotNull(Object... objects) {
73-
assumeThat(asList(objects), everyItem(notNullValue()));
65+
for (int i = 0; i < objects.length; i++) {
66+
assumeNotNull("objects[" + i + "] is not null", objects[i]);
67+
}
7468
}
7569

7670
/**
77-
* Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>.
78-
* If not, the test halts and is ignored.
79-
* Example:
80-
* <pre>:
81-
* assumeThat(1, is(1)); // passes
82-
* foo(); // will execute
83-
* assumeThat(0, is(1)); // assumption failure! test halts
84-
* int x = 1 / 0; // will never execute
85-
* </pre>
86-
*
87-
* @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is("a"))}
88-
* @param actual the computed value being compared
89-
* @param matcher an expression, built of {@link Matcher}s, specifying allowed values
90-
* @see org.hamcrest.CoreMatchers
91-
* @see org.junit.matchers.JUnitMatchers
71+
* If called with null, the test will halt and be ignored.
9272
*/
93-
public static <T> void assumeThat(T actual, Matcher<T> matcher) {
94-
if (!matcher.matches(actual)) {
95-
throw new AssumptionViolatedException(actual, matcher);
96-
}
73+
public static void assumeNotNull(Object object) {
74+
assumeNotNull("object is not null", object);
9775
}
9876

9977
/**
100-
* Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>.
101-
* If not, the test halts and is ignored.
102-
* Example:
103-
* <pre>:
104-
* assumeThat("alwaysPasses", 1, is(1)); // passes
105-
* foo(); // will execute
106-
* assumeThat("alwaysFails", 0, is(1)); // assumption failure! test halts
107-
* int x = 1 / 0; // will never execute
108-
* </pre>
109-
*
110-
* @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is("a"))}
111-
* @param actual the computed value being compared
112-
* @param matcher an expression, built of {@link Matcher}s, specifying allowed values
113-
* @see org.hamcrest.CoreMatchers
114-
* @see org.junit.matchers.JUnitMatchers
78+
* If called with null, the test will halt and be ignored.
11579
*/
116-
public static <T> void assumeThat(String message, T actual, Matcher<T> matcher) {
117-
if (!matcher.matches(actual)) {
118-
throw new AssumptionViolatedException(message, actual, matcher);
119-
}
80+
public static void assumeNotNull(String message, Object object) {
81+
assumeFalse(message, object == null);
82+
}
83+
84+
/**
85+
* If called with null, the test will halt and be ignored.
86+
*/
87+
public static void assumeNull(Object object) {
88+
assumeNull("object is null", object);
89+
}
90+
91+
/**
92+
* If called with null, the test will halt and be ignored.
93+
*/
94+
public static void assumeNull(String message, Object object) {
95+
assumeTrue(message, object == null);
12096
}
12197

12298
/**
@@ -139,7 +115,7 @@ public static <T> void assumeThat(String message, T actual, Matcher<T> matcher)
139115
* @param e if non-null, the offending exception
140116
*/
141117
public static void assumeNoException(Throwable e) {
142-
assumeThat(e, nullValue());
118+
assumeNoException("no exception", e);
143119
}
144120

145121
/**
@@ -153,6 +129,6 @@ public static void assumeNoException(Throwable e) {
153129
* @see #assumeNoException(Throwable)
154130
*/
155131
public static void assumeNoException(String message, Throwable e) {
156-
assumeThat(message, e, nullValue());
132+
if (e != null) throw new AssumptionViolatedException(message, e);
157133
}
158134
}
Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.junit;
22

3-
import org.hamcrest.Matcher;
4-
53
/**
64
* An exception class used to implement <i>assumptions</i> (state in which a given test
75
* is meaningful and should or should not be executed). A test for which an assumption
@@ -10,37 +8,24 @@
108
* @see org.junit.Assume
119
* @since 4.12
1210
*/
13-
@SuppressWarnings("deprecation")
1411
public class AssumptionViolatedException extends org.junit.internal.AssumptionViolatedException {
15-
private static final long serialVersionUID = 1L;
1612

17-
/**
18-
* An assumption exception with the given <i>actual</i> value and a <i>matcher</i> describing
19-
* the expectation that failed.
20-
*/
21-
public <T> AssumptionViolatedException(T actual, Matcher<T> matcher) {
22-
super(actual, matcher);
23-
}
24-
25-
/**
26-
* An assumption exception with a message with the given <i>actual</i> value and a
27-
* <i>matcher</i> describing the expectation that failed.
28-
*/
29-
public <T> AssumptionViolatedException(String message, T expected, Matcher<T> matcher) {
30-
super(message, expected, matcher);
31-
}
13+
private static final long serialVersionUID = 2L;
3214

3315
/**
3416
* An assumption exception with the given message only.
3517
*/
18+
@SuppressWarnings("deprecation")
3619
public AssumptionViolatedException(String message) {
3720
super(message);
3821
}
3922

4023
/**
4124
* An assumption exception with the given message and a cause.
4225
*/
43-
public AssumptionViolatedException(String assumption, Throwable t) {
44-
super(assumption, t);
26+
@SuppressWarnings("deprecation")
27+
public AssumptionViolatedException(String message, Throwable e) {
28+
super(message, e);
4529
}
30+
4631
}

0 commit comments

Comments
 (0)