Skip to content

Commit b60caab

Browse files
author
npryce
committed
New functionality and refactoring coming out of jMock 2 development.
Added appendValueList methods to the Description interface and StringDescription class Moved java bean constraints into org.hamcrest.beans
1 parent dc682b9 commit b60caab

18 files changed

Lines changed: 161 additions & 80 deletions

.classpath

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/api"/>
4+
<classpathentry kind="src" path="src/examples"/>
5+
<classpathentry kind="src" path="src/integration"/>
6+
<classpathentry kind="src" path="src/library"/>
7+
<classpathentry kind="src" path="src/unit-test"/>
8+
<classpathentry kind="lib" path="lib/integration/easymock-2.2.jar"/>
9+
<classpathentry kind="lib" path="lib/integration/jmock-1.10RC1.jar"/>
10+
<classpathentry kind="lib" path="lib/integration/junit-3.8.1.jar"/>
11+
<classpathentry kind="lib" path="lib/integration/junit-4.0.jar"/>
12+
<classpathentry kind="lib" path="lib/integration/testng-4.6-jdk15.jar"/>
13+
<classpathentry kind="lib" path="lib/library/jaxen-1.1-beta-4.jar"/>
14+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
15+
<classpathentry kind="output" path="classes"/>
16+
</classpath>

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>hamcrest-java</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

src/api/org/hamcrest/Description.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ public interface Description {
1111
* Append some plain text to the description.
1212
*/
1313
Description appendText(String text);
14-
14+
1515
/**
1616
* Append an arbitary value to the description.
1717
*/
1818
Description appendValue(Object value);
19+
20+
/**
21+
* Append a list of values to the description.
22+
*/
23+
<T> Description appendValueList(String start, String separator, String end,
24+
T... values);
1925

26+
/**
27+
* Append a list of values to the description.
28+
*/
29+
<T> Description appendValueList(String start, String separator, String end,
30+
Iterable<T> values);
2031
}

src/api/org/hamcrest/Matcher.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
* A matcher over acceptable values. A matcher should be able to describe itself to give feedback when it fails.
77
*/
88
public interface Matcher<T> {
9-
109
/**
11-
* Evaluates the matcher for argument <var>o</var>.
10+
* Evaluates the matcher for argument <var>item</var>.
1211
*
1312
* @param item the object against which the matcher is evaluated.
14-
* @return <code>true</code> if <var>o</var> matcher, otherwise <code>false</code>.
13+
* @return <code>true</code> if <var>item</var> matches, otherwise <code>false</code>.
1514
*/
1615
boolean match(T item);
1716

1817
/**
1918
* Describes this matcher.
2019
*/
2120
void describeTo(Description description);
22-
2321
}

src/library/org/hamcrest/object/HasProperty.java renamed to src/library/org/hamcrest/beans/HasProperty.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright (c) 2000-2006 hamcrest.org
22
*/
3-
package org.hamcrest.object;
3+
package org.hamcrest.beans;
44

55
import org.hamcrest.Description;
66
import org.hamcrest.Matcher;
@@ -26,7 +26,7 @@ public HasProperty(String propertyName) {
2626
this.propertyName = propertyName;
2727
}
2828

29-
public boolean match(Object obj) {
29+
public boolean match(T obj) {
3030
try {
3131
return PropertyUtil.getPropertyDescriptor(propertyName, obj) != null;
3232
} catch (IntrospectionException e) {

src/library/org/hamcrest/object/HasPropertyWithValue.java renamed to src/library/org/hamcrest/beans/HasPropertyWithValue.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright (c) 2000-2006 hamcrest.org
22
*/
3-
package org.hamcrest.object;
3+
package org.hamcrest.beans;
44

55
import org.hamcrest.Description;
66
import org.hamcrest.Matcher;
@@ -78,7 +78,7 @@ public HasPropertyWithValue(String propertyName, Matcher value) {
7878
}
7979

8080
@SuppressWarnings({"unchecked"})
81-
public boolean match(Object argument) {
81+
public boolean match(T argument) {
8282
try {
8383
Method readMethod = getReadMethod(argument);
8484
return readMethod != null
@@ -111,5 +111,4 @@ public void describeTo(Description description) {
111111
public static <T> Matcher<T> hasProperty(String propertyName, Matcher value) {
112112
return new HasPropertyWithValue<T>(propertyName, value);
113113
}
114-
115114
}

src/library/org/hamcrest/object/PropertyUtil.java renamed to src/library/org/hamcrest/beans/PropertyUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright (c) 2000-2006 hamcrest.org
22
*/
3-
package org.hamcrest.object;
3+
package org.hamcrest.beans;
44

55
import java.beans.BeanInfo;
66
import java.beans.IntrospectionException;

src/library/org/hamcrest/core/IsCompatibleType.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/library/org/hamcrest/core/IsNull.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Is the value null?
1212
*/
1313
public class IsNull<T> implements Matcher<T> {
14-
public boolean match(Object o) {
14+
public boolean match(T o) {
1515
return o == null;
1616
}
1717

@@ -26,7 +26,7 @@ public static <T> Matcher<T> isNull() {
2626

2727
@Factory
2828
public static <T> Matcher<T> isNotNull() {
29-
return not((Matcher<T>)isNull());
29+
return not(IsNull.<T>isNull());
3030
}
3131
}
3232

src/library/org/hamcrest/core/Or.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ public void describeTo(Description description) {
4747
public static <T> Matcher<T> or(Matcher<T>... matchers) {
4848
return new Or<T>(matchers);
4949
}
50-
5150
}

0 commit comments

Comments
 (0)