r110099 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110098‎ | r110099 | r110100 >
Date:00:15, 27 January 2012
Author:oren
Status:deferred
Tags:
Comment:
updated path to test date
Modified paths:
  • /trunk/lucene-search-3/src/test/java/org/wikimedia/lsearch/config/GlobalConfigurationTest.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-3/src/test/java/org/wikimedia/lsearch/config/GlobalConfigurationTest.java
@@ -10,7 +10,9 @@
1111 import java.util.Properties;
1212 import java.util.regex.Pattern;
1313
14 -import org.apache.log4j.Logger;
 14+import org.junit.After;
 15+import org.junit.Before;
 16+import org.junit.Test;
1517 import org.wikimedia.lsearch.search.NamespaceFilter;
1618 import org.wikimedia.lsearch.test.AbstractWikiTestCase;
1719 import org.wikimedia.lsearch.util.StringUtils;
@@ -21,13 +23,15 @@
2224 */
2325 public class GlobalConfigurationTest extends AbstractWikiTestCase { // NOPMD by OrenBochman on 1/15/12 3:38 AM
2426
25 - private static final Logger LOG = Logger.getLogger(GlobalConfigurationTest.class.getName());
 27+ // private static final Logger LOGGER =
 28+ // Logger.getLogger(GlobalConfigurationTest.class.getName());
2629 private transient GlobalConfiguration global = null;
2730 private transient IndexId frTest=null;
2831
2932 private transient Hashtable<String, Hashtable<String, Hashtable<String, String>>> database;
3033
3134 @Override
 35+ @Before
3236 public void setUp() {
3337
3438 super.setUp();
@@ -37,18 +41,22 @@
3842 database = global.database;
3943 frTest = IndexId.get("frtest");
4044 }
 45+
4146 @Override
 47+ @After
4248 public void tearDown() {
 49+ // XXX: is this method really needed?
4350
4451 database=null;
4552 frTest=null;
4653 }
4754
 55+ @Test
4856 public void testPreprocessLine(){
4957
5058 String winPathFixer;
5159 if(System.getProperty("os.name").startsWith("Windows")){
52 - winPathFixer = File.separator;
 60+ winPathFixer = "/";
5361 }else{
5462 winPathFixer="";
5563 }
@@ -57,19 +65,17 @@
5866 assertEquals("preprocessLine() failed - ",text,global.preprocessLine(text));
5967
6068 final StringBuilder dburl = new StringBuilder("file://")
61 - .append(winPathFixer)
62 - .append(System.getProperty("user.dir"))
63 - .append(File.separator)
64 - .append("test-data")
65 - .append(File.separator)
66 - .append("dbs.test");
 69+ .append(winPathFixer).append(System.getProperty("user.dir"))
 70+ .append(File.separator).append("src").append(File.separator)
 71+ .append("test").append(File.separator)
 72+ .append("resources").append(File.separator).append("dbs.test");
6773 text = "{"+dburl+"}: (mainsplit)";
6874
6975 assertEquals("preprocessLine() failed - ","entest,rutest,srtest,kktest: (mainsplit)",global.preprocessLine(text));
7076 }
7177
7278
73 -
 79+ @Test
7480 public void testRoles(){
7581 // database
7682
@@ -85,7 +91,7 @@
8692 assertEquals("10",mainpart.get("maxBufDocs"));
8793 }
8894
89 -
 95+ @Test
9096 public void testReadURLSplitRoles(){
9197
9298 Hashtable<String, Hashtable<String, String>> splitroles = database.get("frtest");
@@ -95,6 +101,7 @@
96102 assertNotNull(splitroles.get("part3"));
97103 }
98104
 105+ @Test
99106 public void testParts(){
100107 Hashtable<String, String> nspart1 = database.get("njawiki").get("nspart1");
101108 assertEquals("false",nspart1.get("optimize"));
@@ -102,6 +109,7 @@
103110
104111 }
105112
 113+ @Test
106114 public void testReadURLAdress(){
107115 // search
108116 Hashtable<String,ArrayList<String>> search = global.search;
@@ -115,6 +123,7 @@
116124 assertEquals(6,ssr.length);
117125 }
118126
 127+ @Test
119128 public void testSearchGroups(){
120129 // search groups
121130 Hashtable<Integer,Hashtable<String,ArrayList<String>>> searchGroups = global.searchGroup;
@@ -124,7 +133,8 @@
125134 Hashtable<String,ArrayList<String>> group1 = searchGroups.get(Integer.valueOf(1));
126135 assertEquals("{192.168.0.6=[frtest.part3, detest], 192.168.0.4=[frtest.part1, frtest.part2]}",group1.toString());
127136 }
128 -
 137+
 138+ @Test
129139 public void testIndex(){
130140 // index
131141 Hashtable<String,ArrayList<String>> index = global.index;
@@ -150,10 +160,8 @@
151161
152162 assertEquals("192.168.0.5",indexLocation.get("entest.mainpart"));
153163 assertEquals("192.168.0.2",indexLocation.get("entest.ngram"));
154 -
155164 }
156165
157 -
158166
159167 public void testPrefixes(){
160168
@@ -161,8 +169,9 @@
162170 Hashtable<String,NamespaceFilter> prefixes = global.namespacePrefix;
163171 assertEquals(17,prefixes.size());
164172
165 -}
 173+ }
166174
 175+ @Test
167176 public void testGlobalProperties(){
168177
169178 // check global properties
@@ -171,6 +180,7 @@
172181 assertEquals("wiki rutest",prop.get("KeywordScoring.suffix"));
173182 }
174183
 184+ @Test
175185 public void testLanguages(){
176186
177187 // check languages and keyword stuff
@@ -179,9 +189,9 @@
180190 assertFalse(global.useKeywordScoring("frtest"));
181191 assertTrue(global.useKeywordScoring("srwiki"));
182192 assertTrue(global.useKeywordScoring("rutest"));
 193+ }
183194
184 -}
185 -
 195+ @Test
186196 public void testOaiRepository(){
187197
188198 // test oai repo stuff
@@ -192,16 +202,18 @@
193203
194204 assertEquals("http://sr.wikipedia.org/w/index.php?title=Special:OAIRepository",global.getOAIRepo("srwiki"));
195205 assertEquals("http://localhost/wiki-lucene/phase3/index.php?title=Special:OAIRepository",global.getOAIRepo("frtest"));
196 -}
 206+ }
197207
 208+ @Test
198209 public void testInitiazeSettings(){
199210 //FIXME: try to add InitialiseSettings.php to testdata/
200211 // InitialiseSettings test
201212 assertEquals("sr",global.getLanguage("rswikimedia"));
202213 assertEquals("http://rs.wikimedia.org/w/index.php?title=Special:OAIRepository",global.getOAIRepo("rswikimedia"));
203214 assertEquals("http://commons.wikimedia.org/w/index.php?title=Special:OAIRepository",global.getOAIRepo("commonswiki"));
204 -}
205 -
 215+ }
 216+
 217+ @Test
206218 public void testSuggestTags(){
207219 // test suggest tag
208220 Hashtable<String,String> sug = global.getDBParams("entest","spell");
@@ -210,6 +222,7 @@
211223
212224 }
213225
 226+ @Test
214227 public void testOrphans() {
215228
216229 IndexId enw = IndexId.get("enwiktionary");
@@ -221,7 +234,9 @@
222235 assertFalse(enIndexId.getSearchHosts().contains("oblak2"));
223236 }
224237
 238+ @Test
225239 public void testIndexIds(){
 240+
226241 IndexId entest = IndexId.get("entest");
227242
228243 assertTrue(entest.isMainsplit());
@@ -235,14 +250,18 @@
236251
237252 }
238253
 254+ @Test
239255 public void testgetType(){
 256+
240257 IndexId entest = IndexId.get("entest");
241258
242259 //assertEquals(null,entest.getSnapshotPath());
243260 assertEquals("mainsplit",entest.getType());
244261 }
245 -
 262+
 263+ @Test
246264 public void testgetRsyncSnapshotPath(){
 265+
247266 IndexId entest = IndexId.get("entest");
248267
249268 assertEquals("/mwsearch2/snapshot/entest",entest.getRsyncSnapshotPath());
@@ -260,7 +279,8 @@
261280 //assertEquals(null,enrest.getIndexPath());
262281
263282 }
264 -
 283+
 284+ @Test
265285 public void testGetFrench(){
266286
267287
@@ -272,7 +292,8 @@
273293 assertEquals(3,frTest.getSplitFactor());
274294
275295 }
276 -
 296+
 297+ @Test
277298 public void testGetFrenchPart(){
278299
279300
@@ -287,11 +308,14 @@
288309 assertFalse(detest.isLogical());
289310
290311 }
291 -
 312+
 313+ /**
 314+ * check nssplit configuration option.
 315+ * this configuration option should split the index into servral parts
 316+ */
 317+ @Test
292318 public void testGetNjPart(){
293319
294 -
295 - // check nssplit
296320 IndexId njawiki = IndexId.get("njawiki");
297321 assertTrue(njawiki.isLogical());
298322 assertFalse(njawiki.isSplit());
@@ -310,7 +334,8 @@
311335 assertEquals(2,njawiki2.getPartNum());
312336 assertEquals("[192.168.0.1]",njawiki2.getSearchHosts().toString());
313337 }
314 -
 338+
 339+ @Test
315340 public void testEnSpell(){
316341
317342 IndexId sug = IndexId.get("entest.spell");
@@ -318,7 +343,8 @@
319344 assertFalse(sug.isLogical());
320345 assertEquals(sug,sug.getSpell());
321346 }
322 -
 347+
 348+ @Test
323349 public void testEnSubdivided(){
324350
325351 IndexId sub1 = IndexId.get("entest.mainpart.sub1");
@@ -337,7 +363,8 @@
338364 //assertNull(enmain.getImportPath());
339365
340366 }
341 -
 367+
 368+ @Test
342369 public void testHmSubdivided(){
343370
344371
@@ -361,7 +388,8 @@
362389 assertEquals("[192.168.0.1]",hhl1.getSearchHosts().toString());
363390
364391 }
365 -
 392+
 393+ @Test
366394 public void testEnTitles(){
367395
368396
@@ -370,7 +398,8 @@
371399 assertEquals(2,ent.getSplitFactor());
372400 //assertEquals("[en-titles.tspart2, en-titles.tspart1]",ent.getPhysicalIndexes().toString());
373401 }
374 -
 402+
 403+ @Test
375404 public void testEnTitlesParts(){
376405
377406 IndexId ents1 = IndexId.get("en-titles.tspart1");
@@ -391,7 +420,8 @@
392421 assertEquals("mw",mwt.getInterwikiBySuffix("mediawikiwiki"));
393422 assertEquals("{mediawikiwiki=mediawikiwiki, metawiki=metawiki}",mwt.getSuffixToDbname().toString());
394423 }
395 -
 424+
 425+ @Test
396426 public void testEnSpellPrecursor(){
397427
398428 IndexId ep = IndexId.get("entest.spell.pre");
@@ -406,6 +436,7 @@
407437
408438 }
409439
 440+ @Test
410441 public void testComplexWildcard(){
411442 Pattern p = Pattern.compile(StringUtils.wildcardToRegexp("(?!(enwiki.|dewiki.|frwiki.|itwiki.|nlwiki|.))*.spell"));
412443 assertFalse(p.matcher("enwiki.spell").matches());

Status & tagging log