You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/07/19 17:59:32 UTC
svn commit: r1363400 [29/31] - in /lucene/dev/branches/pforcodec_3892: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/
dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene...
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestBadConfig.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestBadConfig.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestBadConfig.java Thu Jul 19 15:58:54 2012
@@ -17,31 +17,36 @@
package org.apache.solr.core;
-import org.apache.solr.util.AbstractSolrTestCase;
+import javax.script.ScriptEngineManager;
-public class TestBadConfig extends AbstractSolrTestCase {
+import org.junit.Assume;
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "bad_solrconfig.xml"; }
-
- @Override
- public void setUp() throws Exception {
- ignoreException("unset.sys.property");
- try {
- super.setUp();
- fail("Exception should have been thrown");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("unset.sys.property"));
- } finally {
- resetExceptionIgnores();
- }
+public class TestBadConfig extends AbstractBadConfigTestBase {
+
+ public void testUnsetSysProperty() throws Exception {
+ assertConfigs("bad_solrconfig.xml","schema.xml","unset.sys.property");
+ }
+
+ public void testBogusScriptEngine() throws Exception {
+ // sanity check
+ Assume.assumeTrue(null == (new ScriptEngineManager()).getEngineByName("giberish"));
+
+ assertConfigs("bad-solrconfig-bogus-scriptengine-name.xml",
+ "schema.xml","giberish");
}
-
- public void testNothing() {
- // Empty test case as the real test is that the initialization of the TestHarness fails
- assertTrue(true);
+ public void testMissingScriptFile() throws Exception {
+ // sanity check
+ Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
+ assertConfigs("bad-solrconfig-missing-scriptfile.xml",
+ "schema.xml","a-file-name-that-does-not-exist.js");
}
-}
\ No newline at end of file
+
+ public void testInvalidScriptFile() throws Exception {
+ // sanity check
+ Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("javascript"));
+ assertConfigs("bad-solrconfig-invalid-scriptfile.xml",
+ "schema.xml","currency.xml");
+ }
+
+}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java Thu Jul 19 15:58:54 2012
@@ -29,7 +29,7 @@ public class TestCodecSupport extends So
@BeforeClass
public static void beforeClass() throws Exception {
- initCore("solrconfig-basic.xml", "schema_codec.xml");
+ initCore("solrconfig_codec.xml", "schema_codec.xml");
}
public void testPostingsFormats() {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestConfig.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestConfig.java Thu Jul 19 15:58:54 2012
@@ -23,6 +23,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.admin.ShowFileRequestHandler;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.update.SolrIndexConfig;
+import org.apache.solr.util.RefCounted;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Node;
@@ -109,14 +110,21 @@ public class TestConfig extends SolrTest
//System.out.println( handler.getHiddenFiles() );
// should not contain: <gettableFiles>solrconfig.xml scheam.xml admin-extra.html</gettableFiles>
- assertFalse(handler.getHiddenFiles().contains("scheam.xml".toUpperCase(Locale.ENGLISH)));
+ assertFalse(handler.getHiddenFiles().contains("scheam.xml".toUpperCase(Locale.ROOT)));
assertTrue(handler.getHiddenFiles().contains("PROTWORDS.TXT"));
}
@Test
public void testTermIndexInterval() throws Exception {
- IndexWriter writer = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
- int interval = writer.getConfig().getTermIndexInterval();
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()
+ .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
+ int interval = 0;
+ try {
+ IndexWriter writer = iw.get();
+ interval = writer.getConfig().getTermIndexInterval();
+ } finally {
+ iw.decref();
+ }
assertEquals(256, interval);
}
@@ -130,7 +138,7 @@ public class TestConfig extends SolrTest
// If defaults change, add test methods to cover each version
@Test
public void testDefaults() throws Exception {
- SolrConfig sc = new SolrConfig("solrconfig-basic.xml");
+ SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-basic.xml", null);
SolrIndexConfig sic = sc.indexConfig;
assertTrue("default ramBufferSizeMB should be 32", sic.ramBufferSizeMB == 32);
assertTrue("default useCompoundFile should be false", sic.useCompoundFile == false);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Thu Jul 19 15:58:54 2012
@@ -19,14 +19,16 @@ package org.apache.solr.core;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -172,7 +174,7 @@ public class TestCoreContainer extends S
assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
try {
File solrXmlFile = new File(solrHomeDirectory, "solr.xml");
- BufferedWriter out = new BufferedWriter(new FileWriter(solrXmlFile));
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(solrXmlFile), IOUtils.CHARSET_UTF_8));
out.write(EMPTY_SOLR_XML);
out.close();
} catch (IOException e) {
@@ -195,7 +197,7 @@ public class TestCoreContainer extends S
assertEquals("There should not be cores", 0, cores.getCores().size());
//add a new core
- CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", SolrTestCaseJ4.TEST_HOME());
+ CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", SolrTestCaseJ4.TEST_HOME() + "/collection1");
SolrCore newCore = cores.create(coreDescriptor);
cores.register(newCore, false);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInject.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInject.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInject.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInject.java Thu Jul 19 15:58:54 2012
@@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.RefCounted;
public class TestPropInject extends AbstractSolrTestCase {
@Override
@@ -37,14 +38,25 @@ public class TestPropInject extends Abst
}
public void testMergePolicy() throws Exception {
- IndexWriter writer = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
- LogByteSizeMergePolicy mp = (LogByteSizeMergePolicy)writer.getConfig().getMergePolicy();
+
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
+ LogByteSizeMergePolicy mp;
+ try {
+ mp = (LogByteSizeMergePolicy)iw.get().getConfig().getMergePolicy();
+ } finally {
+ iw.decref();
+ }
assertEquals(64.0, mp.getMaxMergeMB(), 0);
}
public void testProps() throws Exception {
- IndexWriter writer = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
- ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler)writer.getConfig().getMergeScheduler();
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
+ ConcurrentMergeScheduler cms;
+ try {
+ cms = (ConcurrentMergeScheduler)iw.get().getConfig().getMergeScheduler();
+ } finally {
+ iw.decref();
+ }
assertEquals(2, cms.getMaxThreadCount());
}
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java Thu Jul 19 15:58:54 2012
@@ -22,6 +22,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.update.DirectUpdateHandler2;
+import org.apache.solr.util.RefCounted;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -33,15 +34,27 @@ public class TestPropInjectDefaults exte
@Test
public void testMergePolicyDefaults() throws Exception {
- IndexWriter writer = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
- LogByteSizeMergePolicy mp = (LogByteSizeMergePolicy)writer.getConfig().getMergePolicy();
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()
+ .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
+ LogByteSizeMergePolicy mp;
+ try {
+ mp = (LogByteSizeMergePolicy) iw.get().getConfig().getMergePolicy();
+ } finally {
+ iw.decref();
+ }
assertEquals(32.0, mp.getMaxMergeMB(), 0);
}
@Test
public void testPropsDefaults() throws Exception {
- IndexWriter writer = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
- ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler)writer.getConfig().getMergeScheduler();
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()
+ .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
+ ConcurrentMergeScheduler cms;
+ try {
+ cms = (ConcurrentMergeScheduler) iw.get().getConfig().getMergeScheduler();
+ } finally {
+ iw.decref();
+ }
assertEquals(4, cms.getMaxThreadCount());
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java Thu Jul 19 15:58:54 2012
@@ -22,7 +22,6 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
@@ -40,6 +39,7 @@ import javax.xml.xpath.XPathFactory;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
import org.apache.solr.core.SolrXMLSerializer.SolrCoreXMLDef;
import org.apache.solr.core.SolrXMLSerializer.SolrXMLDef;
import org.junit.Test;
@@ -82,16 +82,16 @@ public class TestSolrXMLSerializer exten
assertResults(((StringWriter) w).getBuffer().toString().getBytes("UTF-8"));
// again with default file
- File tmpFile = File.createTempFile("solr", ".xml", TEMP_DIR);
+ File tmpFile = _TestUtil.getTempDir("solr.xml");
serializer.persistFile(tmpFile, solrXMLDef);
assertResults(FileUtils.readFileToString(tmpFile, "UTF-8").getBytes("UTF-8"));
+ tmpFile.delete();
}
private void assertResults(byte[] bytes)
- throws ParserConfigurationException, UnsupportedEncodingException,
- IOException, SAXException, XPathExpressionException {
+ throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
BufferedInputStream is = new BufferedInputStream(new ByteArrayInputStream(bytes));
Document document;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Thu Jul 19 15:58:54 2012
@@ -18,11 +18,13 @@ package org.apache.solr.handler;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URL;
import java.util.regex.Matcher;
@@ -36,6 +38,7 @@ import org.apache.lucene.search.MatchAll
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.TestDistributedSearch;
@@ -62,10 +65,13 @@ import org.junit.BeforeClass;
* @since 1.4
*/
// TODO: can this test be sped up? it used to not be so slow...
+@Slow
public class TestReplicationHandler extends SolrTestCaseJ4 {
- private static final String CONF_DIR = "." + File.separator + "solr" + File.separator + "conf" + File.separator;
+ private static final String CONF_DIR = "." + File.separator + "solr"
+ + File.separator + "collection1" + File.separator + "conf"
+ + File.separator;
static JettySolrRunner masterJetty, slaveJetty;
static SolrServer masterClient, slaveClient;
@@ -77,12 +83,10 @@ public class TestReplicationHandler exte
// index from previous test method
static int nDocs = 500;
- // TODO: fix this test to not require FSDirectory.. doesnt even work with MockFSDirectory... wtf?
- static String savedFactory;
+
@BeforeClass
public static void beforeClass() throws Exception {
- savedFactory = System.getProperty("solr.DirectoryFactory");
- System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
+ useFactory(null); // need an FS factory
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@@ -112,11 +116,6 @@ public class TestReplicationHandler exte
slaveJetty.stop();
master.tearDown();
slave.tearDown();
- if (savedFactory == null) {
- System.clearProperty("solr.directoryFactory");
- } else {
- System.setProperty("solr.directoryFactory", savedFactory);
- }
}
private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {
@@ -932,8 +931,8 @@ public class TestReplicationHandler exte
* character copy of file using UTF-8. If port is non-null, will be substituted any time "TEST_PORT" is found.
*/
private static void copyFile(File src, File dst, Integer port) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(src));
- Writer out = new FileWriter(dst);
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(src), "UTF-8"));
+ Writer out = new OutputStreamWriter(new FileOutputStream(dst), "UTF-8");
for (String line = in.readLine(); null != line; line = in.readLine()) {
@@ -1000,8 +999,8 @@ public class TestReplicationHandler exte
homeDir = new File(home, name);
- dataDir = new File(homeDir, "data");
- confDir = new File(homeDir, "conf");
+ dataDir = new File(homeDir + "/collection1", "data");
+ confDir = new File(homeDir + "/collection1", "conf");
homeDir.mkdirs();
dataDir.mkdirs();
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java Thu Jul 19 15:58:54 2012
@@ -18,13 +18,10 @@ package org.apache.solr.handler.componen
*/
import java.io.File;
-import java.io.IOException;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.util.FileUtils;
-import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -44,13 +41,13 @@ public class DistributedQueryElevationCo
}
@BeforeClass
- public static void beforeClass() throws IOException {
+ public static void beforeClass() {
System.setProperty("elevate.data.file", "elevate.xml");
File parent = new File(TEST_HOME(), "conf");
}
@AfterClass
- public static void afterClass() throws IOException {
+ public static void afterClass() {
System.clearProperty("elevate.data.file");
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java Thu Jul 19 15:58:54 2012
@@ -20,12 +20,14 @@ package org.apache.solr.handler.componen
import junit.framework.Assert;
import junit.framework.TestCase;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SpellingParams;
import org.apache.solr.common.util.NamedList;
+import org.junit.BeforeClass;
/**
* Test for SpellCheckComponent's distributed querying
@@ -34,6 +36,7 @@ import org.apache.solr.common.util.Named
*
* @see org.apache.solr.handler.component.SpellCheckComponent
*/
+@Slow
public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTestCase {
private String requestHandlerName;
@@ -45,14 +48,14 @@ public class DistributedSpellCheckCompon
//shardCount=2;
//stress=0;
}
-
- private String saveProp;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ useFactory(null); // need an FS factory
+ }
@Override
public void setUp() throws Exception {
- // this test requires FSDir
- saveProp = System.getProperty("solr.directoryFactory");
- System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
if(random().nextBoolean()) {
requestHandlerName = "spellCheckCompRH";
reqHandlerWithWordbreak = "spellCheckWithWordbreak";
@@ -66,10 +69,6 @@ public class DistributedSpellCheckCompon
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (saveProp == null)
- System.clearProperty("solr.directoryFactory");
- else
- System.setProperty("solr.directoryFactory", saveProp);
}
private void q(Object... q) throws Exception {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java Thu Jul 19 15:58:54 2012
@@ -19,6 +19,7 @@ package org.apache.solr.handler.componen
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
@@ -34,6 +35,7 @@ import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
@@ -55,7 +57,7 @@ public class QueryElevationComponentTest
private void init(String config, String schema) throws Exception {
//write out elevate-data.xml to the Data dir first by copying it from conf, which we know exists, this way we can test both conf and data configurations
createTempDir();
- File parent = new File(TEST_HOME(), "conf");
+ File parent = new File(TEST_HOME() + "/collection1", "conf");
File elevateFile = new File(parent, "elevate.xml");
File elevateDataFile = new File(dataDir, "elevate-data.xml");
FileUtils.copyFile(elevateFile, elevateDataFile);
@@ -412,7 +414,7 @@ public class QueryElevationComponentTest
// write a test file to boost some docs
private void writeFile(File file, String query, String... ids) throws Exception {
- PrintWriter out = new PrintWriter(new FileOutputStream(file));
+ PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), IOUtils.CHARSET_UTF_8));
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
out.println("<elevate>");
out.println("<query text=\"" + query + "\">");
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java Thu Jul 19 15:58:54 2012
@@ -20,6 +20,7 @@ package org.apache.solr.handler.componen
import java.io.File;
import java.util.*;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -39,6 +40,7 @@ import org.junit.Test;
/**
* @since solr 1.3
*/
+@Slow
public class SpellCheckComponentTest extends SolrTestCaseJ4 {
static String rh = "spellCheckCompRH";
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java Thu Jul 19 15:58:54 2012
@@ -174,7 +174,7 @@ public class StatsComponentTest extends
public void testFieldStatisticsResultsDateField() throws Exception {
SolrCore core = h.getCore();
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String date1 = dateFormat.format(new Date(123456789)) + "Z";
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/internal/csv/writer/CSVConfigGuesserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/internal/csv/writer/CSVConfigGuesserTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/internal/csv/writer/CSVConfigGuesserTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/internal/csv/writer/CSVConfigGuesserTest.java Thu Jul 19 15:58:54 2012
@@ -43,7 +43,7 @@ public class CSVConfigGuesserTest extend
* 1234 ; abcd ; 1234 ;
*
*/
- public void testConfigGuess1() {
+ public void testConfigGuess1() throws Exception {
CSVConfig expected = new CSVConfig();
expected.setDelimiter(';');
expected.setValueDelimiter(' ');
@@ -57,7 +57,7 @@ public class CSVConfigGuesserTest extend
StringBuffer sb = new StringBuffer();
sb.append("1234;abcd;1234\n");
sb.append("abcd;1234;abcd");
- ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
+ ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
CSVConfigGuesser guesser = new CSVConfigGuesser(in);
CSVConfig guessed = guesser.guess();
assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
@@ -70,7 +70,7 @@ public class CSVConfigGuesserTest extend
* 1,2,3,4
*
*/
- public void testConfigGuess2() {
+ public void testConfigGuess2() throws Exception {
CSVConfig expected = new CSVConfig();
expected.setDelimiter(';');
expected.setValueDelimiter(' ');
@@ -80,7 +80,7 @@ public class CSVConfigGuesserTest extend
StringBuffer sb = new StringBuffer();
sb.append("1,2,3,4\n");
sb.append("abcd,1234,abcd,1234");
- ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
+ ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
CSVConfigGuesser guesser = new CSVConfigGuesser(in);
CSVConfig guessed = guesser.guess();
assertEquals(expected.isFixedWidth(), guessed.isFixedWidth());
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java Thu Jul 19 15:58:54 2012
@@ -55,7 +55,7 @@ public class TestBinaryResponseWriter ex
* Tests known types implementation by asserting correct encoding/decoding of UUIDField
*/
public void testUUID() throws Exception {
- String s = UUID.randomUUID().toString().toLowerCase(Locale.ENGLISH);
+ String s = UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
assertU(adoc("id", "101", "uuid", s));
assertU(commit());
LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*");
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestFaceting.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestFaceting.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestFaceting.java Thu Jul 19 15:58:54 2012
@@ -52,7 +52,7 @@ public class TestFaceting extends SolrTe
}
String t(int tnum) {
- return String.format(Locale.US, "%08d", tnum);
+ return String.format(Locale.ROOT, "%08d", tnum);
}
void createIndex(int nTerms) {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java Thu Jul 19 15:58:54 2012
@@ -33,6 +33,7 @@ import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
@@ -83,7 +84,7 @@ public class TestRemoteStreaming extends
InputStream inputStream = (InputStream) obj;
try {
StringWriter strWriter = new StringWriter();
- IOUtils.copy(inputStream,strWriter);
+ IOUtils.copy(new InputStreamReader(inputStream, "UTF-8"),strWriter);
return strWriter.toString();
} finally {
IOUtils.closeQuietly(inputStream);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java Thu Jul 19 15:58:54 2012
@@ -86,7 +86,7 @@ public class TestWriterPerf extends Abst
/** make sure to close req after you are done using the response */
- public SolrQueryResponse getResponse(SolrQueryRequest req) throws IOException, Exception {
+ public SolrQueryResponse getResponse(SolrQueryRequest req) throws Exception {
SolrQueryResponse rsp = new SolrQueryResponse();
h.getCore().execute(h.getCore().getRequestHandler(null),req,rsp);
if (rsp.getException() != null) {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Thu Jul 19 15:58:54 2012
@@ -17,38 +17,15 @@
package org.apache.solr.schema;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.core.SolrConfig;
+import org.apache.solr.core.AbstractBadConfigTestBase;
import java.util.regex.Pattern;
-import org.junit.Test;
-
-public class BadIndexSchemaTest extends SolrTestCaseJ4 {
+public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
private void doTest(final String schema, final String errString)
throws Exception {
-
- ignoreException(Pattern.quote(errString));
- try {
- initCore( "solrconfig.xml", schema );
- } catch (SolrException e) {
- // short circuit out if we found what we expected
- if (-1 != e.getMessage().indexOf(errString)) return;
- // Test the cause too in case the expected error is wrapped
- if (null != e.getCause() &&
- -1 != e.getCause().getMessage().indexOf(errString)) return;
-
- // otherwise, rethrow it, possibly completley unrelated
- throw new SolrException
- (ErrorCode.SERVER_ERROR,
- "Unexpected error, expected error matching: " + errString, e);
- } finally {
- deleteCore();
- }
- fail("Did not encounter any exception from: " + schema);
+ assertConfigs("solrconfig.xml", schema, errString);
}
public void testSevereErrorsForInvalidFieldOptions() throws Exception {
@@ -86,4 +63,13 @@ public class BadIndexSchemaTest extends
"can not be configured with a default value");
}
+ public void testPerFieldtypeSimButNoSchemaSimFactory() throws Exception {
+ doTest("bad-schema-sim-global-vs-ft-mismatch.xml", "global similarity does not support it");
+ }
+
+ public void testPerFieldtypePostingsFormatButNoSchemaCodecFactory() throws Exception {
+ doTest("bad-schema-codec-global-vs-ft-mismatch.xml", "codec does not support");
+ }
+
+
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java Thu Jul 19 15:58:54 2012
@@ -158,7 +158,7 @@ public class CurrencyFieldTest extends S
@Ignore
public void testPerformance() throws Exception {
- Random r = new Random();
+ Random r = random();
int initDocs = 200000;
for (int i = 1; i <= initDocs; i++) {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java Thu Jul 19 15:58:54 2012
@@ -31,7 +31,7 @@ import java.util.Locale;
public class DateFieldTest extends LuceneTestCase {
public static TimeZone UTC = TimeZone.getTimeZone("UTC");
protected DateField f = null;
- protected DateMathParser p = new DateMathParser(UTC, Locale.US);
+ protected DateMathParser p = new DateMathParser(UTC, Locale.ROOT);
@Override
public void setUp() throws Exception {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java Thu Jul 19 15:58:54 2012
@@ -41,7 +41,7 @@ public class OpenExchangeRatesOrgProvide
mockParams = new HashMap<String,String>();;
mockParams.put(OpenExchangeRatesOrgProvider.PARAM_RATES_FILE_LOCATION, "open-exchange-rates.json");
oerp = new OpenExchangeRatesOrgProvider();
- loader = new SolrResourceLoader("solr");
+ loader = new SolrResourceLoader("solr/collection1");
}
@Test
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java Thu Jul 19 15:58:54 2012
@@ -21,13 +21,12 @@ import java.util.Collections;
import java.util.HashMap;
import org.apache.lucene.document.Field;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.common.util.Base64;
import org.apache.solr.schema.PreAnalyzedField.PreAnalyzedParser;
import org.junit.Test;
-import junit.framework.TestCase;
-
-public class PreAnalyzedFieldTest extends TestCase {
+public class PreAnalyzedFieldTest extends LuceneTestCase {
private static final String[] valid = {
"1 one two three", // simple parsing
@@ -71,7 +70,8 @@ public class PreAnalyzedFieldTest extend
int props =
FieldProperties.INDEXED | FieldProperties.STORED;
- public void setUp() {
+ public void setUp() throws Exception {
+ super.setUp();
field = new SchemaField("content", new TextField(), props, null);
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java Thu Jul 19 15:58:54 2012
@@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrConfig;
+import org.apache.solr.core.SolrResourceLoader;
import org.junit.Test;
import java.io.File;
@@ -29,7 +30,7 @@ import java.util.TimeZone;
* Tests that defaults are set for Primitive (non-analyzed) fields
*/
public class PrimitiveFieldTypeTest extends SolrTestCaseJ4 {
- private final String testConfHome = TEST_HOME() + File.separator + "conf"+ File.separator;
+ private final String testConfHome = TEST_HOME() + File.separator + "collection1" + File.separator + "conf"+ File.separator;
public static TimeZone UTC = TimeZone.getTimeZone("UTC");
protected SolrConfig config;
protected IndexSchema schema;
@@ -43,7 +44,7 @@ public class PrimitiveFieldTypeTest exte
System.setProperty("solr.test.sys.prop2", "proptwo");
initMap = new HashMap<String,String>();
- config = new SolrConfig(testConfHome + "solrconfig.xml");
+ config = new SolrConfig(new SolrResourceLoader("solr/collection1"), testConfHome + "solrconfig.xml", null);
}
@SuppressWarnings("deprecation")
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java Thu Jul 19 15:58:54 2012
@@ -55,21 +55,21 @@ public class TestBinaryField extends Luc
"solrtest-TestBinaryField-" + System.currentTimeMillis());
File homeDir = new File(home, "example");
- File dataDir = new File(homeDir, "data");
- File confDir = new File(homeDir, "conf");
+ File dataDir = new File(homeDir + "/collection1", "data");
+ File confDir = new File(homeDir + "/collection1", "conf");
homeDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
- SolrResourceLoader loader = new SolrResourceLoader(null, null);
+ SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
File f = new File(confDir, "solrconfig.xml");
- String fname = "solr/conf/solrconfig-slave1.xml";
+ String fname = "solr/collection1/conf/solrconfig-slave1.xml";
FileOutputStream out = new FileOutputStream(f);
IOUtils.copy(loader.openResource(fname), out);
out.close();
f = new File(confDir, "schema.xml");
- fname = "solr/conf/schema-binaryfield.xml";
+ fname = "solr/collection1/conf/schema-binaryfield.xml";
out = new FileOutputStream(f);
IOUtils.copy(loader.openResource(fname), out);
out.close();
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestCollationField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestCollationField.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestCollationField.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/schema/TestCollationField.java Thu Jul 19 15:58:54 2012
@@ -23,6 +23,8 @@ import java.text.Collator;
import java.text.RuleBasedCollator;
import java.util.Locale;
+import org.apache.lucene.util._TestUtil;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
@@ -61,18 +63,18 @@ public class TestCollationField extends
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
- File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR);
+ File tmpFile = _TestUtil.getTempDir("collation1");
tmpFile.delete();
tmpFile.mkdir();
// make data and conf dirs
new File(tmpFile, "data").mkdir();
- File confDir = new File(tmpFile, "conf");
- confDir.mkdir();
+ File confDir = new File(tmpFile + "/collection1", "conf");
+ confDir.mkdirs();
// copy over configuration files
- FileUtils.copyFile(getFile("solr/conf/solrconfig-basic.xml"), new File(confDir, "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/conf/schema-collate.xml"), new File(confDir, "schema.xml"));
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"), new File(confDir, "solrconfig.xml"));
+ FileUtils.copyFile(getFile("solr/collection1/conf/schema-collate.xml"), new File(confDir, "schema.xml"));
// generate custom collation rules (DIN 5007-2), saving to customrules.dat
RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new Locale("de", "DE"));
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java Thu Jul 19 15:58:54 2012
@@ -16,23 +16,17 @@ package org.apache.solr.search;
* limitations under the License.
*/
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.SortField;
import org.apache.lucene.search.QueryUtils;
-
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.schema.IndexSchema;
-
-import java.util.Set;
-import java.util.HashSet;
-
-import org.junit.BeforeClass;
import org.junit.AfterClass;
+import org.junit.BeforeClass;
@@ -44,7 +38,7 @@ import org.junit.AfterClass;
* {@link #testParserCoverage} until you add a new test method to this class.
*
* @see ValueSourceParser#standardValueSourceParsers
- * @see QParserPlugin.standardPlugins
+ * @see QParserPlugin#standardPlugins
* @see QueryUtils
**/
public class QueryEqualityTest extends SolrTestCaseJ4 {
@@ -686,7 +680,7 @@ public class QueryEqualityTest extends S
* the parser being tested for coverage sanity checking
*
* @see QueryUtils#check
- * @see QueryUtils#checkEquals
+ * @see QueryUtils#checkEqual
* @see #testParserCoverage
*/
protected void assertQueryEquals(final String defType,
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Thu Jul 19 15:58:54 2012
@@ -17,10 +17,9 @@
package org.apache.solr.search;
-import java.io.IOException;
-
import org.apache.solr.common.SolrException;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.Test;
public class TestExtendedDismaxParser extends AbstractSolrTestCase {
@Override
@@ -53,7 +52,7 @@ public class TestExtendedDismaxParser ex
"text", "line up and fly directly at the enemy death cannons, clogging them with wreckage!"));
assertU(adoc("id", "48", "text_sw", "this has gigabyte potential", "foo_i","100"));
assertU(adoc("id", "49", "text_sw", "start the big apple end", "foo_i","-100"));
- assertU(adoc("id", "50", "text_sw", "start new big city end"));
+ assertU(adoc("id", "50", "text_sw", "start new big city end"));
assertU(adoc("id", "51", "store", "12.34,-56.78"));
assertU(adoc("id", "52", "text_sw", "tekna theou klethomen"));
assertU(adoc("id", "53", "text_sw", "nun tekna theou esmen"));
@@ -66,6 +65,39 @@ public class TestExtendedDismaxParser ex
// the super classes version
super.tearDown();
}
+
+
+ public void testLowercaseOperators() {
+ assertQ("Upper case operator",
+ req("q","Zapp AND Brannigan",
+ "qf", "name",
+ "lowercaseOperators", "false",
+ "defType","edismax")
+ ,"*[count(//doc)=1]");
+
+ assertQ("Upper case operator, allow lowercase",
+ req("q","Zapp AND Brannigan",
+ "qf", "name",
+ "lowercaseOperators", "true",
+ "defType","edismax")
+ ,"*[count(//doc)=1]");
+
+ assertQ("Lower case operator, don't allow lowercase operators",
+ req("q","Zapp and Brannigan",
+ "qf", "name",
+ "q.op", "AND",
+ "lowercaseOperators", "false",
+ "defType","edismax")
+ ,"*[count(//doc)=0]");
+
+ assertQ("Lower case operator, allow lower case operators",
+ req("q","Zapp and Brannigan",
+ "qf", "name",
+ "q.op", "AND",
+ "lowercaseOperators", "true",
+ "defType","edismax")
+ ,"*[count(//doc)=1]");
+ }
// test the edismax query parser based on the dismax parser
public void testFocusQueryParser() {
@@ -320,6 +352,7 @@ public class TestExtendedDismaxParser ex
}
public void testUserFields() {
+ String allr = "*[count(//doc)=10]";
String oner = "*[count(//doc)=1]";
String nor = "*[count(//doc)=0]";
@@ -333,9 +366,24 @@ public class TestExtendedDismaxParser ex
assertQ(req("defType","edismax", "q","id:42"),
oner);
- assertQ(req("defType","edismax", "uf","*", "q","id:42"),
+ // SOLR-3377 - parens should be allowed immediately before field name
+ assertQ(req("defType","edismax", "q","( id:42 )"),
oner);
-
+ assertQ(req("defType","edismax", "q","(id:42)"),
+ oner);
+ assertQ(req("defType","edismax", "q","(+id:42)"),
+ oner);
+ assertQ(req("defType","edismax", "q","+(+id:42)"),
+ oner);
+ assertQ(req("defType","edismax", "q","+(+((id:42)))"),
+ oner);
+ assertQ(req("defType","edismax", "q","+(+((+id:42)))"),
+ oner);
+ assertQ(req("defType","edismax", "q"," +( +( ( +id:42) ) ) "),
+ oner);
+ assertQ(req("defType","edismax", "q","(id:(*:*)^200)"),
+ allr);
+
assertQ(req("defType","edismax", "uf","id", "q","id:42"),
oner);
@@ -396,7 +444,7 @@ public class TestExtendedDismaxParser ex
}
- public void testAliasing() throws IOException, Exception {
+ public void testAliasing() throws Exception {
String oner = "*[count(//doc)=1]";
String twor = "*[count(//doc)=2]";
String nor = "*[count(//doc)=0]";
@@ -429,12 +477,12 @@ public class TestExtendedDismaxParser ex
}
- public void testAliasingBoost() throws IOException, Exception {
+ public void testAliasingBoost() throws Exception {
assertQ(req("defType","edismax", "q","Zapp Pig", "qf","myalias", "f.myalias.qf","name trait_ss^0.5"), "//result/doc[1]/str[@name='id']=42", "//result/doc[2]/str[@name='id']=47");//doc 42 should score higher than 46
assertQ(req("defType","edismax", "q","Zapp Pig", "qf","myalias^100 name", "f.myalias.qf","trait_ss^0.5"), "//result/doc[1]/str[@name='id']=47", "//result/doc[2]/str[@name='id']=42");//Now the order should be inverse
}
- public void testCyclicAliasing() throws IOException, Exception {
+ public void testCyclicAliasing() throws Exception {
try {
h.query(req("defType","edismax", "q","ignore_exception", "qf","who", "f.who.qf","name","f.name.qf","who"));
fail("Simple cyclic alising");
@@ -626,5 +674,85 @@ public class TestExtendedDismaxParser ex
"//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc\"~3^333.0')]",
"//str[@name='parsedquery'][contains(.,'phrase_sw:\"xxxx cccc vvvv\"~3^333.0')]"
);
+
+ assertQ(
+ "ps2 not working",
+ req("q", "bar foo", "qf", "phrase_sw", "pf2", "phrase_sw^10", "ps2",
+ "2", "bf", "boost_d", "fl", "score,*", "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='s0']");
+
+ assertQ(
+ "Specifying slop in pf2 param not working",
+ req("q", "bar foo", "qf", "phrase_sw", "pf2", "phrase_sw~2^10", "bf",
+ "boost_d", "fl", "score,*", "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='s0']");
+
+ assertQ(
+ "Slop in ps2 parameter should override ps",
+ req("q", "bar foo", "qf", "phrase_sw", "pf2", "phrase_sw^10", "ps",
+ "0", "ps2", "2", "bf", "boost_d", "fl", "score,*", "defType",
+ "edismax"), "//doc[1]/str[@name='id'][.='s0']");
+
+ assertQ(
+ "ps3 not working",
+ req("q", "a bar foo", "qf", "phrase_sw", "pf3", "phrase_sw^10", "ps3",
+ "3", "bf", "boost_d", "fl", "score,*", "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='s1']");
+
+ assertQ(
+ "Specifying slop in pf3 param not working",
+ req("q", "a bar foo", "qf", "phrase_sw", "pf3", "phrase_sw~3^10", "bf",
+ "boost_d", "fl", "score,*", "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='s1']");
+
+ assertQ("ps2 should not override slop specified inline in pf2",
+ req("q", "zzzz xxxx cccc vvvv",
+ "qf", "phrase_sw",
+ "pf2", "phrase_sw~2^22",
+ "ps2", "4",
+ "defType", "edismax",
+ "debugQuery", "true"),
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx\"~2^22.0')]"
+ );
+
+ }
+
+ /**
+ * verify that all reserved characters are properly escaped when being set in
+ * {@link org.apache.solr.search.ExtendedDismaxQParser.Clause#val}.
+ *
+ * @see ExtendedDismaxQParser#splitIntoClauses(String, boolean)
+ */
+ @Test
+ public void testEscapingOfReservedCharacters() throws Exception {
+ // create a document that contains all reserved characters
+ String allReservedCharacters = "!():^[]{}~*?\"+-\\|&/";
+
+ assertU(adoc("id", "reservedChars",
+ "name", allReservedCharacters,
+ "cat_s", "foo/"));
+ assertU(commit());
+
+ // the backslash needs to be manually escaped (the query parser sees the raw backslash as an escape the subsequent
+ // character)
+ String query = allReservedCharacters.replace("\\", "\\\\");
+
+ // query for all those reserved characters. This will fail to parse in the initial parse, meaning that the escaped
+ // query will then be used
+ assertQ("Escaping reserved characters",
+ req("q", query,
+ "qf", "name",
+ "mm", "100%",
+ "defType", "edismax")
+ , "*[count(//doc)=1]");
+
+ // Query string field 'cat_s' for special char / - causes ParseException without patch SOLR-3467
+ assertQ("Escaping string with reserved / character",
+ req("q", "foo/",
+ "qf", "cat_s",
+ "mm", "100%",
+ "defType", "edismax")
+ , "*[count(//doc)=1]");
+
}
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java Thu Jul 19 15:58:54 2012
@@ -83,7 +83,7 @@ public class TestFastLRUCache extends Lu
doTestPercentageAutowarm(100, 0, new int[]{}, new int[]{1, 10, 25, 51, 55, 60, 70, 80, 99, 100, 200, 300});
}
- private void doTestPercentageAutowarm(int limit, int percentage, int[] hits, int[]misses) throws IOException {
+ private void doTestPercentageAutowarm(int limit, int percentage, int[] hits, int[]misses) {
FastLRUCache<Object, Object> fastCache = new FastLRUCache<Object, Object>();
Map<String, String> params = new HashMap<String, String>();
params.put("size", String.valueOf(limit));
@@ -177,7 +177,7 @@ public class TestFastLRUCache extends Lu
private CacheRegenerator createCodeRegenerator() {
CacheRegenerator cr = new CacheRegenerator() {
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache,
- SolrCache oldCache, Object oldKey, Object oldVal) throws IOException {
+ SolrCache oldCache, Object oldKey, Object oldVal) {
newCache.put(oldKey, oldVal);
return true;
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java Thu Jul 19 15:58:54 2012
@@ -18,9 +18,9 @@ package org.apache.solr.search;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.IndexReaderContext;
+import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.util.ReaderUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.SchemaField;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLFUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLFUCache.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLFUCache.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLFUCache.java Thu Jul 19 15:58:54 2012
@@ -26,6 +26,7 @@ import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
@@ -112,7 +113,7 @@ public class TestLFUCache extends SolrTe
private void assertCache(LFUCache cache, int... gets) {
for (int idx : gets) {
if (cache.get(idx) == null) {
- log.error(String.format("Expected entry %d not in cache", idx));
+ log.error(String.format(Locale.ROOT, "Expected entry %d not in cache", idx));
assertTrue(false);
}
}
@@ -120,7 +121,7 @@ public class TestLFUCache extends SolrTe
private void assertNotCache(LFUCache cache, int... gets) {
for (int idx : gets) {
if (cache.get(idx) != null) {
- log.error(String.format("Unexpected entry %d in cache", idx));
+ log.error(String.format(Locale.ROOT, "Unexpected entry %d in cache", idx));
assertTrue(false);
}
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLRUCache.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLRUCache.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/search/TestLRUCache.java Thu Jul 19 15:58:54 2012
@@ -63,7 +63,7 @@ public class TestLRUCache extends Lucene
doTestPercentageAutowarm(10, 10, new int[]{10}, new int[]{1, 5, 9, 100, 200, 300, 400, 800, 899, 900});
}
- private void doTestPercentageAutowarm(int limit, int percentage, int[] hits, int[]misses) throws IOException {
+ private void doTestPercentageAutowarm(int limit, int percentage, int[] hits, int[]misses) {
LRUCache<Object, Object> lruCache = new LRUCache<Object, Object>();
Map<String, String> params = new HashMap<String, String>();
params.put("size", String.valueOf(limit));
@@ -126,7 +126,7 @@ public class TestLRUCache extends Lucene
CacheRegenerator cr = new CacheRegenerator() {
@SuppressWarnings("unchecked")
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache,
- SolrCache oldCache, Object oldKey, Object oldVal) throws IOException {
+ SolrCache oldCache, Object oldKey, Object oldVal) {
newCache.put(oldKey, oldVal);
return true;
}