You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2012/12/12 22:41:26 UTC
svn commit: r1420992 [5/7] - in /lucene/dev/branches/branch_4x: ./
dev-tools/ lucene/ lucene/analysis/
lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/
lucene/benchmark/ lucene/codecs/ lucene/core/ lucene/core/src/test/org/ap...
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java Wed Dec 12 21:41:06 2012
@@ -41,7 +41,7 @@ public class AlternateDirectoryTest exte
assertTrue(TestIndexReaderFactory.newReaderCalled);
}
- static public class TestFSDirectoryFactory extends CachingDirectoryFactory {
+ static public class TestFSDirectoryFactory extends StandardDirectoryFactory {
public static volatile boolean openCalled = false;
public static volatile Directory dir;
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java Wed Dec 12 21:41:06 2012
@@ -96,11 +96,9 @@ public class CoreContainerCoreInitFailur
ignoreException(Pattern.quote("bogus_path"));
cc.create(bogus);
fail("bogus inst dir failed to trigger exception from create");
- } catch (Exception e) {
- // :TODO: should really tighten up the exceptions CoreContainer throws (ie: just SolrException)
-
- assertTrue("init exception doesn't mention bogus dir: " + e.getMessage(),
- 0 < e.getMessage().indexOf("bogus_path"));
+ } catch (SolrException e) {
+ assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+ 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
}
@@ -115,8 +113,8 @@ public class CoreContainerCoreInitFailur
assertEquals("wrong number of core failures", 1, failures.size());
fail = failures.get("bogus");
assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("bogus_path"));
+ assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+ 0 < fail.getCause().getMessage().indexOf("bogus_path"));
// let the test end here, with some recorded failures, and let cleanUp()
// verify that there is no problem shuting down CoreContainer with known
@@ -197,11 +195,9 @@ public class CoreContainerCoreInitFailur
ignoreException(Pattern.quote("bogus_path"));
cc.create(bogus);
fail("bogus inst dir failed to trigger exception from create");
- } catch (Exception e) {
- // :TODO: should really tighten up the exceptions CoreContainer throws (ie: just SolrException)
-
- assertTrue("init exception doesn't mention bogus dir: " + e.getMessage(),
- 0 < e.getMessage().indexOf("bogus_path"));
+ } catch (SolrException e) {
+ assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+ 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
}
@@ -218,8 +214,8 @@ public class CoreContainerCoreInitFailur
assertEquals("wrong number of core failures", 1, failures.size());
fail = failures.get("bogus");
assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("bogus_path"));
+ assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+ 0 < fail.getCause().getMessage().indexOf("bogus_path"));
// -----
@@ -254,12 +250,13 @@ public class CoreContainerCoreInitFailur
ignoreException(Pattern.quote("SAX"));
cc.reload("col_bad");
fail("corrupt solrconfig.xml failed to trigger exception from reload");
- } catch (SAXParseException e) {
- // :TODO: should really tighten up the exceptions CoreContainer throws (ie: just SolrException)
-
- assertTrue("reload exception doesn't refer to slrconfig.xml " + e.getSystemId(),
- 0 < e.getSystemId().indexOf("solrconfig.xml"));
-
+ } catch (SolrException e) {
+ assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't",
+ e.getCause() instanceof SAXParseException);
+ SAXParseException se = (SAXParseException)e.getCause();
+ assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(),
+ 0 < se.getSystemId().indexOf("solrconfig.xml"));
+
}
assertEquals("Failed core reload should not have changed start time",
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java Wed Dec 12 21:41:06 2012
@@ -17,17 +17,13 @@ package org.apache.solr.core;
*/
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class IndexReaderFactoryTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig-termindex.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-termindex.xml", "schema.xml");
}
/**
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java Wed Dec 12 21:41:06 2012
@@ -68,7 +68,7 @@ public class SolrCoreCheckLockOnStartupT
assertNotNull(t.getCause());
assertTrue(t.getCause() instanceof RuntimeException);
assertNotNull(t.getCause().getCause());
- assertTrue(t.getCause().getCause() instanceof LockObtainFailedException);
+ assertTrue(t.getCause().getCause().toString(), t.getCause().getCause() instanceof LockObtainFailedException);
} finally {
indexWriter.close();
directory.close();
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Wed Dec 12 21:41:06 2012
@@ -33,6 +33,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.util.Version;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.handler.SnapPuller;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness;
import org.junit.AfterClass;
@@ -84,23 +85,13 @@ public class TestArbitraryIndexDir exten
}
- @Override
- public String getSchemaFile() {
- return null;
- }
-
- @Override
- public String getSolrConfigFile() {
- return null; // prevent superclass from creating it's own TestHarness
- }
-
@Test
public void testLoadNewIndexDir() throws IOException, ParserConfigurationException, SAXException {
//add a doc in original index dir
assertU(adoc("id", String.valueOf(1),
"name", "name"+String.valueOf(1)));
//create a new index dir and index.properties file
- File idxprops = new File(h.getCore().getDataDir() + "index.properties");
+ File idxprops = new File(h.getCore().getDataDir() + SnapPuller.INDEX_PROPERTIES);
Properties p = new Properties();
File newDir = new File(h.getCore().getDataDir() + "index_temp");
newDir.mkdirs();
@@ -111,7 +102,7 @@ public class TestArbitraryIndexDir exten
p.store(os, "index properties");
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Unable to write index.properties", e);
+ "Unable to write " + SnapPuller.INDEX_PROPERTIES, e);
} finally {
if (os != null) os.close();
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java Wed Dec 12 21:41:06 2012
@@ -145,14 +145,6 @@ public class TestConfig extends SolrTest
assertTrue("default LockType should be native", sic.lockType.equals(SolrIndexConfig.LOCK_TYPE_NATIVE));
}
- @Test
- public void testDefaults31() throws Exception {
- SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-basic-luceneVersion31.xml", null);
- SolrIndexConfig sic = sc.indexConfig;
- assertTrue("default useCompoundFile should be true", sic.useCompoundFile == true);
- assertTrue("default LockType should be simple", sic.lockType.equals(SolrIndexConfig.LOCK_TYPE_SIMPLE));
- }
-
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Wed Dec 12 21:41:06 2012
@@ -27,7 +27,6 @@ import javax.xml.parsers.ParserConfigura
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;
@@ -43,19 +42,22 @@ public class TestCoreContainer extends S
public void testShareSchema() throws IOException, ParserConfigurationException, SAXException {
- final File workDir = new File(TEMP_DIR, this.getClass().getName());
+
+ final File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
+ + "_shareSchema");
- if (workDir.exists()) {
- FileUtils.deleteDirectory(workDir);
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
}
- assertTrue("Failed to mkdirs workDir", workDir.mkdirs());
+ assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
+
+ FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
- String solrHome = SolrResourceLoader.locateSolrHome();
- File fconf = new File(solrHome, "solr.xml");
+ File fconf = new File(solrHomeDirectory, "solr.xml");
- final CoreContainer cores = new CoreContainer(solrHome);
+ final CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
System.setProperty("shareSchema", "true");
- cores.load(solrHome, fconf);
+ cores.load(solrHomeDirectory.getAbsolutePath(), fconf);
try {
cores.setPersistent(false);
assertTrue(cores.isShareSchema());
@@ -72,6 +74,7 @@ public class TestCoreContainer extends S
core2.close();
} finally {
cores.shutdown();
+ System.clearProperty("shareSchema");
}
}
@@ -86,7 +89,7 @@ public class TestCoreContainer extends S
final CoreContainer cores = h.getCoreContainer();
cores.setPersistent(true); // is this needed since we make explicit calls?
-
+
String instDir = null;
{
SolrCore template = null;
@@ -105,12 +108,12 @@ public class TestCoreContainer extends S
final File oneXml = new File(workDir, "1.solr.xml");
cores.persistFile(oneXml);
-
+
assertXmlFile(oneXml, "/solr[@persistent='true']",
- "/solr/cores[@defaultCoreName='collection1']",
- "/solr/cores/core[@name='collection1' and @instanceDir='" + instDir
- + "']", "1=count(/solr/cores/core)");
-
+ "/solr/cores[@defaultCoreName='collection1' and not(@swappableCacheSize)]",
+ "/solr/cores/core[@name='collection1' and @instanceDir='" + instDir +
+ "' and @swappable='false' and @loadOnStartup='true' ]", "1=count(/solr/cores/core)");
+
// create some new cores and sanity check the persistence
final File dataXfile = new File(workDir, "dataX");
@@ -139,16 +142,18 @@ public class TestCoreContainer extends S
assertEquals("cores not added?", 3, cores.getCoreNames().size());
final File twoXml = new File(workDir, "2.solr.xml");
+ cores.swappableCacheSize = 32;
+
cores.persistFile(twoXml);
-
+
assertXmlFile(twoXml, "/solr[@persistent='true']",
- "/solr/cores[@defaultCoreName='collection1']",
+ "/solr/cores[@defaultCoreName='collection1' and @swappableCacheSize='32']",
"/solr/cores/core[@name='collection1' and @instanceDir='" + instDir
+ "']", "/solr/cores/core[@name='X' and @instanceDir='" + instDir
+ "' and @dataDir='" + dataX + "']",
"/solr/cores/core[@name='Y' and @instanceDir='" + instY + "']",
"3=count(/solr/cores/core)");
-
+
// delete a core, check persistence again
assertNotNull("removing X returned null", cores.remove("X"));
@@ -197,7 +202,7 @@ public class TestCoreContainer extends S
throw new RuntimeException("XPath is invalid", e2);
}
}
-
+
public void testNoCores() throws IOException, ParserConfigurationException, SAXException {
//create solrHome
File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
@@ -230,8 +235,9 @@ public class TestCoreContainer extends S
//assert cero cores
assertEquals("There should not be cores", 0, cores.getCores().size());
+ FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME(), "collection1"), solrHomeDirectory);
//add a new core
- CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", SolrTestCaseJ4.TEST_HOME() + "/collection1");
+ CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", solrHomeDirectory.getAbsolutePath());
SolrCore newCore = cores.create(coreDescriptor);
cores.register(newCore, false);
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestJmxIntegration.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestJmxIntegration.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestJmxIntegration.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestJmxIntegration.java Wed Dec 12 21:41:06 2012
@@ -20,6 +20,7 @@ import org.apache.solr.core.JmxMonitored
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -35,14 +36,10 @@ import java.util.*;
*/
public class TestJmxIntegration extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
@Override
Added: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1420992&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (added)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Wed Dec 12 21:41:06 2012
@@ -0,0 +1,299 @@
+package org.apache.solr.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.update.UpdateHandler;
+import org.apache.solr.util.RefCounted;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+
+public class TestLazyCores extends SolrTestCaseJ4 {
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
+ private final File _solrHomeDirectory = new File(TEMP_DIR, "org.apache.solr.core.TestLazyCores_testlazy");
+
+ private static String[] _necessaryConfs = {"schema.xml", "solrconfig.xml", "stopwords.txt", "synonyms.txt",
+ "protwords.txt", "old_synonyms.txt", "currency.xml", "open-exchange-rates.json", "mapping-ISOLatin1Accent.txt"};
+
+ private void copyConfFiles(File home, String subdir) throws IOException {
+
+ File subHome = new File(new File(home, subdir), "conf");
+ assertTrue("Failed to make subdirectory ", subHome.mkdirs());
+ String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
+ for (String file : _necessaryConfs) {
+ FileUtils.copyFile(new File(top, file), new File(subHome, file));
+ }
+ }
+
+ private CoreContainer init() throws Exception {
+
+ if (_solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(_solrHomeDirectory);
+ }
+ assertTrue("Failed to mkdirs workDir", _solrHomeDirectory.mkdirs());
+ for (int idx = 1; idx < 10; ++idx) {
+ copyConfFiles(_solrHomeDirectory, "collection" + idx);
+ }
+
+ File solrXml = new File(_solrHomeDirectory, "solr.xml");
+ FileUtils.write(solrXml, LOTS_SOLR_XML, IOUtils.CHARSET_UTF_8.toString());
+ final CoreContainer cores = new CoreContainer(_solrHomeDirectory.getAbsolutePath());
+ cores.load(_solrHomeDirectory.getAbsolutePath(), solrXml);
+ // h.getCoreContainer().load(_solrHomeDirectory.getAbsolutePath(), new File(_solrHomeDirectory, "solr.xml"));
+
+ cores.setPersistent(false);
+ return cores;
+ }
+
+ public void after() throws Exception {
+ if (_solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(_solrHomeDirectory);
+ }
+ }
+
+ @Test
+ public void testLazyLoad() throws Exception {
+ CoreContainer cc = init();
+ try {
+ // NOTE: the way this works, this should not assert, however if it's put after the getCore on this collection,
+ // that will cause the core to be loaded and this test will fail.
+
+ Collection<String> names = cc.getCoreNames();
+ for (String name : names) {
+ assertFalse("collectionLazy2".equals(name));
+ }
+
+ SolrCore core1 = cc.getCore("collection1");
+ assertFalse("core1 should not be swappable", core1.getCoreDescriptor().isSwappable());
+ assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());
+ assertNotNull(core1.getSolrConfig());
+
+ SolrCore core2 = cc.getCore("collectionLazy2");
+ assertTrue("core2 should not be swappable", core2.getCoreDescriptor().isSwappable());
+ assertFalse("core2 should not be loadable", core2.getCoreDescriptor().isLoadOnStartup());
+
+ SolrCore core3 = cc.getCore("collectionLazy3");
+ assertTrue("core3 should not be swappable", core3.getCoreDescriptor().isSwappable());
+ assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());
+
+ SolrCore core4 = cc.getCore("collectionLazy4");
+ assertFalse("core4 should not be swappable", core4.getCoreDescriptor().isSwappable());
+ assertFalse("core4 should not be loadable", core4.getCoreDescriptor().isLoadOnStartup());
+
+ SolrCore core5 = cc.getCore("collectionLazy5");
+ assertFalse("core5 should not be swappable", core5.getCoreDescriptor().isSwappable());
+ assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());
+
+ core1.close();
+ core2.close();
+ core3.close();
+ core4.close();
+ core5.close();
+ } finally {
+ cc.shutdown();
+ }
+ }
+
+ // This is a little weak. I'm not sure how to test that lazy core2 is loaded automagically. The getCore
+ // will, of course, load it.
+ @Test
+ public void testLazySearch() throws Exception {
+ CoreContainer cc = init();
+ try {
+ // Make sure Lazy2 isn't loaded.
+ checkNotInCores(cc, "collectionLazy2");
+ SolrCore core2 = cc.getCore("collectionLazy2");
+
+ addLazy(core2, "id", "0");
+ addLazy(core2, "id", "1", "v_t", "Hello Dude");
+ addLazy(core2, "id", "2", "v_t", "Hello Yonik");
+ addLazy(core2, "id", "3", "v_s", "{!literal}");
+ addLazy(core2, "id", "4", "v_s", "other stuff");
+ addLazy(core2, "id", "5", "v_f", "3.14159");
+ addLazy(core2, "id", "6", "v_f", "8983");
+
+ SolrQueryRequest req = makeReq(core2);
+ CommitUpdateCommand cmtCmd = new CommitUpdateCommand(req, false);
+ core2.getUpdateHandler().commit(cmtCmd);
+
+ RefCounted<SolrIndexSearcher> holder = core2.getSearcher();
+ SolrIndexSearcher searcher = holder.get();
+
+ // Just get a couple of searches to work!
+ assertQ("test prefix query",
+ makeReq(core2, "q", "{!prefix f=v_t}hel")
+ , "//result[@numFound='2']"
+ );
+
+ assertQ("test raw query",
+ makeReq(core2, "q", "{!raw f=v_t}hello")
+ , "//result[@numFound='2']"
+ );
+
+ // Now just insure that the normal searching on "collection1" finds _0_ on the same query that found _2_ above.
+ // Use of makeReq above and req below is tricky, very tricky.
+ assertQ("test raw query",
+ req("q", "{!raw f=v_t}hello")
+ , "//result[@numFound='0']"
+ );
+
+ // no analysis is done, so these should match nothing
+ assertQ("test raw query",
+ makeReq(core2, "q", "{!raw f=v_t}Hello")
+ , "//result[@numFound='0']"
+ );
+ assertQ("test raw query",
+ makeReq(core2, "q", "{!raw f=v_f}1.5")
+ , "//result[@numFound='0']"
+ );
+
+ checkInCores(cc, "collectionLazy2");
+
+ searcher.close();
+ core2.close();
+ } finally {
+ cc.shutdown();
+ }
+ }
+
+ @Test
+ public void testCachingLimit() throws Exception {
+ CoreContainer cc = init();
+ try {
+ // By putting these in non-alpha order, we're also checking that we're not just seeing an artifact.
+ SolrCore core1 = cc.getCore("collection1");
+ SolrCore core2 = cc.getCore("collectionLazy3");
+ SolrCore core4 = cc.getCore("collectionLazy4");
+ SolrCore core3 = cc.getCore("collectionLazy2");
+ SolrCore core5 = cc.getCore("collectionLazy5");
+
+
+ checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5");
+ checkNotInCores(cc, "collectionLazy6", "collectionLazy7", "collectionLazy8", "collectionLazy9");
+
+ // map should be full up, add one more and verify
+ SolrCore core6 = cc.getCore("collectionLazy6");
+ checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5", "collectionLazy6");
+ checkNotInCores(cc, "collectionLazy7", "collectionLazy8", "collectionLazy9");
+
+ SolrCore core7 = cc.getCore("collectionLazy7");
+ checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5", "collectionLazy6", "collectionLazy7");
+ checkNotInCores(cc, "collectionLazy8", "collectionLazy9");
+ SolrCore core8 = cc.getCore("collectionLazy8");
+ checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy4", "collectionLazy5", "collectionLazy6", "collectionLazy7", "collectionLazy8");
+ checkNotInCores(cc, "collectionLazy3", "collectionLazy9");
+
+ SolrCore core9 = cc.getCore("collectionLazy9");
+ checkInCores(cc, "collection1", "collectionLazy4", "collectionLazy5", "collectionLazy6", "collectionLazy7", "collectionLazy8", "collectionLazy9");
+ checkNotInCores(cc, "collectionLazy2", "collectionLazy3");
+
+
+ // Note decrementing the count when the core is removed from the lazyCores list is appropriate, since the
+ // refcount is 1 when constructed. anyone _else_ who's opened up one has to close it.
+ core1.close();
+ core2.close();
+ core3.close();
+ core4.close();
+ core5.close();
+ core6.close();
+ core7.close();
+ core8.close();
+ core9.close();
+ } finally {
+ cc.shutdown();
+ }
+ }
+
+ private void checkNotInCores(CoreContainer cc, String... nameCheck) {
+ Collection<String> names = cc.getCoreNames();
+ for (String name : nameCheck) {
+ assertFalse("core " + name + " was found in the list of cores", names.contains(name));
+ }
+ }
+
+ private void checkInCores(CoreContainer cc, String... nameCheck) {
+ Collection<String> names = cc.getCoreNames();
+ for (String name : nameCheck) {
+ assertTrue("core " + name + " was not found in the list of cores", names.contains(name));
+ }
+ }
+
+
+ private void addLazy(SolrCore core, String... fieldValues) throws IOException {
+ UpdateHandler updater = core.getUpdateHandler();
+ SolrQueryRequest req = makeReq(core);
+ AddUpdateCommand cmd = new AddUpdateCommand(req);
+ if ((fieldValues.length % 2) != 0) {
+ throw new RuntimeException("The length of the string array (query arguments) needs to be even");
+ }
+ cmd.solrDoc = new SolrInputDocument();
+ for (int idx = 0; idx < fieldValues.length; idx += 2) {
+ cmd.solrDoc.addField(fieldValues[idx], fieldValues[idx + 1]);
+ }
+
+ updater.addDoc(cmd);
+ }
+
+ private LocalSolrQueryRequest makeReq(SolrCore core, String... q) {
+ if (q.length == 1) {
+ return new LocalSolrQueryRequest(core,
+ q[0], null, 0, 20, new HashMap<String, String>());
+ }
+ if (q.length % 2 != 0) {
+ throw new RuntimeException("The length of the string array (query arguments) needs to be even");
+ }
+ NamedList.NamedListEntry[] entries = new NamedList.NamedListEntry[q.length / 2];
+ for (int i = 0; i < q.length; i += 2) {
+ entries[i / 2] = new NamedList.NamedListEntry<String>(q[i], q[i + 1]);
+ }
+ return new LocalSolrQueryRequest(core, new NamedList<Object>(entries));
+ }
+
+ private final static String LOTS_SOLR_XML = " <solr persistent=\"false\"> " +
+ "<cores adminPath=\"/admin/cores\" defaultCoreName=\"collectionLazy2\" swappableCacheSize=\"4\"> " +
+ "<core name=\"collection1\" instanceDir=\"collection1\" /> " +
+ "<core name=\"collectionLazy2\" instanceDir=\"collection2\" swappable=\"true\" loadOnStartup=\"false\" /> " +
+ "<core name=\"collectionLazy3\" instanceDir=\"collection3\" swappable=\"on\" loadOnStartup=\"false\"/> " +
+ "<core name=\"collectionLazy4\" instanceDir=\"collection4\" swappable=\"false\" loadOnStartup=\"false\"/> " +
+ "<core name=\"collectionLazy5\" instanceDir=\"collection5\" swappable=\"false\" loadOnStartup=\"true\"/> " +
+ "<core name=\"collectionLazy6\" instanceDir=\"collection6\" swappable=\"true\" loadOnStartup=\"false\" /> " +
+ "<core name=\"collectionLazy7\" instanceDir=\"collection7\" swappable=\"true\" loadOnStartup=\"false\" /> " +
+ "<core name=\"collectionLazy8\" instanceDir=\"collection8\" swappable=\"true\" loadOnStartup=\"false\" /> " +
+ "<core name=\"collectionLazy9\" instanceDir=\"collection9\" swappable=\"true\" loadOnStartup=\"false\" /> " +
+ "</cores> " +
+ "</solr>";
+}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestPropInject.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestPropInject.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestPropInject.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestPropInject.java Wed Dec 12 21:41:06 2012
@@ -17,24 +17,19 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import java.io.IOException;
-
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.RefCounted;
+import org.junit.BeforeClass;
public class TestPropInject extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
- @Override
- public String getSolrConfigFile() {
- return "solrconfig-propinject.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-propinject.xml", "schema.xml");
}
public void testMergePolicy() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java Wed Dec 12 21:41:06 2012
@@ -17,26 +17,19 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import org.apache.solr.update.processor.UpdateRequestProcessorChain;
-import org.apache.solr.update.processor.RegexReplaceProcessorFactory;
-
-import org.apache.solr.util.AbstractSolrTestCase;
-
import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.solr.update.processor.RegexReplaceProcessorFactory;
+import org.apache.solr.update.processor.UpdateRequestProcessorChain;
+import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Assume;
+import org.junit.BeforeClass;
public class TestXIncludeConfig extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema-xinclude.xml";
- }
-
- //public String getSolrConfigFile() { return "solrconfig.xml"; }
- @Override
- public String getSolrConfigFile() {
- return "solrconfig-xinclude.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-xinclude.xml", "schema-xinclude.xml");
}
@Override
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java Wed Dec 12 21:41:06 2012
@@ -27,15 +27,19 @@ import org.apache.solr.request.LocalSolr
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.QueryParsing;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
* Most of the tests for StandardRequestHandler are in ConvertedLegacyTest
*
*/
public class StandardRequestHandlerTest extends AbstractSolrTestCase {
-
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
@Override public void setUp() throws Exception {
super.setUp();
lrf = h.getRequestFactory("standard", 0, 20 );
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Wed Dec 12 21:41:06 2012
@@ -54,8 +54,8 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.util.AbstractSolrTestCase;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
/**
* Test for ReplicationHandler
@@ -72,9 +72,9 @@ public class TestReplicationHandler exte
+ File.separator + "collection1" + File.separator + "conf"
+ File.separator;
- static JettySolrRunner masterJetty, slaveJetty;
- static SolrServer masterClient, slaveClient;
- static SolrInstance master = null, slave = null;
+ JettySolrRunner masterJetty, slaveJetty;
+ SolrServer masterClient, slaveClient;
+ SolrInstance master = null, slave = null;
static String context = "/solr";
@@ -83,9 +83,11 @@ public class TestReplicationHandler exte
static int nDocs = 500;
- @BeforeClass
- public static void beforeClass() throws Exception {
- useFactory(null); // need an FS factory
+ @Before
+ public void setup() throws Exception {
+ super.setUp();
+ // For manual testing only
+ // useFactory(null); // force an FS factory
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@@ -109,8 +111,10 @@ public class TestReplicationHandler exte
}
}
- @AfterClass
- public static void afterClass() throws Exception {
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
masterJetty.stop();
slaveJetty.stop();
master.tearDown();
@@ -415,7 +419,7 @@ public class TestReplicationHandler exte
// setup an xslt dir to force subdir file replication
File masterXsltDir = new File(master.getConfDir() + File.separator + "xslt");
File masterXsl = new File(masterXsltDir, "dummy.xsl");
- assertTrue(masterXsltDir.mkdir());
+ assertTrue("could not make dir " + masterXsltDir, masterXsltDir.mkdirs());
assertTrue(masterXsl.createNewFile());
File slaveXsltDir = new File(slave.getConfDir() + File.separator + "xslt");
@@ -596,14 +600,10 @@ public class TestReplicationHandler exte
nDocs--;
masterClient.deleteByQuery("*:*");
- for (int i = 0; i < nDocs; i++)
- index(masterClient, "id", i, "name", "name = " + i);
masterClient.commit();
- NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
- SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
- assertEquals(nDocs, masterQueryResult.getNumFound());
+
//change solrconfig having 'replicateAfter startup' option on master
master.copyConfigFile(CONF_DIR + "solrconfig-master2.xml",
@@ -613,6 +613,16 @@ public class TestReplicationHandler exte
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
+
+ for (int i = 0; i < nDocs; i++)
+ index(masterClient, "id", i, "name", "name = " + i);
+
+ masterClient.commit();
+
+ NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
+ SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
+ assertEquals(nDocs, masterQueryResult.getNumFound());
+
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
@@ -647,18 +657,11 @@ public class TestReplicationHandler exte
}
private void doTestReplicateAfterCoreReload() throws Exception {
+ int docs = TEST_NIGHTLY ? 200000 : 0;
+
//stop slave
slaveJetty.stop();
- masterClient.deleteByQuery("*:*");
- for (int i = 0; i < 10; i++)
- index(masterClient, "id", i, "name", "name = " + i);
-
- masterClient.commit();
-
- NamedList masterQueryRsp = rQuery(10, "*:*", masterClient);
- SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
- assertEquals(10, masterQueryResult.getNumFound());
//change solrconfig having 'replicateAfter startup' option on master
master.copyConfigFile(CONF_DIR + "solrconfig-master3.xml",
@@ -669,6 +672,16 @@ public class TestReplicationHandler exte
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
+ masterClient.deleteByQuery("*:*");
+ for (int i = 0; i < docs; i++)
+ index(masterClient, "id", i, "name", "name = " + i);
+
+ masterClient.commit();
+
+ NamedList masterQueryRsp = rQuery(docs, "*:*", masterClient);
+ SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
+ assertEquals(docs, masterQueryResult.getNumFound());
+
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
@@ -677,9 +690,9 @@ public class TestReplicationHandler exte
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = rQuery(10, "*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(docs, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- assertEquals(10, slaveQueryResult.getNumFound());
+ assertEquals(docs, slaveQueryResult.getNumFound());
//compare results
String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult, slaveQueryResult, 0, null);
@@ -693,19 +706,19 @@ public class TestReplicationHandler exte
assertEquals(version, getIndexVersion(masterClient).get("indexversion"));
assertEquals(commits.get("commits"), getCommits(masterClient).get("commits"));
- index(masterClient, "id", 110, "name", "name = 1");
- index(masterClient, "id", 120, "name", "name = 2");
+ index(masterClient, "id", docs + 10, "name", "name = 1");
+ index(masterClient, "id", docs + 20, "name", "name = 2");
masterClient.commit();
- NamedList resp = rQuery(12, "*:*", masterClient);
+ NamedList resp = rQuery(docs + 2, "*:*", masterClient);
masterQueryResult = (SolrDocumentList) resp.get("response");
- assertEquals(12, masterQueryResult.getNumFound());
+ assertEquals(docs + 2, masterQueryResult.getNumFound());
//get docs from slave and check if number is equal to master
- slaveQueryRsp = rQuery(12, "*:*", slaveClient);
+ slaveQueryRsp = rQuery(docs + 2, "*:*", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- assertEquals(12, slaveQueryResult.getNumFound());
+ assertEquals(docs + 2, slaveQueryResult.getNumFound());
// NOTE: revert config on master.
master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml");
@@ -923,6 +936,7 @@ public class TestReplicationHandler exte
File[] files = dataDir.listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
if(name.startsWith("snapshot")) {
return true;
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java Wed Dec 12 21:41:06 2012
@@ -111,10 +111,10 @@ public class CoreAdminHandlerTest extend
fail("bogus collection created ok");
} catch (SolrException e) {
// :NOOP:
- // :TODO: CoreAdminHandler's exception messages are terrible, otherwise we could asert something useful here
+ // :TODO: CoreAdminHandler's exception messages are terrible, otherwise we could assert something useful here
}
- // check specificly for status of the failed core name
+ // check specifically for status of the failed core name
resp = new SolrQueryResponse();
admin.handleRequestBody
(req(CoreAdminParams.ACTION,
@@ -132,8 +132,8 @@ public class CoreAdminHandlerTest extend
assertEquals("wrong number of core failures", 1, failures.size());
Exception fail = failures.get("bogus_dir_core");
assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("dir_does_not_exist"));
+ assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+ 0 < fail.getCause().getMessage().indexOf("dir_does_not_exist"));
assertEquals("bogus_dir_core status isn't empty",
0, ((NamedList)status.get("bogus_dir_core")).size());
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java Wed Dec 12 21:41:06 2012
@@ -17,28 +17,24 @@
package org.apache.solr.handler.admin;
+import java.util.Arrays;
+import java.util.EnumSet;
+
import org.apache.solr.common.luke.FieldFlag;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.EnumSet;
-import java.util.Arrays;
-
/**
* :TODO: currently only tests some of the utilities in the LukeRequestHandler
*/
public class LukeRequestHandlerTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
@Before
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java Wed Dec 12 21:41:06 2012
@@ -16,25 +16,23 @@ package org.apache.solr.handler.componen
* limitations under the License.
*/
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.HashMap;
import java.util.TimeZone;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.StatsParams;
-
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.schema.SchemaField;
-
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.schema.SchemaField;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
@@ -42,19 +40,15 @@ import org.apache.solr.util.AbstractSolr
*/
public class StatsComponentTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema11.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
}
@Override
public void setUp() throws Exception {
super.setUp();
+ clearIndex();
lrf = h.getRequestFactory("standard", 0, 20);
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java Wed Dec 12 21:41:06 2012
@@ -16,16 +16,19 @@
*/
package org.apache.solr.highlight;
+import java.util.HashMap;
+
import org.apache.solr.handler.component.HighlightComponent;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness;
-
-import java.util.HashMap;
+import org.junit.BeforeClass;
public class HighlighterConfigTest extends AbstractSolrTestCase {
- @Override public String getSchemaFile() { return "schema.xml"; }
- // the default case (i.e. <highlight> without a class attribute) is tested every time sorlconfig.xml is used
- @Override public String getSolrConfigFile() { return "solrconfig-highlight.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-highlight.xml", "schema.xml");
+ }
@Override
public void setUp() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java Wed Dec 12 21:41:06 2012
@@ -16,22 +16,22 @@
*/
package org.apache.solr.request;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Locale;
+import java.util.UUID;
+
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.JavaBinCodec;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.response.BinaryQueryResponseWriter;
import org.apache.solr.response.BinaryResponseWriter.Resolver;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.ReturnFields;
-
import org.apache.solr.util.AbstractSolrTestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Locale;
-import java.util.UUID;
+import org.junit.BeforeClass;
/**
* Test for BinaryResponseWriter
@@ -41,14 +41,10 @@ import java.util.UUID;
*/
public class TestBinaryResponseWriter extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
/**
@@ -96,7 +92,7 @@ public class TestBinaryResponseWriter ex
assertTrue("ddd_s not found", out.getFieldNames().contains("ddd_s"));
assertEquals("Wrong number of fields found",
2, out.getFieldNames().size());
-
+ req.close();
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java Wed Dec 12 21:41:06 2012
@@ -17,30 +17,34 @@
package org.apache.solr.request;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import org.apache.solr.client.solrj.ResponseParser;
+import org.apache.solr.client.solrj.impl.BinaryResponseParser;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.response.BinaryQueryResponseWriter;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.client.solrj.impl.BinaryResponseParser;
-import org.apache.solr.client.solrj.impl.XMLResponseParser;
-
+import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.io.*;
-
public class TestWriterPerf extends AbstractSolrTestCase {
public static final Logger log
= LoggerFactory.getLogger(TestWriterPerf.class);
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig-functionquery.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-functionquery.xml", "schema11.xml");
+ }
+
public String getCoreName() { return "basic"; }
@Override
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Wed Dec 12 21:41:06 2012
@@ -19,13 +19,16 @@ package org.apache.solr.search;
import org.apache.solr.common.SolrException;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
import org.junit.Test;
public class TestExtendedDismaxParser extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema12.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
+ }
+
// public String getCoreName() { return "collection1"; }
@Override
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java Wed Dec 12 21:41:06 2012
@@ -18,13 +18,15 @@ package org.apache.solr.search;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class TestQueryTypes extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+
public String getCoreName() { return "basic"; }
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java Wed Dec 12 21:41:06 2012
@@ -22,7 +22,9 @@ import org.apache.lucene.search.BooleanQ
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.Query;
import org.apache.lucene.index.Term;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
import java.util.List;
@@ -31,10 +33,11 @@ import java.util.List;
*/
public class TestQueryUtils extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
@Override
public void setUp() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java Wed Dec 12 21:41:06 2012
@@ -19,6 +19,7 @@ package org.apache.solr.search;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.*;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -26,6 +27,7 @@ import org.apache.solr.update.processor.
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.common.SolrInputDocument;
+import org.junit.BeforeClass;
import java.util.*;
import java.io.IOException;
@@ -35,10 +37,12 @@ import java.io.IOException;
*/
public class TestSearchPerf extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+
@Override
public void setUp() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java Wed Dec 12 21:41:06 2012
@@ -19,13 +19,14 @@ package org.apache.solr.search;
*/
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class TestSurroundQueryParser extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schemasurround.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schemasurround.xml");
+ }
// public String getCoreName() { return "collection1"; }
@Override
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java Wed Dec 12 21:41:06 2012
@@ -17,6 +17,7 @@ package org.apache.solr.search.function;
*/
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
@@ -24,14 +25,18 @@ import org.apache.solr.util.AbstractSolr
*
**/
public class SortByFunctionTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
+
@Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ public void setUp() throws Exception {
+ super.setUp();
+
}
public void test() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java Wed Dec 12 21:41:06 2012
@@ -427,10 +427,7 @@ public class TestFunctionQuery extends S
/**
* test collection-level term stats (new in 4.x indexes)
*/
- public void testTotalTermFreq() throws Exception {
- assumeFalse("PreFlex codec does not support collection-level term stats",
- "Lucene3x".equals(Codec.getDefault().getName()));
-
+ public void testTotalTermFreq() throws Exception {
clearIndex();
assertU(adoc("id","1", "a_tdt","2009-08-31T12:10:10.123Z", "b_tdt","2009-08-31T12:10:10.124Z"));
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java Wed Dec 12 21:41:06 2012
@@ -19,15 +19,19 @@ package org.apache.solr.servlet;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class DirectSolrConnectionTest extends AbstractSolrTestCase
{
- @Override
- public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solr/crazy-path-to-config.xml", "solr/crazy-path-to-schema.xml");
+ }
+
DirectSolrConnection direct;
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java Wed Dec 12 21:41:06 2012
@@ -34,6 +34,7 @@ import org.apache.solr.response.SolrQuer
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.RefCounted;
+import org.junit.BeforeClass;
class NewSearcherListener implements SolrEventListener {
@@ -108,10 +109,10 @@ class NewSearcherListener implements Sol
@Slow
public class AutoCommitTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
public static void verbose(Object... args) {
if (!VERBOSE) return;
@@ -125,6 +126,14 @@ public class AutoCommitTest extends Abst
log.info(sb.toString());
// System.out.println(sb.toString());
}
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
+ // reload the core to clear stats
+ h.getCoreContainer().reload(h.getCore().getName());
+ }
/**
* Take a string and make it an iterable ContentStream
@@ -141,8 +150,8 @@ public class AutoCommitTest extends Abst
}
public void testMaxDocs() throws Exception {
-
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
DirectUpdateHandler2 updateHandler = (DirectUpdateHandler2)core.getUpdateHandler();
@@ -190,6 +199,7 @@ public class AutoCommitTest extends Abst
public void testMaxTime() throws Exception {
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
core.registerNewSearcherListener(trigger);
DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
@@ -263,6 +273,7 @@ public class AutoCommitTest extends Abst
public void testCommitWithin() throws Exception {
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
core.registerNewSearcherListener(trigger);
DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java Wed Dec 12 21:41:06 2012
@@ -16,15 +16,15 @@ package org.apache.solr.update;
* limitations under the License.
*/
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import java.io.File;
+import java.io.FileFilter;
+
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
-
-import java.io.File;
-import java.io.FileFilter;
+import org.junit.BeforeClass;
/**
@@ -33,15 +33,9 @@ import java.io.FileFilter;
**/
public class DirectUpdateHandlerOptimizeTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- // return "solrconfig-duh-optimize.xml";
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java Wed Dec 12 21:41:06 2012
@@ -40,7 +40,6 @@ import org.junit.Test;
*/
public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
- // TODO: fix this test to not require FSDirectory
static String savedFactory;
@BeforeClass
public static void beforeClass() throws Exception {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java Wed Dec 12 21:41:06 2012
@@ -32,6 +32,7 @@ import org.apache.solr.core.SolrEventLis
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
+import org.junit.BeforeClass;
/**
* Test auto commit functionality in a way that doesn't suck.
@@ -55,10 +56,11 @@ import org.junit.Before;
@Slow
public class SoftAutoCommitTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
private MockEventListener monitor;
private DirectUpdateHandler2 updater;
@@ -77,6 +79,13 @@ public class SoftAutoCommitTest extends
updater.registerSoftCommitCallback(monitor);
updater.registerCommitCallback(monitor);
}
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // reset stats
+ h.getCoreContainer().reload("collection1");
+ }
public void testSoftAndHardCommitMaxTimeMixedAdds() throws Exception {
@@ -179,7 +188,7 @@ public class SoftAutoCommitTest extends
}
public void testSoftAndHardCommitMaxTimeDelete() throws Exception {
-
+
final int softCommitWaitMillis = 500;
final int hardCommitWaitMillis = 1200;
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java Wed Dec 12 21:41:06 2012
@@ -17,6 +17,7 @@
package org.apache.solr.update;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
@@ -41,9 +42,11 @@ public class TestIndexingPerformance ext
// TODO: fix this test to not require FSDirectory
static String savedFactory;
@BeforeClass
- public static void beforeClass() {
+ public static void beforeClass() throws Exception {
savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
+
+ initCore("solrconfig_perf.xml", "schema12.xml");
}
@AfterClass
public static void afterClass() {
@@ -56,11 +59,7 @@ public class TestIndexingPerformance ext
public static final Logger log
= LoggerFactory.getLogger(TestIndexingPerformance.class);
-
- @Override
- public String getSchemaFile() { return "schema12.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig_perf.xml"; }
+
public void testIndexingPerf() throws IOException {
int iter=1000;
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java Wed Dec 12 21:41:06 2012
@@ -21,21 +21,22 @@ import java.util.HashMap;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.UpdateParams;
-import org.apache.solr.core.*;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.UpdateRequestHandler;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class UpdateParamsTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
/**
* Tests that only update.chain and not update.processor works (SOLR-2105)
*/
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java Wed Dec 12 21:41:06 2012
@@ -17,23 +17,24 @@
package org.apache.solr.update.processor;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.update.processor.UpdateRequestProcessorChain;
-import org.apache.solr.update.processor.CustomUpdateRequestProcessor;
-import org.apache.solr.util.AbstractSolrTestCase;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
import java.util.Arrays;
-import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
*
*/
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
-
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return "solrconfig-transformers.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-transformers.xml", "schema.xml");
+ }
public void testConfiguration() throws Exception
Modified: lucene/dev/branches/branch_4x/solr/example/contexts/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/contexts/solr.xml?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/contexts/solr.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/contexts/solr.xml Wed Dec 12 21:41:06 2012
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
- <Set name="contextPath">/solr</Set>
+ <Set name="contextPath"><SystemProperty name="hostContext" default="/solr"/></Set>
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
<Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
-</Configure>
\ No newline at end of file
+</Configure>
Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml Wed Dec 12 21:41:06 2012
@@ -637,7 +637,7 @@
such as /select?qt=XXX
handleSelect="true" will cause the SolrDispatchFilter to process
- the request and dispatch the query to a handler specified by the
+ the request and dispatch the query to a handler specified by the
"qt" param, assuming "/select" isn't already registered.
handleSelect="false" will cause the SolrDispatchFilter to
@@ -738,7 +738,7 @@
like so: http://host/app/[core/]select?qt=name If no qt is
given, then the requestHandler that declares default="true" will be
used or the one named "standard".
-
+
If a Request Handler is declared with startup="lazy", then it will
not be initialized until the first request that uses it.
Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/velocity/product-doc.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/velocity/product-doc.vm?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/velocity/product-doc.vm (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/velocity/product-doc.vm Wed Dec 12 21:41:06 2012
@@ -24,4 +24,4 @@
<div>No Similar Items Found</div>
#end
</div>
-#parse('debug.vm')
+#parse('debug.vm')
\ No newline at end of file
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java Wed Dec 12 21:41:06 2012
@@ -20,6 +20,7 @@ package org.apache.solr.client.solrj.imp
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -195,9 +196,8 @@ public class CloudSolrServer extends Sol
// Retrieve slices from the cloud state and, for each collection specified,
// add it to the Map of slices.
Map<String,Slice> slices = new HashMap<String,Slice>();
- for (int i = 0; i < collectionList.size(); i++) {
- String coll= collectionList.get(i);
- ClientUtils.appendMap(coll, slices, clusterState.getSlices(coll));
+ for (String collectionName : collectionList) {
+ ClientUtils.addSlices(slices, collectionName, clusterState.getSlices(collectionName), true);
}
Set<String> liveNodes = clusterState.getLiveNodes();
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java Wed Dec 12 21:41:06 2012
@@ -17,21 +17,21 @@
package org.apache.solr.client.solrj.request;
-import java.io.IOException;
-import java.util.Collection;
-
+import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.response.SolrPingResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStream;
+import java.io.IOException;
+import java.util.Collection;
+
/**
* Verify that there is a working Solr core at the URL of a {@link SolrServer}.
* To use this class, the solrconfig.xml for the relevant core must include the
* request handler for <code>/admin/ping</code>.
- *
+ *
* @since solr 1.3
*/
public class SolrPing extends SolrRequest
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java?rev=1420992&r1=1420991&r2=1420992&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java Wed Dec 12 21:41:06 2012
@@ -242,15 +242,13 @@ public class ClientUtils
catch (IOException e) {throw new RuntimeException(e);} // can't happen
return sb.toString();
}
-
- public static void appendMap(String collection, Map<String,Slice> map1, Map<String,Slice> map2) {
- if (map1==null)
- map1 = new HashMap<String,Slice>();
- if (map2!=null) {
- Set<Entry<String,Slice>> entrySet = map2.entrySet();
- for (Entry<String,Slice> entry : entrySet) {
- map1.put(collection + "_" + entry.getKey(), entry.getValue());
- }
+
+ /** Constructs a slices map from a collection of slices and handles disambiguation if multiple collections are being queried simultaneously */
+ public static void addSlices(Map<String,Slice> target, String collectionName, Collection<Slice> slices, boolean multiCollection) {
+ for (Slice slice : slices) {
+ String key = slice.getName();
+ if (multiCollection) key = collectionName + "_" + key;
+ target.put(key, slice);
}
}
}