Remove emul tests depdency on GWT code.
Change-Id: I90b28f91406e2b8f204c488acc8e3ad492717bd6
diff --git a/user/super/com/google/gwt/emul/java/util/Collections.java b/user/super/com/google/gwt/emul/java/util/Collections.java
index e89cee6..ea8587c 100644
--- a/user/super/com/google/gwt/emul/java/util/Collections.java
+++ b/user/super/com/google/gwt/emul/java/util/Collections.java
@@ -18,6 +18,7 @@
import static javaemul.internal.Coercions.ensureInt;
import static javaemul.internal.InternalPreconditions.checkArgument;
import static javaemul.internal.InternalPreconditions.checkElementIndex;
+import static javaemul.internal.InternalPreconditions.checkNotNull;
import java.io.Serializable;
@@ -1186,6 +1187,7 @@
*/
@SuppressWarnings("unchecked")
public static void rotate(List<?> lst, int dist) {
+ checkNotNull(lst);
int size = lst.size();
// Rotating an empty collection results in the same empty collection
diff --git a/user/test/com/google/gwt/emultest/java/lang/CompilerConstantStringTest.java b/user/test/com/google/gwt/emultest/java/lang/CompilerConstantStringTest.java
index fade8c5..6b76b0e 100644
--- a/user/test/com/google/gwt/emultest/java/lang/CompilerConstantStringTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/CompilerConstantStringTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,7 +15,6 @@
*/
package com.google.gwt.emultest.java.lang;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.testing.TestUtils;
@@ -24,10 +23,10 @@
/**
* This test verifies that the static evaluation performed by the compiler
* on constant string expressions is correct.
- *
+ *
* TODO: this is just copied from the old StringTest before it was improved,
* but we need to go through and remove tests that do not actually
- * test the compiler.
+ * test the compiler.
*/
public class CompilerConstantStringTest extends GWTTestCase {
@@ -115,12 +114,12 @@
/**
* Tests hashing with strings.
- *
+ *
* The specific strings used in this test used to trigger failures because we
* use a JavaScript object as a hash map to cache the computed hash codes.
* This conflicts with built-in properties defined on objects -- see issue
* #631.
- *
+ *
*/
public void testHashCode() {
String[] testStrings = {
@@ -251,7 +250,7 @@
public void testSplit_emptyExpr() {
// TODO(rluble): implement JDK8 string.split semantics and fix test.
// See issue 8913.
- String[] expected = (!GWT.isScript() && TestUtils.getJdkVersion() > 7) ?
+ String[] expected = (TestUtils.getJdkVersion() > 7) ?
new String[] {"a", "b", "c", "x", "x", "d", "e", "x", "f", "x"} :
new String[] {"", "a", "b", "c", "x", "x", "d", "e", "x", "f", "x"};
compareList("emptyRegexSplit", expected, "abcxxdexfx".split(""));
diff --git a/user/test/com/google/gwt/emultest/java/lang/StringTest.java b/user/test/com/google/gwt/emultest/java/lang/StringTest.java
index db7efd2..33c39b1 100644
--- a/user/test/com/google/gwt/emultest/java/lang/StringTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/StringTest.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.emultest.java.lang;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.testing.TestUtils;
@@ -161,17 +159,17 @@
assertEquals("bcd", str);
try {
new String(bytes, 1, 6);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, -1, 2);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 6, 2);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
}
@@ -191,32 +189,32 @@
assertEquals("ßçÐ", str);
try {
new String(bytes, 1, 6, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, -1, 2, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 6, 2, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 1, 6, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, -1, 2, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 6, 2, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
}
@@ -237,32 +235,32 @@
assertEquals("ßçÐ", str);
try {
new String(bytes, 2, 12, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, -1, 2, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 12, 2, encoding);
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 2, 12, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, -1, 2, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
try {
new String(bytes, 12, 2, Charset.forName(encoding));
- assertTrue("Should have thrown IOOB in Development Mode", GWT.isScript());
+ assertTrue("Should have thrown IOOB in Development Mode", !TestUtils.isJvm());
} catch (IndexOutOfBoundsException expected) {
}
}
@@ -667,7 +665,7 @@
public void testSplit_emptyExpr() {
// TODO(rluble): implement JDK8 string.split semantics and fix test.
- String[] expected = (!GWT.isScript() && TestUtils.getJdkVersion() > 7) ?
+ String[] expected = (TestUtils.getJdkVersion() > 7) ?
new String[] {"a", "b", "c", "x", "x", "d", "e", "x", "f", "x"} :
new String[] {"", "a", "b", "c", "x", "x", "d", "e", "x", "f", "x"};
compareList("emptyRegexSplit", expected, "abcxxdexfx".split(""));
@@ -706,7 +704,7 @@
assertEquals("concat with str.toString()", "0abcd", "0" + str.toString() + "d");
// issue 4301
- Object s = TRUE ? "abc" : JavaScriptObject.createObject();
+ Object s = TRUE ? "abc" : createJavaScriptObject();
assertTrue("issue4301", isJsStringValue(s.toString()));
assertSame("s same as s.toString()", s, s.toString());
}
@@ -818,4 +816,8 @@
return Character.toString(from);
}
+ private static native Object createJavaScriptObject() /*-{
+ return {};
+ }-*/;
+
}
diff --git a/user/test/com/google/gwt/emultest/java/math/BigDecimalCompareTest.java b/user/test/com/google/gwt/emultest/java/math/BigDecimalCompareTest.java
index 474ce3a..9d2b7fc 100644
--- a/user/test/com/google/gwt/emultest/java/math/BigDecimalCompareTest.java
+++ b/user/test/com/google/gwt/emultest/java/math/BigDecimalCompareTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2009 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,15 +21,15 @@
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
- *
+ *
* INCLUDES MODIFICATIONS BY GOOGLE.
*/
/**
@@ -37,8 +37,8 @@
*/
package com.google.gwt.emultest.java.math;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.emultest.java.util.EmulTestBase;
+import com.google.gwt.testing.TestUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -390,7 +390,7 @@
* negate(MathContext) for a negative BigDecimal.
*/
public void testNegateMathContextNegative() {
- if (!GWT.isScript()) {
+ if (TestUtils.isJvm()) {
// OpenJDK fails this test, so for now we only run it in Production Mode
return;
}
@@ -411,7 +411,7 @@
* negate(MathContext) for a positive BigDecimal.
*/
public void testNegateMathContextPositive() {
- if (!GWT.isScript()) {
+ if (TestUtils.isJvm()) {
// OpenJDK fails this test, so for now we only run it in Production Mode
return;
}
diff --git a/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java b/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
index a3f77aa..a7757e8 100644
--- a/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
+++ b/user/test/com/google/gwt/emultest/java/math/BigIntegerConstructorsTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2009 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,15 +21,15 @@
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
- *
+ *
* INCLUDES MODIFICATIONS BY GOOGLE.
*/
/**
@@ -37,8 +37,8 @@
*/
package com.google.gwt.emultest.java.math;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.emultest.java.util.EmulTestBase;
+import com.google.gwt.testing.TestUtils;
import java.math.BigInteger;
import java.util.Random;
@@ -782,7 +782,7 @@
* Test internal static factory method.
*/
public void testValueOfDouble() {
- if (!GWT.isScript()) {
+ if (TestUtils.isJvm()) {
// JRE implementation doesn't have the method tested here
return;
}
diff --git a/user/test/com/google/gwt/emultest/java/util/CollectionsTest.java b/user/test/com/google/gwt/emultest/java/util/CollectionsTest.java
index 77c2e1a..74cd10f 100644
--- a/user/test/com/google/gwt/emultest/java/util/CollectionsTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/CollectionsTest.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.JavaScriptException;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -290,7 +288,7 @@
try {
Collections.rotate(null, 0);
fail("Collections.rotate(null, distance) should throw NullPointerException");
- } catch (NullPointerException | JavaScriptException expected) {
+ } catch (NullPointerException expected) {
// Expected
}
// Test optimized RandomAccess code path
diff --git a/user/test/com/google/gwt/emultest/java/util/DateTest.java b/user/test/com/google/gwt/emultest/java/util/DateTest.java
index 932c8fd..df9cd70 100644
--- a/user/test/com/google/gwt/emultest/java/util/DateTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/DateTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,8 +15,8 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.testing.TestUtils;
import java.util.ArrayList;
import java.util.Date;
@@ -540,7 +540,7 @@
public void testToGMTString() {
// We can't rely on the JRE's toString, as it is an implementation detail.
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
// /////////////////////////////
// Past
// /////////////////////////////
@@ -561,7 +561,7 @@
public void testToLocaleString() {
// We can't rely on the JRE's toString, as it is an implementation detail.
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
// /////////////////////////////
// Past
// /////////////////////////////
@@ -581,7 +581,7 @@
public void testToString() {
// We can't rely on the JRE's toString, as it is an implementation detail.
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
// /////////////////////////////
// Past
// /////////////////////////////
@@ -647,7 +647,7 @@
// Month and date of days with time shifts
private ArrayList<Integer> timeShiftMonth = new ArrayList<Integer>();
private ArrayList<Integer> timeShiftDate = new ArrayList<Integer>();
-
+
private boolean containsTimeShift(Date start, int days) {
long startTime = start.getTime();
Date end = new Date();
@@ -666,12 +666,12 @@
timeShiftDate.add(start.getDate());
return;
}
-
+
// Recurse over the first half of the period
if (containsTimeShift(start, days / 2)) {
findTimeShift(start, days / 2);
}
-
+
// Recurse over the second half of the period
Date mid = new Date();
mid.setTime(start.getTime());
@@ -724,7 +724,7 @@
for (int i = 0; i < numShifts; i++) {
int month = timeShiftMonth.get(i);
int startDay = timeShiftDate.get(i);
-
+
for (int day = startDay; day <= startDay + 1; day++) {
for (int hour = 0; hour < 24; hour++) {
Date d = new Date(year - 1900, month, day, hour, 0, 0);
@@ -744,7 +744,7 @@
/**
* Check if daylight saving time occurs on the date.
- *
+ *
* @param date the date to check
* @return true if DST occurs on the date, false if not
*/
@@ -762,12 +762,12 @@
if (!findClockBackwardTime(2009, monthDayHour)) {
return;
}
-
+
Date d;
int month = monthDayHour[0];
int day = monthDayHour[1];
int hour = monthDayHour[2];
-
+
// Check that this is the later of the two times having the
// same hour:minute:second
d = new Date(2009 - 1900, month, day, hour, 30, 0);
diff --git a/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java b/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
index d605394..d6bc22c 100644
--- a/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,7 +15,7 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.testing.TestUtils;
import org.apache.commons.collections.TestMap;
@@ -104,7 +104,7 @@
/**
* Check the state of a newly constructed, empty IdentityHashMap.
- *
+ *
* @param hashMap
*/
private static void checkEmptyHashMapAssumptions(IdentityHashMap hashMap) {
@@ -502,7 +502,7 @@
hashMap1.put(new Foo(), VALUE_1);
hashMap2.put(new Foo(), VALUE_1);
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
// Only reliable in Production Mode since Development Mode can have
// identity hash collisions.
assertFalse(hashMap1.hashCode() == hashMap2.hashCode());
diff --git a/user/test/com/google/gwt/emultest/java/util/LinkedHashMapTest.java b/user/test/com/google/gwt/emultest/java/util/LinkedHashMapTest.java
index a9152ab..bbbdb40 100644
--- a/user/test/com/google/gwt/emultest/java/util/LinkedHashMapTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/LinkedHashMapTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2006 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,7 +15,7 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.testing.TestUtils;
import org.apache.commons.collections.TestMap;
@@ -117,7 +117,7 @@
/**
* Check the state of a newly constructed, empty LinkedHashMap.
- *
+ *
* @param hashMap
*/
private static void checkEmptyLinkedHashMapAssumptions(LinkedHashMap<?, ?> hashMap) {
@@ -754,7 +754,7 @@
* @return the copy
*/
private <K, V> LinkedHashMap<K, V> cloneLinkedHashMap(LinkedHashMap<K, V> hashMap) {
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
return new LinkedHashMap<K, V>(hashMap);
} else {
LinkedHashMap<K, V> m = new LinkedHashMap<K, V>();
diff --git a/user/test/com/google/gwt/emultest/java/util/TreeMapTest.java b/user/test/com/google/gwt/emultest/java/util/TreeMapTest.java
index a6cc002..c8cc026 100644
--- a/user/test/com/google/gwt/emultest/java/util/TreeMapTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/TreeMapTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,7 +15,6 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.testing.TestUtils;
import org.apache.commons.collections.TestMap;
@@ -39,10 +38,10 @@
/**
* Tests <code>TreeMap</code>.
- *
+ *
* @param <K> The key type for the underlying TreeMap
* @param <V> The value type for the underlying TreeMap
- *
+ *
* TODO(jat): this whole structure needs work. Ideally we would port a new
* Apache collections test to GWT, but that is not an insignificant amount of
* work.
@@ -64,7 +63,7 @@
/**
* Verify a Collection is explicitly and implicitly empty.
- *
+ *
* @param collection
*/
@SuppressWarnings("unchecked")
@@ -78,7 +77,7 @@
/**
* Verify a Map is explicitly and implicitly empty.
- *
+ *
* @param map
*/
private static <K, V> void _assertEmpty(Map<K, V> map) {
@@ -95,7 +94,7 @@
* Verify that two Collections are deeply equivalent. Some of the Sets that
* need to be verified do not implement a sensible equals method
* (TreeMap.values for example).
- *
+ *
* @param expected
* @param actual
*/
@@ -116,7 +115,7 @@
/**
* Verify that two Maps are deeply equivalent.
- *
+ *
* @param expected
* @param actual
*/
@@ -134,7 +133,7 @@
/**
* Verify that two SortedMaps are deeply equivalent.
- *
+ *
* @param expected
* @param actual
*/
@@ -257,7 +256,7 @@
/**
* Test method for 'java.util.Map.clear()'.
- *
+ *
* @see java.util.Map#clear()
*/
public void testClear() {
@@ -275,7 +274,7 @@
/**
* Test method for 'java.util.Map.clear()'.
- *
+ *
* @see java.util.Map#clear()
*/
public void testClear_throwsUnsupportedOperationException() {
@@ -313,7 +312,7 @@
/**
* Test method for 'java.util.SortedMap.comparator()'.
- *
+ *
* @see java.util.SortedMap#comparator()
*/
public void testComparator() {
@@ -327,7 +326,7 @@
/**
* Test method for default constructor.
- *
+ *
* @see java.util.TreeMap#TreeMap()
*/
public void testConstructor() {
@@ -337,7 +336,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(Comparator)'.
- *
+ *
* @see java.util.TreeMap#TreeMap(Comparator)
*/
public void testConstructor_comparator() {
@@ -352,7 +351,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(Map)'.
- *
+ *
* @see java.util.TreeMap#TreeMap(Map)
*/
public void testConstructor_Map() {
@@ -372,7 +371,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(Map)'.
- *
+ *
* @see java.util.TreeMap#TreeMap(Map)
*/
@SuppressWarnings("unchecked")
@@ -388,7 +387,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(Map)'.
- *
+ *
* @see java.util.TreeMap#TreeMap(Map)
*/
public void testConstructor_Map_throwsNullPointerException() {
@@ -402,7 +401,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(SortedMap)'.
- *
+ *
* @see java.util.TreeMap#TreeMap(SortedMap)
*/
public void testConstructor_SortedMap() {
@@ -431,7 +430,7 @@
/**
* Test method for 'java.util.TreeMap.TreeMap(SortedMap).
- *
+ *
* @see java.util.TreeMap#TreeMap(SortedMap)
*/
public void testConstructor_SortedMap_throwsNullPointerException() {
@@ -445,7 +444,7 @@
/**
* Test method for 'java.util.Map.containsKey(Object)'. *
- *
+ *
* @see java.util.Map#containsKey(Object)
*/
public void testContainsKey() {
@@ -472,7 +471,7 @@
/**
* Test method for 'java.util.Map.containsKey(Object)'.
- *
+ *
* @see java.util.Map#containsKey(Object)
*/
public void testContainsKey_throwsClassCastException() {
@@ -491,7 +490,7 @@
/**
* Test method for 'java.util.Map.containsKey(Object)'.
- *
+ *
* @see java.util.Map#containsKey(Object)
*/
public void testContainsKey_throwsNullPointerException() {
@@ -508,7 +507,7 @@
/**
* Test method for 'java.util.Map.containsValue(Object)'.
- *
+ *
* @see java.util.Map#containsValue(Object)
*/
@SuppressWarnings("SuspiciousMethodCalls")
@@ -533,7 +532,7 @@
/**
* Test method for 'java.util.Map.containsValue(Object)'.
- *
+ *
* @see java.util.Map#containsValue(Object)
*/
public void testContainsValue_throwsClassCastException() {
@@ -557,7 +556,7 @@
/**
* Test method for 'java.util.Map.containsValue(Object)'.
- *
+ *
* @see java.util.Map#containsValue(Object)
*/
public void testContainsValue_throwsNullPointerException() {
@@ -648,7 +647,7 @@
}
// JDK < 7 does not handle null keys correctly.
- if (useNullKey() && !GWT.isScript() && TestUtils.getJdkVersion() < 7) {
+ if (useNullKey() && TestUtils.isJvm() && TestUtils.getJdkVersion() < 7) {
map.remove(null);
keys.remove(null);
}
@@ -715,7 +714,7 @@
/**
* Test method for 'java.util.Map.entrySet().remove(Object)'.
- *
+ *
* @see java.util.Map#entrySet()
*/
public void testEntrySet_add_throwsUnsupportedOperationException() {
@@ -815,7 +814,7 @@
/**
* Test method for 'java.util.Map.entrySet()'.
- *
+ *
* @see java.util.Map#entrySet()
*/
public void testEntrySet_entries() {
@@ -847,7 +846,7 @@
/**
* Test method for 'java.util.Map.entrySet()'.
- *
+ *
* @see java.util.Map#entrySet()
*/
public void testEntrySet_entries_view() {
@@ -888,7 +887,7 @@
/**
* Test method for 'java.util.Map.entrySet().remove(Object)'.
- *
+ *
* @see java.util.Map#entrySet()
*/
public void testEntrySet_remove() {
@@ -906,7 +905,7 @@
/**
* Test method for 'java.util.Map.entrySet().remove(Object)'.
- *
+ *
* @see java.util.Map#entrySet()
*/
public void testEntrySet_remove_equivalentEntry() {
@@ -929,7 +928,7 @@
/**
* Test method for 'java.util.Object.equals(Object)'.
- *
+ *
* @see java.util.Map#equals(Object)
*/
public void testEquals() {
@@ -976,7 +975,7 @@
/**
* Test method for 'java.util.SortedMap.firstKey()'.
- *
+ *
* @see java.util.SortedMap#firstKey()
*/
public void testFirstKey() {
@@ -1008,7 +1007,7 @@
/**
* Test method for 'java.util.SortedMap.firstKey()'.
- *
+ *
* @see java.util.SortedMap#firstKey()
*/
public void testFirstKey_throwsNoSuchElementException() {
@@ -1094,7 +1093,7 @@
/**
* Test method for 'java.util.Map.get(Object)'.
- *
+ *
* @see java.util.Map#get(Object)
*/
public void testGet() {
@@ -1125,7 +1124,7 @@
/**
* Test method for 'java.util.Map.get(Object)'.
- *
+ *
* @see java.util.Map#get(Object)
*/
public void testGet_throwsClassCastException() {
@@ -1144,7 +1143,7 @@
/**
* Test method for 'java.util.Map.get(Object)'.
- *
+ *
* @see java.util.Map#get(Object)
*/
public void testGet_throwsNullPointerException() {
@@ -1155,7 +1154,7 @@
try {
map.get(null);
// JDK < 7 does not conform to the specification if the map is empty.
- if (!GWT.isScript() && TestUtils.getJdkVersion() > 6) {
+ if (TestUtils.getJdkVersion() > 6) {
assertTrue(useNullKey());
}
} catch (NullPointerException e) {
@@ -1174,7 +1173,7 @@
/**
* Test method for 'java.lang.Object.hashCode()'.
- *
+ *
* @see java.util.Map#hashCode()
*/
public void testHashCode() {
@@ -1214,7 +1213,7 @@
/**
* Test method for 'java.util.SortedMap.headMap(Object)' and
* 'java.util.NavigableMap.headMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#headMap(Object)
* @see java.util.NavigableMap#headMap(Object, boolean)
*/
@@ -1389,7 +1388,7 @@
/**
* Test method for 'java.util.SortedMap.headMap(Object)' and
* 'java.util.NavigableMap.headMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#headMap(Object)
* @see java.util.NavigableMap#headMap(Object, boolean)
*/
@@ -1436,7 +1435,7 @@
/**
* Test method for 'java.util.SortedMap.headMap(Object)' and
* 'java.util.NavigableMap.headMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#headMap(Object)
* @see java.util.NavigableMap#headMap(Object, boolean)
*/
@@ -1473,7 +1472,7 @@
/**
* Test method for 'java.util.SortedMap.headMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#headMap(Object)
*/
@SuppressWarnings("unchecked")
@@ -1507,7 +1506,7 @@
/**
* Test method for 'java.util.SortedMap.headMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#headMap(Object)
*/
public void testHeadMap_throwsNullPointerException() {
@@ -1622,9 +1621,9 @@
/**
* Test method for 'java.util.Map.isEmpty()'.
- *
+ *
* @see java.util.Map#isEmpty()
- *
+ *
*/
public void testIsEmpty() {
K[] keys = getKeys();
@@ -1645,7 +1644,7 @@
/**
* Test method for 'java.util.Map.keySet()'.
- *
+ *
* @see java.util.Map#clear()
*/
public void testKeySet() {
@@ -1666,7 +1665,7 @@
/**
* Test method for 'java.util.Map.keySet()'.
- *
+ *
* @see java.util.Map#clear()
*/
public void testKeySet_viewPut() {
@@ -1682,7 +1681,7 @@
/**
* Test method for 'java.util.Map.keySet()'.
- *
+ *
* @see java.util.Map#clear()
*/
public void testKeySet_viewRemove() {
@@ -1757,7 +1756,7 @@
/**
* Test method for 'java.util.SortedMap.lastKey()'.
- *
+ *
* @see java.util.SortedMap#lastKey()
*/
public void testLastKey() {
@@ -1807,7 +1806,7 @@
/**
* Test method for 'java.util.SortedMap.lastKey()'.
- *
+ *
* @see java.util.SortedMap#lastKey()
*/
public void testLastKey_throwsNoSuchElementException() {
@@ -2070,7 +2069,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut() {
@@ -2096,7 +2095,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut_entries3() {
@@ -2130,13 +2129,13 @@
* Test method for 'java.util.Map.put(Object, Object)'. This test shows some
* bad behavior of the TreeMap class before JDK 7. A mapping with null key can
* be put in but several methods are are unusable afterward.
- *
+ *
* A SortedMap with natural ordering (no comparator) is supposed to throw a
* null pointer exception if a null keys are "not supported". For a natural
* ordered TreeMap before JDK 7, a null pointer exception is not thrown. But,
* the map is left in a state where any other key based methods result in a
* null pointer exception.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut_nullKey() {
@@ -2167,7 +2166,7 @@
sortedMap.subMap(getLessThanMinimumKey(), getGreaterThanMaximumKey());
sortedMap.headMap(getLessThanMinimumKey());
sortedMap.tailMap(getLessThanMinimumKey());
- } else if (!GWT.isScript() && TestUtils.getJdkVersion() > 6) {
+ } else if (TestUtils.getJdkVersion() > 6) {
// nulls are rejected immediately and don't poison the map anymore
try {
assertNull(sortedMap.put(null, values[0]));
@@ -2257,7 +2256,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut_replace() {
@@ -2277,7 +2276,8 @@
}
public void testPut_ComparableKey() {
- final boolean java6CompatibleSources = GWT.isScript() || TestUtils.getJdkVersion() < 7;
+ final boolean java6CompatibleSources =
+ !TestUtils.isJvm() || TestUtils.getJdkVersion() < 7;
TreeMap<String, Object> map = new TreeMap<String, Object>();
ConflictingKey conflictingKey = new ConflictingKey("conflictingKey");
try {
@@ -2297,7 +2297,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
@SuppressWarnings("unchecked")
@@ -2320,7 +2320,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
@SuppressWarnings("unchecked")
@@ -2343,7 +2343,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut_throwsNullPointerException() {
@@ -2357,7 +2357,7 @@
try {
map.put(null, values[0]);
// JDK < 7 does not conform to the specification if the map is empty.
- if (!GWT.isScript() && TestUtils.getJdkVersion() > 6) {
+ if (TestUtils.getJdkVersion() > 6) {
assertTrue(useNullKey());
}
} catch (NullPointerException e) {
@@ -2384,7 +2384,7 @@
/**
* Test method for 'java.util.Map.put(Object, Object)'.
- *
+ *
* @see java.util.Map#put(Object, Object)
*/
public void testPut_throwsUnsupportedOperationException() {
@@ -2403,7 +2403,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll() {
@@ -2443,7 +2443,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_addEntries() {
@@ -2466,7 +2466,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_emptyMap() {
@@ -2488,7 +2488,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_overwrite() {
@@ -2511,7 +2511,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_self() {
@@ -2532,7 +2532,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
@SuppressWarnings("unchecked")
@@ -2559,7 +2559,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_throwsIllegalOperationException() {
@@ -2572,7 +2572,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_throwsNullPointerException() {
@@ -2591,7 +2591,7 @@
/**
* Test method for 'java.util.Map.putAll(Map)'.
- *
+ *
* @see java.util.Map#putAll(Map)
*/
public void testPutAll_throwsUnsupportedOperationException() {
@@ -2608,7 +2608,7 @@
/**
* Test method for 'java.util.Map.remove(Object)'.
- *
+ *
* @see java.util.Map#remove(Object)
*/
public void testRemove() {
@@ -2653,7 +2653,7 @@
/**
* Test method for 'java.util.Map.remove(Object)'.
- *
+ *
* @see java.util.Map#remove(Object)
*/
public void testRemove_throwsClassCastException() {
@@ -2676,7 +2676,7 @@
/**
* Test method for 'java.util.Map.remove(Object)'.
- *
+ *
* @see java.util.Map#remove(Object)
*/
@SuppressWarnings("unchecked")
@@ -2691,7 +2691,7 @@
try {
map.remove(null);
// JDK < 7 does not conform to the specification if the map is empty.
- if (!GWT.isScript() && TestUtils.getJdkVersion() > 6) {
+ if (TestUtils.getJdkVersion() > 6) {
assertTrue(useNullKey());
}
} catch (NullPointerException e) {
@@ -2711,7 +2711,7 @@
/**
* Test method for 'java.util.Map.remove(Object)'.
- *
+ *
* @see java.util.Map#remove(Object)
*/
public void testRemove_throwsUnsupportedOperationException() {
@@ -2729,7 +2729,7 @@
/**
* Test method for 'java.util.Map.size()'.
- *
+ *
* @see java.util.Map#size()
*/
public void testSize() {
@@ -2790,7 +2790,7 @@
/**
* Test method for 'java.util.SortedMap.subMap(Object, Object)' and
* 'java.util.NavigableMap.subMap(Object, boolean, Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#subMap(Object, Object)
* @see java.util.NavigableMap#subMap(Object, boolean, Object, boolean)
*/
@@ -2977,7 +2977,7 @@
}
// JDK < 7 does not handle null keys correctly.
- if (!GWT.isScript() && TestUtils.getJdkVersion() < 7) {
+ if (TestUtils.isJvm() && TestUtils.getJdkVersion() < 7) {
return;
}
@@ -3000,7 +3000,7 @@
/**
* Test method for 'java.util.SortedMap.subMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#subMap(Object, Object)
*/
@SuppressWarnings("unchecked")
@@ -3034,7 +3034,7 @@
/**
* Test method for 'java.util.SortedMap.subMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#subMap(Object, Object)
*/
public void testSubMap_throwsIllegalArgumentException() {
@@ -3050,7 +3050,7 @@
/**
* Test method for 'java.util.SortedMap.subMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#subMap(Object, Object)
*/
public void testSubMap_throwsNullPointerException() {
@@ -3110,7 +3110,7 @@
/**
* Test method for 'java.util.SortedMap.tailMap(Object)' and
* 'java.util.NavigableMap.tailMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#tailMap(Object)
* @see java.util.NavigableMap#tailMap(Object, boolean)
*/
@@ -3127,7 +3127,7 @@
/**
* Test method for 'java.util.SortedMap.tailMap(Object)' and
* 'java.util.NavigableMap.tailMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#tailMap(Object)
* @see java.util.NavigableMap#tailMap(Object, boolean)
*/
@@ -3152,7 +3152,7 @@
/**
* Test method for 'java.util.SortedMap.tailMap(Object)' and
* 'java.util.NavigableMap.tailMap(Object, boolean)'.
- *
+ *
* @see java.util.SortedMap#tailMap(Object)
* @see java.util.NavigableMap#tailMap(Object, boolean)
*/
@@ -3205,7 +3205,7 @@
/**
* Test method for 'java.util.SortedMap.tailMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#tailMap(Object)
*/
@SuppressWarnings("unchecked")
@@ -3239,7 +3239,7 @@
/**
* Test method for 'java.util.SortedMap.tailMap(Object, Object)'.
- *
+ *
* @see java.util.SortedMap#tailMap(Object)
*/
public void testTailMap_throwsNullPointerException() {
@@ -3303,7 +3303,7 @@
/**
* Test method for 'java.util.Map.values()'.
- *
+ *
* @see java.util.Map#values()
*/
public void testValues() {
@@ -3367,7 +3367,7 @@
/**
* Test method for 'java.util.Map.values()'.
- *
+ *
* @see java.util.Map#values()
*/
public void testValues_nullKey() {
@@ -3390,7 +3390,7 @@
/**
* Test method for 'java.util.Map.values()'.
- *
+ *
* @see java.util.Map#values()
*/
public void testValues_viewPut() {
@@ -3412,7 +3412,7 @@
/**
* Test method for 'java.util.Map.values()'.
- *
+ *
* @see java.util.Map#values()
*/
public void testValues_viewRemove() {
@@ -3471,7 +3471,7 @@
@Override
protected void verifyMap() {
- if (GWT.isScript()) {
+ if (!TestUtils.isJvm()) {
// Verify red-black correctness in our implementation
TreeMapViolator.callAssertCorrectness(map);
}
diff --git a/user/test/com/google/gwt/emultest/java/util/TreeSetTest.java b/user/test/com/google/gwt/emultest/java/util/TreeSetTest.java
index ba3a37e..8fcd829 100644
--- a/user/test/com/google/gwt/emultest/java/util/TreeSetTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/TreeSetTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,7 +15,7 @@
*/
package com.google.gwt.emultest.java.util;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.testing.TestUtils;
import org.apache.commons.collections.TestSet;
@@ -34,9 +34,9 @@
/**
* Tests <code>TreeSet</code>.
- *
+ *
* @param <E> The key type for the underlying TreeSet
- *
+ *
* TODO(jat): this whole structure needs work. Ideally we would port a new
* Apache collections test to GWT, but that is not an insignificant amount of
* work.
@@ -45,7 +45,7 @@
/**
* Verify a Set is explicitly and implicitly empty.
- *
+ *
* @param set
*/
private static <E> void _assertEmpty(Set<E> set) {
@@ -58,7 +58,7 @@
* Verify that two Collections are deeply equivalent. Some of the Sets that
* need to be verified do not implement a sensible equals method
* (TreeSet.values for example).
- *
+ *
* @param expected
* @param actual
*/
@@ -79,7 +79,7 @@
/**
* Verify that two SortedMaps are deeply equivalent.
- *
+ *
* @param expected
* @param actual
*/
@@ -127,7 +127,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#put(Object)
*/
public void testAdd() {
@@ -143,7 +143,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#add(Object)
*/
public void testAdd_entries3() {
@@ -169,7 +169,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#add(Object)
*/
public void testAdd_replace() {
@@ -188,7 +188,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#add(Object)
*/
@SuppressWarnings("unchecked")
@@ -201,7 +201,7 @@
try {
Set untypedSet = set;
untypedSet.add(getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -210,7 +210,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#add(Object)
*/
@SuppressWarnings("unchecked")
@@ -231,7 +231,7 @@
/**
* Test method for 'java.util.Set.add(Object)'.
- *
+ *
* @see java.util.Set#add(Object)
*/
public void testAdd_throwsUnsupportedOperationException() {
@@ -248,7 +248,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll() {
@@ -269,7 +269,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll_addEntries() {
@@ -290,7 +290,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll_emptyMap() {
@@ -310,7 +310,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll_overwrite() {
@@ -331,7 +331,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
@SuppressWarnings("ModifyingCollectionWithItself")
@@ -350,7 +350,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
@SuppressWarnings("unchecked")
@@ -367,7 +367,7 @@
// This throws in dev mode because we're putting a second entry in
// the set and TreeSet calls the compare method to order them.
destSet.addAll(sourceSet);
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -376,7 +376,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll_throwsNullPointerException() {
@@ -395,7 +395,7 @@
/**
* Test method for 'java.util.Set.addAll(Map)'.
- *
+ *
* @see java.util.Set#addAll(Map)
*/
public void testAddAll_throwsUnsupportedOperationException() {
@@ -427,7 +427,7 @@
/**
* Test method for 'java.util.Set.clear()'.
- *
+ *
* @see java.util.Set#clear()
*/
public void testClear() {
@@ -445,7 +445,7 @@
/**
* Test method for 'java.util.Set.clear()'.
- *
+ *
* @see java.util.Set#clear()
*/
public void testClear_throwsUnsupportedOperationException() {
@@ -462,7 +462,7 @@
/**
* Test method for 'java.util.SortedSet.comparator()'.
- *
+ *
* @see java.util.SortedSet#comparator()
*/
public void testComparator() {
@@ -476,7 +476,7 @@
/**
* Test method for default constructor.
- *
+ *
* @see java.util.TreeSet#TreeSet()
*/
public void testConstructor() {
@@ -486,7 +486,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(Comparator)'.
- *
+ *
* @see java.util.TreeSet#TreeSet(Comparator)
*/
public void testConstructor_comparator() {
@@ -501,7 +501,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(Set)'.
- *
+ *
* @see java.util.TreeSet#TreeSet(Set)
*/
public void testConstructor_Set() {
@@ -519,7 +519,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(Set)'.
- *
+ *
* @see java.util.TreeSet#TreeSet(Set)
*/
@SuppressWarnings("unchecked")
@@ -534,7 +534,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(Set)'.
- *
+ *
* @see java.util.TreeSet#TreeSet(Set)
*/
public void testConstructor_Set_throwsNullPointerException() {
@@ -548,7 +548,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(SortedSet).
- *
+ *
* @see java.util.TreeSet#TreeSet(SortedSet)
*/
public void testConstructor_SortedMap_throwsNullPointerException() {
@@ -562,7 +562,7 @@
/**
* Test method for 'java.util.TreeSet.TreeSet(SortedSet)'.
- *
+ *
* @see java.util.TreeSet#TreeSet(SortedSet)
*/
public void testConstructor_SortedSet() {
@@ -580,7 +580,7 @@
/**
* Test method for 'java.util.Set.contains(Object)'. *
- *
+ *
* @see java.util.Set#contains(Object)
*/
public void testContains() {
@@ -594,7 +594,7 @@
/**
* Test method for 'java.util.Set.contains(Object)'.
- *
+ *
* @see java.util.Set#contains(Object)
*/
public void testContains_throwsClassCastException() {
@@ -602,7 +602,7 @@
set.add(getKeys()[0]);
try {
set.contains(getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -610,7 +610,7 @@
/**
* Test method for 'java.util.Set.contains(Object)'.
- *
+ *
* @see java.util.Set#contains(Object)
*/
public void testContains_throwsNullPointerException() {
@@ -674,7 +674,7 @@
/**
* Test method for 'java.util.Object.equals(Object)'.
- *
+ *
* @see java.util.Set#equals(Object)
*/
public void testEquals() {
@@ -691,7 +691,7 @@
/**
* Test method for 'java.util.SortedSet.first()'.
- *
+ *
* @see java.util.SortedSet#first()
*/
public void testFirst() {
@@ -716,7 +716,7 @@
/**
* Test method for 'java.util.SortedSet.first()'.
- *
+ *
* @see java.util.SortedSet#first()
*/
public void testFirstKey_throwsNoSuchElementException() {
@@ -749,7 +749,7 @@
/**
* Test method for 'java.lang.Object.hashCode()'.
- *
+ *
* @see java.util.Set#hashCode()
*/
public void testHashCode() {
@@ -776,7 +776,7 @@
/**
* Test method for 'java.util.SortedSet.headSet(Object, Object)'.
- *
+ *
* @see java.util.SortedSet#headSet(Object)
*/
@SuppressWarnings("unchecked")
@@ -789,7 +789,7 @@
} else {
try {
SortedSet.headSet(getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -799,7 +799,7 @@
/**
* Test method for 'java.util.SortedSet.headSet(Object)' and
* 'java.util.NavigableSet.headSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#headSet(Object)
* @see java.util.NavigableSet#headSet(Object, boolean)
*/
@@ -814,7 +814,7 @@
/**
* Test method for 'java.util.SortedSet.headSet(Object)' and
* 'java.util.NavigableSet.headSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#headSet(Object)
* @see java.util.NavigableSet#headSet(Object, boolean)
*/
@@ -829,7 +829,7 @@
/**
* Test method for 'java.util.SortedSet.headSet(Object)' and
* 'java.util.NavigableSet.headSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#headSet(Object)
* @see java.util.NavigableSet#headSet(Object, boolean)
*/
@@ -846,7 +846,7 @@
/**
* Test method for 'java.util.SortedSet.headSet(Object)' and
* 'java.util.NavigableSet.headSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#headSet(Object)
* @see java.util.NavigableSet#headSet(Object, boolean)
*/
@@ -889,9 +889,9 @@
/**
* Test method for 'java.util.Set.isEmpty()'. *
- *
+ *
* @see java.util.Set#isEmpty()
- *
+ *
*/
public void testIsEmpty() {
Set<E> sourceSet = createSet();
@@ -910,7 +910,7 @@
/**
* Test method for 'java.util.SortedSet.last()'.
- *
+ *
* @see java.util.SortedSet#last()
*/
public void testLastKey() {
@@ -936,7 +936,7 @@
/**
* Test method for 'java.util.SortedSet.last()'.
- *
+ *
* @see java.util.SortedSet#last()
*/
public void testLastKey_throwsNoSuchElementException() {
@@ -1007,7 +1007,7 @@
/**
* Test method for 'java.util.Set.remove(Object)'.
- *
+ *
* @see java.util.Set#remove(Object)
*/
public void testRemove() {
@@ -1025,7 +1025,7 @@
/**
* Test method for 'java.util.Set.remove(Object)'.
- *
+ *
* @see java.util.Set#remove(Object)
*/
public void testRemove_throwsClassCastException() {
@@ -1036,7 +1036,7 @@
set.add(getKeys()[0]);
try {
set.remove(getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -1045,7 +1045,7 @@
/**
* Test method for 'java.util.Set.remove(Object)'.
- *
+ *
* @see java.util.Set#remove(Object)
*/
public void testRemove_throwsUnsupportedOperationException() {
@@ -1062,7 +1062,7 @@
/**
* Test method for 'java.util.Set.size()'.
- *
+ *
* @see java.util.Set#size()
*/
public void testSize() {
@@ -1097,7 +1097,7 @@
/**
* Test method for 'java.util.SortedSet.subSet(Object, Object)'.
- *
+ *
* @see java.util.SortedSet#subSet(Object, Object)
*/
@SuppressWarnings("unchecked")
@@ -1106,19 +1106,19 @@
SortedSet.add(getKeys()[0]);
try {
SortedSet.subSet(getConflictingKey(), getKeys()[0]);
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (IllegalArgumentException e) {
// since we can't ensure CCEs in Production Mode, we may get IAE
- assertTrue("IllegalArgumentException in Development Mode", GWT.isScript());
+ assertTrue("IllegalArgumentException in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
try {
SortedSet.subSet(getKeys()[0], getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (IllegalArgumentException e) {
// since we can't ensure CCEs in Production Mode, we may get IAE
- assertTrue("IllegalArgumentException in Development Mode", GWT.isScript());
+ assertTrue("IllegalArgumentException in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -1126,7 +1126,7 @@
/**
* Test method for 'java.util.SortedSet.subSet(Object, Object)'.
- *
+ *
* @see java.util.SortedSet#subSet(Object, Object)
*/
public void testSubMap_throwsIllegalArgumentException() {
@@ -1143,7 +1143,7 @@
/**
* Test method for 'java.util.SortedSet.subSet(Object, Object)' and
* 'java.util.NavigableSet.subSet(Object, boolean, Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#subSet(Object, Object)
* @see java.util.NavigableSet#subSet(Object, boolean, Object, boolean)
*/
@@ -1219,7 +1219,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object)' and
* '@see java.util.NavigableSet.tailSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
* @see java.util.NavigableSet#tailSet(Object, boolean)
*/
@@ -1235,7 +1235,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object)' and
* '@see java.util.NavigableSet.tailSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
* @see java.util.NavigableSet#tailSet(Object, boolean)
*/
@@ -1259,7 +1259,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object)' and
* '@see java.util.NavigableSet.tailSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
* @see java.util.NavigableSet#tailSet(Object, boolean)
*/
@@ -1284,7 +1284,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object)' and
* '@see java.util.NavigableSet.tailSet(Object, boolean)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
* @see java.util.NavigableSet#tailSet(Object, boolean)
*/
@@ -1328,7 +1328,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object, Object)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
*/
@SuppressWarnings("unchecked")
@@ -1341,7 +1341,7 @@
} else {
try {
SortedSet.tailSet(getConflictingKey());
- assertTrue("CCE expected in Development Mode", GWT.isScript());
+ assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
} catch (ClassCastException e) {
// expected outcome
}
@@ -1350,7 +1350,7 @@
/**
* Test method for 'java.util.SortedSet.tailSet(Object, Object)'.
- *
+ *
* @see java.util.SortedSet#tailSet(Object)
*/
public void testTailSet_throwsIllegalArgumentException() {
diff --git a/user/test/com/google/gwt/testing/TestUtils.gwt.xml b/user/test/com/google/gwt/testing/TestUtils.gwt.xml
index 7a02008..d485f79 100644
--- a/user/test/com/google/gwt/testing/TestUtils.gwt.xml
+++ b/user/test/com/google/gwt/testing/TestUtils.gwt.xml
@@ -13,6 +13,5 @@
<!-- limitations under the License. -->
<module>
- <inherits name="com.google.gwt.regexp.RegExp"/>
<source path='' />
</module>
diff --git a/user/test/com/google/gwt/testing/TestUtils.java b/user/test/com/google/gwt/testing/TestUtils.java
index c4a6d05..b1ee1ff 100644
--- a/user/test/com/google/gwt/testing/TestUtils.java
+++ b/user/test/com/google/gwt/testing/TestUtils.java
@@ -15,16 +15,11 @@
*/
package com.google.gwt.testing;
-import com.google.gwt.regexp.shared.MatchResult;
-import com.google.gwt.regexp.shared.RegExp;
-
/**
* Utility functions needed by various tests.
*/
public class TestUtils {
- private static final String VERSION_REGEXP = "1\\.([0-9]+)(\\..*)?";
-
public static int getJdkVersion() {
String versionString = System.getProperty("java.version", "none");
if (versionString.equals("none")) {
@@ -34,9 +29,13 @@
return getMajorVersion(versionString);
}
+ public static boolean isJvm() {
+ return getJdkVersion() != -1;
+ }
+
private static int getMajorVersion(String versionString) {
- MatchResult matchResult = RegExp.compile(VERSION_REGEXP).exec(versionString);
- assert matchResult.getGroup(0).equals(versionString);
- return Integer.parseInt(matchResult.getGroup(1));
+ String[] split = versionString.split("\\.");
+ assert split.length >= 1;
+ return Integer.parseInt(split[1]);
}
}