Skip to content

Commit 882e781

Browse files
author
p3muet@gmail.com
committed
reverting gwt changes
1 parent 551236d commit 882e781

57 files changed

Lines changed: 181 additions & 1030 deletions

File tree

Some content is hidden

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

‎README.txt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ different Jars.
3838
tools, including JUnit (3 and 4), TestNG, jMock and
3939
EasyMock.
4040

41-
* [hamcrest-gwt.jar]
42-
Use this with the core and (optionally) library jars
43-
to use Hamcrest in the Google Web Toolkit. (See
44-
http://code.google.com/webtoolkit/)
45-
4641
Alternatively, if you don't care:
4742

4843
* [hamcrest-all.jar]

‎build.xml‎

Lines changed: 21 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
value="true"
1313
description="Whether to build with debug information"/>
1414

15-
<property name="gwtvalidate"
16-
value="true"
17-
description="Whether to validate the GWT distribution"/>
18-
1915
<target name="all"
2016
depends="clean, package"
2117
description="Performs clean build, runs tests and packages for distribution"/>
@@ -64,7 +60,6 @@
6460
<arg value="hamcrest-core/src/main/java"/>
6561
<arg value="org.hamcrest.CoreMatchers"/>
6662
<arg value="build/temp/hamcrest-core/generated-code"/>
67-
<arg value="core"/>
6863
</java>
6964
<!-- Append to core jar -->
7065
<java-to-jar srcdir="build/temp/hamcrest-core/generated-code"
@@ -92,7 +87,6 @@
9287
<arg value="hamcrest-core/src/main/java,hamcrest-library/src/main/java"/>
9388
<arg value="org.hamcrest.Matchers"/>
9489
<arg value="build/temp/hamcrest-library/generated-code"/>
95-
<arg value="library"/>
9690
</java>
9791
<!-- Append to library jar -->
9892
<java-to-jar srcdir="build/temp/hamcrest-library/generated-code"
@@ -109,82 +103,6 @@
109103
build/hamcrest-core-${version}.jar;
110104
build/hamcrest-library-${version}.jar"/>
111105
</target>
112-
113-
<target name="gwt" depends="gwt-setup, gwt-lib, gwt-validate" />
114-
<target name="gwt-setup">
115-
<condition property="dogwtvalidate">
116-
<and>
117-
<not>
118-
<isset property="nogwt" />
119-
</not>
120-
<istrue value="${gwtvalidate}" />
121-
</and>
122-
</condition>
123-
</target>
124-
<target name="gwt-lib"
125-
depends="gwt-setup, core, library"
126-
description="Build GWT Hamcrest library"
127-
unless="nogwt">
128-
<java-to-jar-no-compile srcdir="hamcrest-gwt/src/main/java"
129-
destjar="build/hamcrest-gwt-${version}.jar"/>
130-
<!-- Generate classes with all static imports. -->
131-
<mkdir dir="build/temp/hamcrest-gwt/generated-code/org/hamcrest/translatable"/>
132-
<java classname="org.hamcrest.generator.config.XmlConfigurator"
133-
fork="yes"
134-
failonerror="yes"
135-
classpath="
136-
build/hamcrest-core-${version}.jar;
137-
build/hamcrest-generator-${version}.jar;
138-
">
139-
<arg value="core-matchers.xml"/>
140-
<arg value="hamcrest-core/src/main/java/"/>
141-
<arg value="org.hamcrest.CoreMatchers"/>
142-
<arg value="build/temp/hamcrest-gwt/generated-code/org/hamcrest/translatable"/>
143-
<arg value="gwt"/>
144-
</java>
145-
<java classname="org.hamcrest.generator.config.XmlConfigurator"
146-
fork="yes"
147-
failonerror="yes"
148-
classpath="
149-
build/hamcrest-core-${version}.jar;
150-
build/hamcrest-library-${version}.jar;
151-
build/hamcrest-generator-${version}.jar;
152-
">
153-
<arg value="matchers.xml"/>
154-
<arg value="hamcrest-core/src/main/java/"/>
155-
<arg value="org.hamcrest.Matchers"/>
156-
<arg value="build/temp/hamcrest-gwt/generated-code/org/hamcrest/translatable"/>
157-
<arg value="gwt"/>
158-
</java>
159-
<!-- Copy over org.hamcrest.* java files into translatable, to deal with
160-
wierdness in how GWT's source tag works. -->
161-
<copy todir="build/temp/hamcrest-gwt/generated-code/org/hamcrest/translatable/org/hamcrest">
162-
<fileset dir="hamcrest-core/src/main/java/org/hamcrest">
163-
<include name="*.java"/>
164-
<exclude name="CustomTypeSafeMatcher.java"/>
165-
<exclude name="StringDescription.java"/>
166-
<exclude name="TypeSafeDiagnosingMatcher.java"/>
167-
<exclude name="TypeSafeMatcher.java"/>
168-
</fileset>
169-
</copy>
170-
<copy todir="build/temp/hamcrest-gwt/generated-code/org/hamcrest/translatable/org/hamcrest">
171-
<fileset dir="hamcrest-library/src/main/java/org/hamcrest">
172-
<include name="*.java"/>
173-
174-
</fileset>
175-
</copy>
176-
<!-- Copy in GWT README file. -->
177-
<copy file="hamcrest-gwt/README.txt" tofile="build/temp/hamcrest-gwt/generated-code/README.txt"/>
178-
<!-- Append to gwt jar. -->
179-
<java-to-jar-no-compile srcdir="build/temp/hamcrest-gwt/generated-code"
180-
destjar="build/hamcrest-gwt-${version}.jar"/>
181-
</target>
182-
<target name="gwt-validate"
183-
depends="gwt-setup, gwt-lib"
184-
description="Validate a test app to verify integrity of build."
185-
if="dogwtvalidate">
186-
<gwt-validate src="hamcrest-gwt/src/test/java" module="org.hamcrest.gwt.test.HamcrestTest"/>
187-
</target>
188106

189107
<target name="unit-test"
190108
depends="core, library, integration, generator"
@@ -240,7 +158,7 @@
240158
</target>
241159

242160
<target name="package"
243-
depends="core, generator, library, integration, gwt, bigjar, unit-test, examples"
161+
depends="core, generator, library, integration, bigjar, unit-test, examples"
244162
description="Package for distribution">
245163
<zip zipfile="build/hamcrest-${version}.zip">
246164
<zipfileset dir="." prefix="hamcrest-${version}">
@@ -255,12 +173,11 @@
255173
<include name="hamcrest-generator-${version}.jar"/>
256174
<include name="hamcrest-library-${version}.jar"/>
257175
<include name="hamcrest-integration-${version}.jar"/>
258-
<include name="hamcrest-gwt-${version}.jar"/>
259176
<include name="hamcrest-all-${version}.jar"/>
260177
</zipfileset>
261178
</zip>
262179
<tar tarfile="build/hamcrest-${version}.tgz" compression="gzip" longfile="gnu">
263-
<tarfileset dir="." prefix="hamcrest-${version}">
180+
<tarfileset dir="." prefix="hamcrest-${version}">
264181
<include name="hamcrest-*/**"/>
265182
<include name="lib/**"/>
266183
<include name="*.txt"/>
@@ -272,35 +189,36 @@
272189
<include name="hamcrest-generator-${version}.jar"/>
273190
<include name="hamcrest-library-${version}.jar"/>
274191
<include name="hamcrest-integration-${version}.jar"/>
275-
<include name="hamcrest-gwt-${version}.jar"/>
276192
<include name="hamcrest-all-${version}.jar"/>
277193
</tarfileset>
278194
</tar>
279195
</target>
280196

281-
<target name="javadoc" depends="library">
282-
<mkdir dir="build/javadoc"/>
283-
<javadoc destdir="build/javadoc" source="1.5" failonerror="yes"
284-
overview="overview.html">
197+
<target name="javadoc" depends="library">
198+
<mkdir dir="build/javadoc"/>
199+
<javadoc destdir="build/javadoc" source="1.5" failonerror="yes"
200+
overview="overview.html">
201+
285202
<classpath>
286203
<fileset dir="lib/integration">
287204
<include name="*.jar"/>
288205
</fileset>
289206
</classpath>
290-
<packageset dir="hamcrest-core/src/main/java"/>
291-
<packageset dir="hamcrest-library/src/main/java" excludes="org/hamcrest/internal"/>
292-
<packageset dir="hamcrest-integration/src/main/java"/>
293-
<packageset dir="build/generated-code"/>
294207

295-
<group title="Hamcrest API and Utility Classes" packages="org.hamcrest"/>
296-
<group title="Matcher Library" packages="org.hamcrest.*"/>
297-
<group title="Integration" packages="org.hamcrest.integration, org.hamcrest.integration.*"/>
298-
299-
<link offline="false" href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
300-
<link offline="false" href="http://www.junit.org/junit/javadoc/3.8.1/"/>
301-
<link offline="false" href="http://junit.sourceforge.net/javadoc_40/"/>
302-
</javadoc>
303-
</target>
208+
<packageset dir="hamcrest-core/src/main/java"/>
209+
<packageset dir="hamcrest-library/src/main/java" excludes="org/hamcrest/internal"/>
210+
<packageset dir="hamcrest-integration/src/main/java"/>
211+
<packageset dir="build/generated-code"/>
212+
213+
<group title="Hamcrest API and Utility Classes" packages="org.hamcrest"/>
214+
<group title="Matcher Library" packages="org.hamcrest.*"/>
215+
<group title="Integration" packages="org.hamcrest.integration, org.hamcrest.integration.*"/>
216+
217+
<link offline="false" href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
218+
<link offline="false" href="http://www.junit.org/junit/javadoc/3.8.1/"/>
219+
<link offline="false" href="http://junit.sourceforge.net/javadoc_40/"/>
220+
</javadoc>
221+
</target>
304222

305223
<macrodef name="java-to-jar"
306224
description="Compile Java source and build a Jar">
@@ -328,63 +246,4 @@
328246
</sequential>
329247
</macrodef>
330248

331-
<macrodef name="java-to-jar-no-compile"
332-
description="Build a Jar file, but do not compile">
333-
<attribute name="srcdir" description="Directory containg Java source"/>
334-
<attribute name="destjar" description="Path to Jar"/>
335-
<sequential>
336-
<mkdir dir="build/temp/@{destjar}.contents"/>
337-
<copy file="LICENSE.txt" todir="build/temp/@{destjar}.contents"/>
338-
<!-- Put Java source in Jars for user's convenience. -->
339-
<copy todir="build/temp/@{destjar}.contents">
340-
<fileset dir="@{srcdir}"/>
341-
</copy>
342-
<jar jarfile="@{destjar}">
343-
<fileset dir="build/temp/@{destjar}.contents"/>
344-
</jar>
345-
</sequential>
346-
</macrodef>
347-
348-
<macrodef name="gwt-validate" description="Validates a GWT module can be compiled to JavaScript">
349-
<attribute name="src" description="The source you wish to validate"/>
350-
<attribute name="module" description="The fully qualified name of the module to validate"/>
351-
<sequential>
352-
<echo message="Running GWT Validator..."/>
353-
<!-- Platform identification -->
354-
<condition property="gwt.dev" value="gwt-dev-linux.jar">
355-
<and>
356-
<os family="unix"/>
357-
<not>
358-
<contains string="${os.name}" substring="mac" casesensitive="false"/>
359-
</not>
360-
</and>
361-
</condition>
362-
<condition property="gwt.dev" value="gwt-dev-mac.jar">
363-
<and>
364-
<os family="unix" />
365-
<contains string="${os.name}" substring="mac" casesensitive="false" />
366-
</and>
367-
</condition>
368-
<condition property="gwt.dev" value="gwt-dev-windows.jar">
369-
<os family="windows" />
370-
</condition>
371-
<fail unless="gwt.dev" message="Validating GWT on ${os.name} is not supported" />
372-
<java dir="build/temp/hamcrest-gwt"
373-
fork="yes"
374-
failonerror="true"
375-
classname="com.google.gwt.dev.GWTCompiler"
376-
classpath="
377-
@{src};
378-
build/hamcrest-core-${version}.jar;
379-
build/hamcrest-library-${version}.jar;
380-
build/hamcrest-gwt-${version}.jar;
381-
lib/gwt/gwt-user.jar;lib/gwt/${gwt.dev}
382-
">
383-
<jvmarg value="-Xmx256M"/>
384-
<arg value="-validateOnly"/>
385-
<arg value="@{module}"/>
386-
</java>
387-
</sequential>
388-
</macrodef>
389-
390249
</project>

‎core-matchers.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<factory class="org.hamcrest.core.IsAnything"/>
1111
<factory class="org.hamcrest.core.IsCollectionContaining"/>
1212
<factory class="org.hamcrest.core.IsEqual"/>
13-
<factory class="org.hamcrest.core.IsInstanceOf" excludes="gwt"/>
13+
<factory class="org.hamcrest.core.IsInstanceOf"/>
1414
<factory class="org.hamcrest.core.IsNot"/>
1515
<factory class="org.hamcrest.core.IsNull"/>
1616
<factory class="org.hamcrest.core.IsSame"/>

‎hamcrest-core/src/main/java/org/hamcrest/Factory.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@
1414
@Retention(RUNTIME)
1515
@Target({METHOD})
1616
public @interface Factory {
17-
/**
18-
* The targets from which to exclude this constructor.
19-
*/
20-
public String[] excludes() default {};
2117
}

‎hamcrest-core/src/main/java/org/hamcrest/TypeSafeDiagnosingMatcher.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @param <T>
1212
* @author Neil Dunn
1313
*/
14-
public abstract class TypeSafeDiagnosingMatcher<T> extends DiagnosingMatcher<T> {
14+
public abstract class TypeSafeDiagnosingMatcher<T> extends BaseMatcher<T> {
1515
private final Class<?> expectedType;
1616

1717
protected TypeSafeDiagnosingMatcher() {
@@ -25,16 +25,16 @@ protected TypeSafeDiagnosingMatcher() {
2525
public abstract boolean matchesSafely(T item, Description mismatchDescription);
2626

2727
@SuppressWarnings("unchecked")
28-
protected boolean matches(Object item, Description mismatchDescription) {
29-
boolean result = false;
30-
if (item == null) {
31-
mismatchDescription.appendText("The item was null.");
32-
} else if (!expectedType.isInstance(item)) {
33-
mismatchDescription.appendText("The item was not an instance of " + expectedType);
34-
} else {
35-
result = matchesSafely((T) item, mismatchDescription);
36-
}
37-
return result;
28+
public final boolean matches(Object item) {
29+
return item != null
30+
&& expectedType.isInstance(item)
31+
&& matchesSafely((T) item, new Description.NullDescription());
32+
}
33+
34+
@SuppressWarnings("unchecked")
35+
@Override
36+
public final void describeMismatch(Object item, Description mismatchDescription) {
37+
matchesSafely((T) item, mismatchDescription);
3838
}
3939

4040
private static Class<?> findExpectedType(Class<?> fromClass) {

‎hamcrest-core/src/main/java/org/hamcrest/core/DescribedAs.java‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
*/
33
package org.hamcrest.core;
44

5+
import java.util.regex.Pattern;
6+
57
import org.hamcrest.BaseMatcher;
68
import org.hamcrest.Description;
79
import org.hamcrest.Factory;
@@ -14,40 +16,33 @@ public class DescribedAs<T> extends BaseMatcher<T> {
1416
private final String descriptionTemplate;
1517
private final Matcher<T> matcher;
1618
private final Object[] values;
17-
19+
20+
private final static Pattern ARG_PATTERN = Pattern.compile("%([0-9]+)");
21+
1822
public DescribedAs(String descriptionTemplate, Matcher<T> matcher, Object[] values) {
1923
this.descriptionTemplate = descriptionTemplate;
2024
this.matcher = matcher;
21-
this.values = new Object[values.length];
22-
System.arraycopy(values, 0, this.values, 0, values.length);
25+
this.values = values.clone();
2326
}
24-
27+
2528
public boolean matches(Object o) {
2629
return matcher.matches(o);
2730
}
2831

2932
public void describeTo(Description description) {
30-
int p;
31-
String s = descriptionTemplate;
32-
while ((p = s.indexOf('%')) >= 0) {
33-
int q = p + 1;
34-
while (q < s.length()) {
35-
int c = s.charAt(q);
36-
if (c < '0' || c > '9') {
37-
break;
38-
}
39-
q++;
40-
}
41-
description.appendText(s.substring(0, p));
42-
if (q == p + 1) {
43-
description.appendText("%");
44-
} else {
45-
int idx = Integer.parseInt(s.substring(p + 1, q));
46-
description.appendValue(values[idx]);
47-
}
48-
s = s.substring(q);
33+
java.util.regex.Matcher arg = ARG_PATTERN.matcher(descriptionTemplate);
34+
35+
int textStart = 0;
36+
while (arg.find()) {
37+
description.appendText(descriptionTemplate.substring(textStart, arg.start()));
38+
int argIndex = Integer.parseInt(arg.group(1));
39+
description.appendValue(values[argIndex]);
40+
textStart = arg.end();
41+
}
42+
43+
if (textStart < descriptionTemplate.length()) {
44+
description.appendText(descriptionTemplate.substring(textStart));
4945
}
50-
description.appendText(s);
5146
}
5247

5348
/**

0 commit comments

Comments
 (0)