r109803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109802‎ | r109803 | r109804 >
Date:02:55, 23 January 2012
Author:oren
Status:deferred
Tags:
Comment:
moved testing code to test code branch - to be converted into unit tests +
minor improvements to method names
Modified paths:
  • /trunk/lucene-search-3/src/main/java/org/wikimedia/lsearch/util/QueryStringMap.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-3/src/main/java/org/wikimedia/lsearch/util/QueryStringMap.java
@@ -26,12 +26,9 @@
2727
2828 import java.io.UnsupportedEncodingException;
2929 import java.net.URI;
30 -import java.net.URISyntaxException;
3130 import java.net.URLDecoder;
32 -import java.util.Iterator;
3331 import java.util.LinkedHashMap;
3432 import java.util.Map;
35 -import java.util.Set;
3633 import java.util.StringTokenizer;
3734
3835 /**
@@ -77,43 +74,4 @@
7875 }
7976 }
8077
81 - public static void main(String[] args) {
82 - try {
83 - testURI("/x");
84 - testURI("/x?foo=bar");
85 - testURI("/x?foo=bar&biz=bax");
86 -
87 - // The %26 should _not_ split 'foo' from 'bogo'
88 - testURI("/x?foo=bar+%26bogo&next=extreme");
89 -
90 - // UTF-8 good encoding
91 - testURI("/x?serveuse=%c3%a9nid");
92 -
93 - // bad encoding; you'll see replacement char
94 - testURI("/x?serveuse=%e9nid");
95 -
96 - // corner cases; missing params
97 - testURI("/x?foo");
98 - testURI("/x?foo&bar=baz");
99 - testURI("/x?foo&&bar");
100 - testURI("/x?&");
101 - testURI("/x?=");
102 - testURI("/x?==&");
103 -
104 - testURI("/updatePage?db=wikilucene&namespace=6&title=Nick+Gorton5+8+05.jpg");
105 - testURI("/getStatus");
106 - } catch (URISyntaxException e) {
107 - e.printStackTrace();
108 - }
109 - }
110 -
111 - private static void testURI(String uri) throws URISyntaxException {
112 - QueryStringMap map = new QueryStringMap(new URI(uri));
113 - System.out.println(uri);
114 - Set<String> keys = map.keySet();
115 - for (Iterator<String> i = keys.iterator(); i.hasNext();) {
116 - String key = i.next();
117 - System.out.println(" \"" + key + "\" => \"" + map.get(key) + "\"");
118 - }
119 - }
12078 }

Status & tagging log