String caches its hash code, so prefer HashMap to TreeMap.

This commit is contained in:
akwizgran
2011-11-28 15:40:16 +00:00
parent ebd6ebf902
commit b72a90be21
3 changed files with 9 additions and 9 deletions

View File

@@ -5,9 +5,10 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -46,14 +47,14 @@ public class ZipUtilsTest extends TestCase {
zip.flush();
zip.close();
Map<String, String> expected = new TreeMap<String, String>();
expected.put("abc/def", "foo bar baz");
Map<String, String> expected = Collections.singletonMap("abc/def",
"foo bar baz");
checkZipEntries(dest, expected);
}
private void checkZipEntries(File f, Map<String, String> expected)
throws IOException {
Map<String, String> found = new TreeMap<String, String>();
Map<String, String> found = new HashMap<String, String>();
assertTrue(f.exists());
assertTrue(f.isFile());
ZipInputStream unzip = new ZipInputStream(new FileInputStream(f));
@@ -108,7 +109,7 @@ public class ZipUtilsTest extends TestCase {
zip.flush();
zip.close();
Map<String, String> expected = new TreeMap<String, String>();
Map<String, String> expected = new HashMap<String, String>();
expected.put("ghi/def/1", "one one one");
expected.put("ghi/def/2", "two two two");
expected.put("ghi/3", "three three three");