Index: trunk/lucene-search-2/test/org/wikimedia/lsearch/test/WikiTestCase.java |
— | — | @@ -1,19 +1,65 @@ |
2 | 2 | package org.wikimedia.lsearch.test; |
3 | 3 | |
| 4 | +import java.io.File; |
| 5 | + |
| 6 | +import junit.framework.TestCase; |
| 7 | + |
4 | 8 | import org.wikimedia.lsearch.analyzers.WikiQueryParser; |
5 | 9 | import org.wikimedia.lsearch.config.Configuration; |
6 | 10 | import org.wikimedia.lsearch.config.GlobalConfiguration; |
7 | 11 | |
8 | | -import junit.framework.TestCase; |
| 12 | +public abstract class WikiTestCase extends TestCase { |
| 13 | + |
| 14 | + public Configuration getConfig() { |
| 15 | + return config; |
| 16 | + } |
9 | 17 | |
10 | | -public abstract class WikiTestCase extends TestCase { |
| 18 | + |
| 19 | + public void setConfig(final Configuration config) { |
| 20 | + this.config = config; |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | + public GlobalConfiguration getGlobal() { |
| 25 | + return global; |
| 26 | + } |
| 27 | + |
| 28 | + |
| 29 | + public void setGlobal(final GlobalConfiguration global) { |
| 30 | + this.global = global; |
| 31 | + } |
| 32 | + |
| 33 | + |
11 | 34 | protected Configuration config = null; |
| 35 | + |
12 | 36 | protected GlobalConfiguration global = null; |
13 | 37 | |
| 38 | + |
14 | 39 | protected void setUp() throws Exception { |
15 | | - if(config == null){ |
16 | | - Configuration.setConfigFile(System.getProperty("user.dir")+"/test-data/lsearch.conf.test"); |
17 | | - Configuration.setGlobalConfigUrl("file://"+System.getProperty("user.dir")+"/test-data/lsearch-global.test"); |
| 40 | + if(config == null) |
| 41 | + { |
| 42 | + String winPathFixer; |
| 43 | + if(System.getProperty("os.name").startsWith("Windows")){ |
| 44 | + winPathFixer = File.separator; |
| 45 | + }else{ |
| 46 | + winPathFixer=""; |
| 47 | + } |
| 48 | + |
| 49 | + Configuration.setConfigFile( |
| 50 | + System.getProperty("user.dir")+ |
| 51 | + winPathFixer+ |
| 52 | + File.separator+ |
| 53 | + "test-data"+ |
| 54 | + File.separator+ |
| 55 | + "lsearch.conf.test"); |
| 56 | + |
| 57 | + Configuration.setGlobalConfigUrl( |
| 58 | + "file://"+ |
| 59 | + winPathFixer+ |
| 60 | + System.getProperty("user.dir")+ |
| 61 | + File.separator+"test-data"+ |
| 62 | + File.separator+"lsearch-global.test"); |
| 63 | + |
18 | 64 | config = Configuration.open(); |
19 | 65 | global = GlobalConfiguration.getInstance(); |
20 | 66 | WikiQueryParser.TITLE_BOOST = 2; |