Simple fix and accompanying testcase for toString() method in TreeMap.Entry: issue 3422 Patch by: amitmanjhi Review by: scottb git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5367 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/util/TreeMap.java b/user/super/com/google/gwt/emul/java/util/TreeMap.java index 1c6ffcd..f379021 100644 --- a/user/super/com/google/gwt/emul/java/util/TreeMap.java +++ b/user/super/com/google/gwt/emul/java/util/TreeMap.java
@@ -234,7 +234,8 @@ @Override public String toString() { - return (isRed ? "R: " : "B: ") + key + "=" + value; + // for compatibility with the real Jre: issue 3422 + return key + "=" + value; } }
diff --git a/user/test/com/google/gwt/emultest/java/util/TreeMapStringStringTest.java b/user/test/com/google/gwt/emultest/java/util/TreeMapStringStringTest.java index 8f7f714..3568063 100644 --- a/user/test/com/google/gwt/emultest/java/util/TreeMapStringStringTest.java +++ b/user/test/com/google/gwt/emultest/java/util/TreeMapStringStringTest.java
@@ -16,9 +16,11 @@ package com.google.gwt.emultest.java.util; import java.util.Iterator; +import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedMap; +import java.util.TreeMap; /** * Tests <code>TreeMap</code> with Strings and the natural comparator. @@ -118,6 +120,15 @@ assertEquals("lastKey", "dd", subMap.lastKey()); } + // checks for compatibility with real Jre's Entry.toString(): issue 3422 + public void testTreeMapEntryToString() { + Map<String, String> treeMap = new TreeMap<String, String>(); + treeMap.put("bar", "barValue"); + + assertEquals("bar=barValue", + treeMap.entrySet().iterator().next().toString()); + } + @Override protected Object getConflictingKey() { return new Integer(1);