You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cm...@apache.org on 2013/08/11 14:19:39 UTC

svn commit: r1512909 [33/38] - in /lucene/dev/branches/lucene4956: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/suggest/ dev-tools/idea/solr/contrib/dataimporthandler/ dev-tools/idea/solr/core/src/test/ dev-too...

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Sun Aug 11 12:19:13 2013
@@ -32,6 +32,7 @@ import org.apache.solr.update.AddUpdateC
 import org.apache.solr.update.CommitUpdateCommand;
 import org.apache.solr.update.UpdateHandler;
 import org.apache.solr.util.RefCounted;
+import org.apache.solr.util.TestHarness;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -52,7 +53,6 @@ public class TestLazyCores extends SolrT
 
   private final File solrHomeDirectory = new File(TEMP_DIR, "org.apache.solr.core.TestLazyCores_testlazy");
 
-
   private CoreContainer init() throws Exception {
 
     if (solrHomeDirectory.exists()) {
@@ -63,13 +63,17 @@ public class TestLazyCores extends SolrT
       copyMinConf(new File(solrHomeDirectory, "collection" + idx));
     }
 
+    SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
+
     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"));
+    ConfigSolrXmlOld config = (ConfigSolrXmlOld) ConfigSolr.fromFile(loader, solrXml);
+
+    CoresLocator locator = new SolrXMLCoresLocator.NonPersistingLocator(solrXml, LOTS_SOLR_XML, config);
 
-    cores.setPersistent(false);
+
+    final CoreContainer cores = new CoreContainer(loader, config, locator);
+    cores.load();
     return cores;
   }
 
@@ -91,15 +95,15 @@ public class TestLazyCores extends SolrT
 
       SolrCore core1 = cc.getCore("collection1");
       assertFalse("core1 should not be transient", core1.getCoreDescriptor().isTransient());
-      assertTrue("core1 should  be loadable", core1.getCoreDescriptor().isLoadOnStartup());
+      assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());
       assertNotNull(core1.getSolrConfig());
 
       SolrCore core2 = cc.getCore("collectionLazy2");
-      assertTrue("core2 should not be transient", core2.getCoreDescriptor().isTransient());
+      assertTrue("core2 should be transient", core2.getCoreDescriptor().isTransient());
       assertTrue("core2 should be loadable", core2.getCoreDescriptor().isLoadOnStartup());
 
       SolrCore core3 = cc.getCore("collectionLazy3");
-      assertTrue("core3 should not be transient", core3.getCoreDescriptor().isTransient());
+      assertTrue("core3 should be transient", core3.getCoreDescriptor().isTransient());
       assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());
 
       SolrCore core4 = cc.getCore("collectionLazy4");
@@ -108,7 +112,7 @@ public class TestLazyCores extends SolrT
 
       SolrCore core5 = cc.getCore("collectionLazy5");
       assertFalse("core5 should not be transient", core5.getCoreDescriptor().isTransient());
-      assertTrue("core5 should  be loadable", core5.getCoreDescriptor().isLoadOnStartup());
+      assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());
 
       core1.close();
       core2.close();
@@ -285,17 +289,17 @@ public class TestLazyCores extends SolrT
           CoreAdminParams.CoreAdminAction.CREATE.toString(),
           CoreAdminParams.DATA_DIR, dataDir,
           CoreAdminParams.NAME, name,
-          "schema", "schema-tiny.xml",
-          "config", "solrconfig-minimal.xml");
+          "schema", "schema.xml",
+          "config", "solrconfig.xml");
 
       admin.handleRequestBody(request, resp);
       fail("Should have thrown an error");
     } catch (SolrException se) {
-      SolrException cause = (SolrException)se.getCause();
-      assertEquals("Exception code should be 500", 500, cause.code());
+      //SolrException cause = (SolrException)se.getCause();
+      assertEquals("Exception code should be 500", 500, se.code());
       for (String err : errs) {
        assertTrue("Should have seen an exception containing the an error",
-            cause.getMessage().contains(err));
+            se.getMessage().contains(err));
       }
     }
   }
@@ -343,39 +347,25 @@ public class TestLazyCores extends SolrT
       copyMinConf(new File(solrHomeDirectory, "core3"));
       copyMinConf(new File(solrHomeDirectory, "core4"));
 
-      cc.setPersistent(true);
-      CoreDescriptor d1 = new CoreDescriptor(cc, "core1", "./core1");
-      d1.setTransient(true);
-      d1.setLoadOnStartup(true);
-      d1.setSchemaName("schema-tiny.xml");
-      d1.setConfigName("solrconfig-minimal.xml");
-      SolrCore core1 = cc.create(d1);
-
-      CoreDescriptor d2 = new CoreDescriptor(cc, "core2", "./core2");
-      d2.setTransient(true);
-      d2.setLoadOnStartup(false);
-      d2.setSchemaName("schema-tiny.xml");
-      d2.setConfigName("solrconfig-minimal.xml");
-      SolrCore core2 = cc.create(d2);
-
-      CoreDescriptor d3 = new CoreDescriptor(cc, "core3", "./core3");
-      d3.setTransient(false);
-      d3.setLoadOnStartup(true);
-      d3.setSchemaName("schema-tiny.xml");
-      d3.setConfigName("solrconfig-minimal.xml");
-      SolrCore core3 = cc.create(d3);
-
-      CoreDescriptor d4 = new CoreDescriptor(cc, "core4", "./core4");
-      d4.setTransient(false);
-      d4.setLoadOnStartup(false);
-      d4.setSchemaName("schema-tiny.xml");
-      d4.setConfigName("solrconfig-minimal.xml");
-      SolrCore core4 = cc.create(d4);
+      final CoreDescriptor cd1 = buildCoreDescriptor(cc, "core1", "./core1")
+          .isTransient(true).loadOnStartup(true).build();
+      final CoreDescriptor cd2 = buildCoreDescriptor(cc, "core2", "./core2")
+          .isTransient(true).loadOnStartup(false).build();
+      final CoreDescriptor cd3 = buildCoreDescriptor(cc, "core3", "./core3")
+          .isTransient(false).loadOnStartup(true).build();
+      final CoreDescriptor cd4 = buildCoreDescriptor(cc, "core4", "./core4")
+          .isTransient(false).loadOnStartup(false).build();
+
+
+      SolrCore core1 = cc.create(cd1);
+      SolrCore core2 = cc.create(cd2);
+      SolrCore core3 = cc.create(cd3);
+      SolrCore core4 = cc.create(cd4);
 
-      final File oneXml = new File(solrHomeDirectory, "lazy1.solr.xml");
-      cc.persistFile(oneXml);
+      SolrXMLCoresLocator.NonPersistingLocator locator =
+          (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();
 
-      assertXmlFile(oneXml,
+      TestHarness.validateXPath(locator.xml,
           "/solr/cores/core[@name='collection1']",
           "/solr/cores/core[@name='collectionLazy2']",
           "/solr/cores/core[@name='collectionLazy3']",
@@ -388,8 +378,8 @@ public class TestLazyCores extends SolrT
           "/solr/cores/core[@name='core1']",
           "/solr/cores/core[@name='core2']",
           "/solr/cores/core[@name='core3']",
-          "/solr/cores/core[@name='core4']");
-      assertXmlFile(oneXml, "13=count(/solr/cores/core)");
+          "/solr/cores/core[@name='core4']",
+          "13=count(/solr/cores/core)");
 
       removeOne(cc, "collectionLazy2");
       removeOne(cc, "collectionLazy3");
@@ -403,11 +393,8 @@ public class TestLazyCores extends SolrT
       removeOne(cc, "core4");
 
       // now test that unloading a core means the core is not persisted
+      TestHarness.validateXPath(locator.xml, "3=count(/solr/cores/core)");
 
-      final File twoXml = new File(solrHomeDirectory, "lazy2.solr.xml");
-      cc.persistFile(twoXml);
-
-      assertXmlFile(twoXml, "3=count(/solr/cores/core)");
     } finally {
       cc.shutdown();
     }
@@ -455,31 +442,23 @@ public class TestLazyCores extends SolrT
 
   private final static String LOTS_SOLR_XML = " <solr persistent=\"false\"> " +
       "<cores adminPath=\"/admin/cores\" defaultCoreName=\"collectionLazy2\" transientCacheSize=\"4\">  " +
-      "<core name=\"collection1\" instanceDir=\"collection1\" config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+      "<core name=\"collection1\" instanceDir=\"collection1\"  /> " +
 
-      "<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\"  " +
-      " config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+      "<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\"   /> " +
 
-      "<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\"    /> " +
 
-      "<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" /> " +
 
-      "<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" /> " +
 
-      "<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" /> " +
 
-      "<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" /> " +
 
-      "<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" /> " +
 
-      "<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" " +
-      "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\"  /> " +
+      "<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" /> " +
 
       "</cores> " +
       "</solr>";

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java Sun Aug 11 12:19:13 2013
@@ -17,37 +17,177 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
+import org.apache.solr.update.SolrIndexConfigTest;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.SegmentReader;
+import org.apache.lucene.index.SegmentInfo;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.MergePolicy;
 import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.RefCounted;
+import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.SolrTestCaseJ4;
-import org.junit.BeforeClass;
+import org.junit.After;
+import java.util.concurrent.atomic.AtomicInteger;
 
+/** @see SolrIndexConfigTest */
 public class TestMergePolicyConfig extends SolrTestCaseJ4 {
+  
+  private static AtomicInteger docIdCounter = new AtomicInteger(42);
+
+  @After
+  public void after() throws Exception {
+    deleteCore();
+  }
+
+  public void testDefaultMergePolicyConfig() throws Exception {
+    initCore("solrconfig-mergepolicy-defaults.xml","schema-minimal.xml");
+    IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+    assertEquals(false, iwc.getUseCompoundFile());
+
+    TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+                                               iwc.getMergePolicy());
+    assertEquals(0.0D, tieredMP.getNoCFSRatio(), 0.0D);
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    initCore("solrconfig-mergepolicy.xml","schema.xml");
+    assertCommitSomeNewDocs();
+    assertCompoundSegments(h.getCore(), false);
+  }
+
+  public void testLegacyMergePolicyConfig() throws Exception {
+    final boolean expectCFS 
+      = Boolean.parseBoolean(System.getProperty("useCompoundFile"));
+
+    initCore("solrconfig-mergepolicy-legacy.xml","schema-minimal.xml");
+    IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+    assertEquals(expectCFS, iwc.getUseCompoundFile());
+
+
+    TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+                                               iwc.getMergePolicy());
+
+    assertEquals(7, tieredMP.getMaxMergeAtOnce());
+    assertEquals(7.0D, tieredMP.getSegmentsPerTier(), 0.0D);
+    assertEquals(expectCFS ? 1.0D : 0.0D, tieredMP.getNoCFSRatio(), 0.0D);
+
+    assertCommitSomeNewDocs();
+    assertCompoundSegments(h.getCore(), expectCFS);
   }
   
   public void testTieredMergePolicyConfig() throws Exception {
+    final boolean expectCFS 
+      = Boolean.parseBoolean(System.getProperty("useCompoundFile"));
+
+    initCore("solrconfig-mergepolicy.xml","schema-minimal.xml");
     IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
-    MergePolicy mp = iwc.getMergePolicy();
-    assertTrue(mp instanceof TieredMergePolicy);
-    TieredMergePolicy tieredMP = (TieredMergePolicy) mp;
+    assertEquals(expectCFS, iwc.getUseCompoundFile());
 
-    // mp-specific setter
-    assertEquals(19, tieredMP.getMaxMergeAtOnceExplicit());
-    
-    // make sure we apply compoundFile and mergeFactor
-    assertEquals(false, tieredMP.getUseCompoundFile());
+
+    TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+                                               iwc.getMergePolicy());
+
+    // set by legacy <mergeFactor> setting
     assertEquals(7, tieredMP.getMaxMergeAtOnce());
     
-    // make sure we overrode segmentsPerTier (split from maxMergeAtOnce out of mergeFactor)
+    // mp-specific setters
+    assertEquals(19, tieredMP.getMaxMergeAtOnceExplicit());
+    assertEquals(0.1D, tieredMP.getNoCFSRatio(), 0.0D);
+    // make sure we overrode segmentsPerTier 
+    // (split from maxMergeAtOnce out of mergeFactor)
     assertEquals(9D, tieredMP.getSegmentsPerTier(), 0.001);
     
-    // make sure we overrode noCFSRatio (useless because we disabled useCompoundFile,
-    // but just to make sure it works)
-    assertEquals(1.0D, tieredMP.getNoCFSRatio(), 0.001);
+    assertCommitSomeNewDocs();
+    // even though we have a single segment (which is 100% of the size of 
+    // the index which is higher then our 0.6D threashold) the
+    // compound ratio doesn't matter because the segment was never merged
+    assertCompoundSegments(h.getCore(), expectCFS);
+
+    assertCommitSomeNewDocs();
+    assertNumSegments(h.getCore(), 2);
+    assertCompoundSegments(h.getCore(), expectCFS);
+
+    assertU(optimize());
+    assertNumSegments(h.getCore(), 1);
+    // we've now forced a merge, and the MP ratio should be in play
+    assertCompoundSegments(h.getCore(), false);
+  }
+
+  /**
+   * Given a Type and an object asserts that the object is non-null and an 
+   * instance of the specified Type.  The object is then cast to that type and 
+   * returned.
+   */
+  public static <T> T assertAndCast(Class<? extends T> clazz, Object o) {
+    assertNotNull(clazz);
+    assertNotNull(o);
+    assertTrue(clazz.isInstance(o));
+    return clazz.cast(o);
+  }
+
+  public static void assertCommitSomeNewDocs() {
+    for (int i = 0; i < 5; i++) {
+      int val = docIdCounter.getAndIncrement();
+      assertU(adoc("id", "" + val,
+                   "a_s", val + "_" + val + "_" + val + "_" + val,
+                   "b_s", val + "_" + val + "_" + val + "_" + val,
+                   "c_s", val + "_" + val + "_" + val + "_" + val,
+                   "d_s", val + "_" + val + "_" + val + "_" + val,
+                   "e_s", val + "_" + val + "_" + val + "_" + val,
+                   "f_s", val + "_" + val + "_" + val + "_" + val));
+    }
+    assertU(commit());
   }
+
+  /**
+   * Given an SolrCore, asserts that the number of leave segments in 
+   * the index reader matches the expected value.
+   */
+  public static void assertNumSegments(SolrCore core, int expected) {
+    RefCounted<SolrIndexSearcher> searcherRef = core.getRegisteredSearcher();
+    try {
+      assertEquals(expected, searcherRef.get().getIndexReader().leaves().size());
+    } finally {
+      searcherRef.decref();
+    }
+  }
+
+  /**
+   * Given an SolrCore, asserts that each segment in the (searchable) index 
+   * has a compound file status that matches the expected input.
+   */
+  public static void assertCompoundSegments(SolrCore core, boolean compound) {
+    RefCounted<SolrIndexSearcher> searcherRef = core.getRegisteredSearcher();
+    try {
+      assertCompoundSegments(searcherRef.get().getIndexReader(), compound);
+    } finally {
+      searcherRef.decref();
+    }
+  }
+
+  /**
+   * Given an IndexReader, asserts that there is at least one AtomcReader leaf,
+   * and that all AtomicReader leaves are SegmentReader's that have a compound 
+   * file status that matches the expected input.
+   */
+  private static void assertCompoundSegments(IndexReader reader, 
+                                             boolean compound) {
+
+    assertNotNull("Null leaves", reader.leaves());
+    assertTrue("no leaves", 0 < reader.leaves().size());
+
+    for (AtomicReaderContext atomic : reader.leaves()) {
+      assertTrue("not a segment reader: " + atomic.reader().toString(), 
+                 atomic.reader() instanceof SegmentReader);
+      
+      assertEquals("Compound status incorrect for: " + 
+                   atomic.reader().toString(),
+                   compound,
+                   ((SegmentReader)atomic.reader()).getSegmentInfo().info.getUseCompoundFile());
+    }
+  }
+
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java Sun Aug 11 12:19:13 2013
@@ -29,8 +29,17 @@ import java.io.File;
 public class TestShardHandlerFactory extends SolrTestCaseJ4 {
 
   public void testXML() throws Exception {
-    CoreContainer cc = new CoreContainer(TEST_HOME());
-    cc.load(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler.xml"));
+    CoreContainer cc = CoreContainer.createAndLoad(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler.xml"));
+    ShardHandlerFactory factory = cc.getShardHandlerFactory();
+    assertTrue(factory instanceof MockShardHandlerFactory);
+    NamedList args = ((MockShardHandlerFactory)factory).args;
+    assertEquals("myMagicRequiredValue", args.get("myMagicRequiredParameter"));
+    factory.close();
+    cc.shutdown();
+  }
+
+  public void testOldXML() throws Exception {
+    CoreContainer cc = CoreContainer.createAndLoad(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler-old.xml"));
     ShardHandlerFactory factory = cc.getShardHandlerFactory();
     assertTrue(factory instanceof MockShardHandlerFactory);
     NamedList args = ((MockShardHandlerFactory)factory).args;

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java Sun Aug 11 12:19:13 2013
@@ -17,8 +17,15 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
+import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LiveIndexWriterConfig;
+
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.RefCounted;
+import org.apache.solr.util.RandomMergePolicy;
+import org.apache.solr.update.LoggingInfoStream;
 import org.junit.BeforeClass;
 
 public class TestSolrIndexConfig extends SolrTestCaseJ4 {
@@ -27,10 +34,31 @@ public class TestSolrIndexConfig extends
   public static void beforeClass() throws Exception {
     initCore("solrconfig-indexconfig.xml","schema.xml");
   }
+
+  public void testLiveWriter() throws Exception {
+    SolrCore core = h.getCore();
+    RefCounted<IndexWriter> iw = core.getUpdateHandler().getSolrCoreState().getIndexWriter(core);
+    try {
+      checkIndexWriterConfig(iw.get().getConfig());
+    } finally {
+      if (null != iw) iw.decref();
+    }
+  }
+
   
-  public void testIndexConfig() throws Exception {
+  public void testIndexConfigParsing() throws Exception {
     IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
 
+    checkIndexWriterConfig(iwc);
+  }
+
+  private void checkIndexWriterConfig(LiveIndexWriterConfig iwc) {
+
     assertEquals(123, iwc.getMaxThreadStates());
+    assertTrue(iwc.getInfoStream() instanceof LoggingInfoStream);
+    assertTrue(iwc.getMergePolicy().getClass().toString(),
+               iwc.getMergePolicy() instanceof RandomMergePolicy);
+
   }
+
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java Sun Aug 11 12:19:13 2013
@@ -17,6 +17,23 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
+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;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -29,24 +46,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-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;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
 
 public class TestSolrXMLSerializer extends LuceneTestCase {
   private static final XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -143,6 +142,9 @@ public class TestSolrXMLSerializer exten
     solrXMLDef.containerProperties = containerProperties ;
     solrXMLDef.solrAttribs = rootSolrAttribs;
     solrXMLDef.coresAttribs = coresAttribs;
+    solrXMLDef.loggingAttribs = new HashMap<String, String>();
+    solrXMLDef.loggingAttribs = new HashMap<String, String>();
+    solrXMLDef.watcherAttribs = new HashMap<String, String>();
     return solrXMLDef;
   }
   

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXml.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXml.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXml.java Sun Aug 11 12:19:13 2013
@@ -17,37 +17,34 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.SolrTestCaseJ4;
+import org.junit.Rule;
 import org.junit.Test;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 public class TestSolrXml extends SolrTestCaseJ4 {
+
+  @Rule
+  public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());
+
   private final File solrHome = new File(TEMP_DIR, TestSolrXml.getClassName() + File.separator + "solrHome");
 
   @Test
-  public void testAllInfoPresent() throws IOException, ParserConfigurationException, SAXException {
-    CoreContainer cc = null;
+  public void testAllInfoPresent() throws IOException {
+
     File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
     FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml"));
+
+    SolrResourceLoader loader = null;
     try {
-      InputStream is = new FileInputStream(new File(solrHome, "solr.xml"));
-      Config config = new Config(new SolrResourceLoader("solr/collection1"), null, new InputSource(is), null, false);
-      boolean oldStyle = (config.getNode("solr/cores", false) != null);
-      ConfigSolr cfg;
-      if (oldStyle) {
-        cfg = new ConfigSolrXmlOld(config, cc);
-      } else {
-        cfg = new ConfigSolrXml(config, cc);
-      }
+      loader = new SolrResourceLoader(solrHome.getAbsolutePath());
+      ConfigSolr cfg = ConfigSolr.fromSolrHome(loader, solrHome.getAbsolutePath());
 
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_ADMINHANDLER, null), "testAdminHandler");
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_CORELOADTHREADS, 0), 11);
@@ -64,10 +61,6 @@ public class TestSolrXml extends SolrTes
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_LOGGING_WATCHER_THRESHOLD, 0), 99);
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_MANAGEMENTPATH, null), "testManagementPath");
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_SHAREDLIB, null), "testSharedLib");
-      assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_CLASS, null), "testHttpShardHandlerFactory");
-      assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_CONNTIMEOUT, 0), 110);
-      assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_NAME, null), "testShardHandlerFactory");
-      assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_SOCKETTIMEOUT, 0), 100);
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_SHARESCHEMA, null), "testShareSchema");
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_TRANSIENTCACHESIZE, 0), 66);
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_ZKCLIENTTIMEOUT, 0), 77);
@@ -75,61 +68,35 @@ public class TestSolrXml extends SolrTes
       assertNull("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_PERSISTENT, null));
       assertNull("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_CORES_DEFAULT_CORE_NAME, null));
       assertNull("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_ADMINPATH, null));
-    } finally {
-      if (cc != null) cc.shutdown();
     }
+    finally {
+      loader.close();
+    }
+
   }
 
   // Test  a few property substitutions that happen to be in solr-50-all.xml.
-  public void testPropretySub() throws IOException, ParserConfigurationException, SAXException {
+  public void testPropertySub() throws IOException {
 
-    String coreRoot = System.getProperty("coreRootDirectory");
-    String hostPort = System.getProperty("hostPort");
-    String shareSchema = System.getProperty("shareSchema");
-    String socketTimeout = System.getProperty("socketTimeout");
-    String connTimeout = System.getProperty("connTimeout");
     System.setProperty("coreRootDirectory", "myCoreRoot");
     System.setProperty("hostPort", "8888");
     System.setProperty("shareSchema", "newShareSchema");
     System.setProperty("socketTimeout", "220");
     System.setProperty("connTimeout", "200");
 
-    CoreContainer cc = null;
     File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
     FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml"));
+
+    SolrResourceLoader loader = null;
     try {
-      InputStream is = new FileInputStream(new File(solrHome, "solr.xml"));
-      Config config = new Config(new SolrResourceLoader("solr/collection1"), null, new InputSource(is), null, false);
-      boolean oldStyle = (config.getNode("solr/cores", false) != null);
-      ConfigSolr cfg;
-      if (oldStyle) {
-        cfg = new ConfigSolrXmlOld(config, cc);
-      } else {
-        cfg = new ConfigSolrXml(config, cc);
-      }
+      loader = new SolrResourceLoader(solrHome.getAbsolutePath());
+      ConfigSolr cfg = ConfigSolr.fromSolrHome(loader, solrHome.getAbsolutePath());
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_COREROOTDIRECTORY, null), "myCoreRoot");
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_HOSTPORT, 0), 8888);
-      assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_CONNTIMEOUT, 0), 200);
-      assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_SOCKETTIMEOUT, 0), 220);
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_SHARESCHEMA, null), "newShareSchema");
-
-    } finally {
-      if (cc != null) cc.shutdown();
-      if (coreRoot != null) System.setProperty("coreRootDirectory", coreRoot);
-      else System.clearProperty("coreRootDirectory");
-
-      if (hostPort != null) System.setProperty("hostPort", hostPort);
-      else System.clearProperty("hostPort");
-
-      if (shareSchema != null) System.setProperty("shareSchema", shareSchema);
-      else System.clearProperty("shareSchema");
-
-      if (socketTimeout != null) System.setProperty("socketTimeout", socketTimeout);
-      else System.clearProperty("socketTimeout");
-
-      if (connTimeout != null) System.setProperty("connTimeout", connTimeout);
-      else System.clearProperty("connTimeout");
-
+    }
+    finally {
+      loader.close();
     }
   }
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestXIncludeConfig.java Sun Aug 11 12:19:13 2013
@@ -26,6 +26,9 @@ import org.apache.solr.util.AbstractSolr
 import org.junit.Assume;
 import org.junit.BeforeClass;
 
+/** 
+ * Test both XInclude as well as more old school "entity includes"
+ */
 public class TestXIncludeConfig extends AbstractSolrTestCase {
 
   @BeforeClass
@@ -62,7 +65,20 @@ public class TestXIncludeConfig extends 
                  chain.getFactories()[0].getClass());
 
     IndexSchema schema = core.getLatestSchema();
+    
+    // xinclude
     assertNotNull("ft-included is null", schema.getFieldTypeByName("ft-included"));
     assertNotNull("field-included is null", schema.getFieldOrNull("field-included"));
+
+    // entity include
+    assertNotNull("ft-entity-include1 is null", 
+                  schema.getFieldTypeByName("ft-entity-include1"));
+    assertNotNull("ft-entity-include2 is null", 
+                  schema.getFieldTypeByName("ft-entity-include2"));
+
+    // sanity check
+    assertNull("ft-entity-include3 is not null",  // Does Not Exist Anywhere
+               schema.getFieldTypeByName("ft-entity-include3"));
+
   }
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java Sun Aug 11 12:19:13 2013
@@ -18,6 +18,7 @@
 package org.apache.solr.handler;
 
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
 import org.apache.solr.common.util.ContentStreamBase;
@@ -30,7 +31,11 @@ import org.apache.solr.update.DeleteUpda
 import org.apache.solr.update.processor.BufferingRequestProcessor;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.xml.sax.SAXException;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.List;
 import java.util.Map;
 
 public class JsonLoaderTest extends SolrTestCaseJ4 {
@@ -39,7 +44,7 @@ public class JsonLoaderTest extends Solr
     initCore("solrconfig.xml","schema.xml");
   }
   
-  static String input = ("{\n" +
+  static String input = json("{\n" +
       "\n" +
       "'add': {\n" +
       "  'doc': {\n" +
@@ -77,7 +82,7 @@ public class JsonLoaderTest extends Solr
       "'rollback': {}\n" +
       "\n" +
       "}\n" +
-      "").replace('\'', '"');
+      "");
 
 
   public void testParsing() throws Exception
@@ -231,11 +236,207 @@ public class JsonLoaderTest extends Solr
 
   @Test
   public void testNullValues() throws Exception {
-    updateJ("[{'id':'10','foo_s':null,'foo2_s':['hi',null,'there']}]".replace('\'', '"'), params("commit","true"));
+    updateJ( json( "[{'id':'10','foo_s':null,'foo2_s':['hi',null,'there']}]" ), params("commit","true"));
     assertJQ(req("q","id:10", "fl","foo_s,foo2_s")
         ,"/response/docs/[0]=={'foo2_s':['hi','there']}"
     );
   }
+  
+  @Test
+  public void testBooleanValuesInAdd() throws Exception {
+    String str = "{'add':[{'id':'1','b1':true,'b2':false,'b3':[false,true]}]}".replace('\'', '"');
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    JsonLoader loader = new JsonLoader();
+    loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+    assertEquals(1, p.addCommands.size());
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    SolrInputDocument d = add.solrDoc;
+    SolrInputField f = d.getField("b1");
+    assertEquals(Boolean.TRUE, f.getValue());
+    f = d.getField("b2");
+    assertEquals(Boolean.FALSE, f.getValue());
+    f = d.getField("b3");
+    assertEquals(2, ((List)f.getValue()).size());
+    assertEquals(Boolean.FALSE, ((List)f.getValue()).get(0));
+    assertEquals(Boolean.TRUE, ((List)f.getValue()).get(1));
+
+    req.close();
+  }
+
+  @Test
+  public void testIntegerValuesInAdd() throws Exception {
+    String str = "{'add':[{'id':'1','i1':256,'i2':-5123456789,'i3':[0,1]}]}".replace('\'', '"');
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    JsonLoader loader = new JsonLoader();
+    loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+    assertEquals(1, p.addCommands.size());
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    SolrInputDocument d = add.solrDoc;
+    SolrInputField f = d.getField("i1");
+    assertEquals(256L, f.getValue());
+    f = d.getField("i2");
+    assertEquals(-5123456789L, f.getValue());
+    f = d.getField("i3");
+    assertEquals(2, ((List)f.getValue()).size());
+    assertEquals(0L, ((List)f.getValue()).get(0));
+    assertEquals(1L, ((List)f.getValue()).get(1));
+
+    req.close();
+  }
+
+
+  @Test
+  public void testDecimalValuesInAdd() throws Exception {
+    String str = "{'add':[{'id':'1','d1':256.78,'d2':-5123456789.0,'d3':0.0,'d3':1.0,'d4':1.7E-10}]}".replace('\'', '"');
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    JsonLoader loader = new JsonLoader();
+    loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+    assertEquals(1, p.addCommands.size());
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    SolrInputDocument d = add.solrDoc;
+    SolrInputField f = d.getField("d1");
+    assertEquals(256.78, f.getValue());
+    f = d.getField("d2");
+    assertEquals(-5123456789.0, f.getValue());
+    f = d.getField("d3");
+    assertEquals(2, ((List)f.getValue()).size());
+    assertTrue(((List)f.getValue()).contains(0.0));
+    assertTrue(((List) f.getValue()).contains(1.0));
+    f = d.getField("d4");
+    assertEquals(1.7E-10, f.getValue());
+
+    req.close();
+  }
+
+  @Test
+  public void testBigDecimalValuesInAdd() throws Exception {
+    String str = ("{'add':[{'id':'1','bd1':0.12345678901234567890123456789012345,"
+                 + "'bd2':12345678901234567890.12345678901234567890,'bd3':0.012345678901234567890123456789012345,"
+                 + "'bd3':123456789012345678900.012345678901234567890}]}").replace('\'', '"');
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    JsonLoader loader = new JsonLoader();
+    loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+    assertEquals(1, p.addCommands.size());
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    SolrInputDocument d = add.solrDoc;
+    SolrInputField f = d.getField("bd1");                        
+    assertTrue(f.getValue() instanceof String);
+    assertEquals("0.12345678901234567890123456789012345", f.getValue());
+    f = d.getField("bd2");
+    assertTrue(f.getValue() instanceof String);
+    assertEquals("12345678901234567890.12345678901234567890", f.getValue());
+    f = d.getField("bd3");
+    assertEquals(2, ((List)f.getValue()).size());
+    assertTrue(((List)f.getValue()).contains("0.012345678901234567890123456789012345"));
+    assertTrue(((List)f.getValue()).contains("123456789012345678900.012345678901234567890"));
+
+    req.close();
+  }
+
+  @Test
+  public void testBigIntegerValuesInAdd() throws Exception {
+    String str = ("{'add':[{'id':'1','bi1':123456789012345678901,'bi2':1098765432109876543210,"
+                 + "'bi3':[1234567890123456789012,10987654321098765432109]}]}").replace('\'', '"');
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    JsonLoader loader = new JsonLoader();
+    loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+    assertEquals(1, p.addCommands.size());
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    SolrInputDocument d = add.solrDoc;
+    SolrInputField f = d.getField("bi1");
+    assertTrue(f.getValue() instanceof String);
+    assertEquals("123456789012345678901", f.getValue());
+    f = d.getField("bi2");
+    assertTrue(f.getValue() instanceof String);
+    assertEquals("1098765432109876543210", f.getValue());
+    f = d.getField("bi3");
+    assertEquals(2, ((List)f.getValue()).size());
+    assertTrue(((List)f.getValue()).contains("1234567890123456789012"));
+    assertTrue(((List)f.getValue()).contains("10987654321098765432109"));
+
+    req.close();
+  }
+
+
+  @Test
+  public void testAddNonStringValues() throws Exception {
+    // BigInteger and BigDecimal should be typed as strings, since there is no direct support for them
+    updateJ(json( "[{'id':'1','boolean_b':false,'long_l':19,'double_d':18.6,'big_integer_s':12345678901234567890,"
+        +"      'big_decimal_s':0.1234567890123456789012345}]" ), params("commit","true"));
+    assertJQ(req("q","id:1", "fl","boolean_b,long_l,double_d,big_integer_s,big_decimal_s")
+        ,"/response/docs/[0]=={'boolean_b':[false],'long_l':[19],'double_d':[18.6],"
+                             +"'big_integer_s':['12345678901234567890'],"
+                             +"'big_decimal_s':['0.1234567890123456789012345']}]}"
+    );
+  }
+
+
+  @Test
+  public void testAddBigIntegerValueToTrieField() throws Exception {
+    // Adding a BigInteger to a long field should fail
+    // BigInteger.longValue() returns only the low-order 64 bits.
+
+    ignoreException("big_integer_t");
+
+    try {
+      updateJ(json( "[{'id':'1','big_integer_tl':12345678901234567890}]" ), null);
+      fail("A BigInteger value should overflow a long field");
+    } catch (SolrException e) {
+      if ( ! (e.getCause() instanceof NumberFormatException)) {
+        throw e;
+      }
+    }
+
+    // Adding a BigInteger to an integer field should fail
+    // BigInteger.intValue() returns only the low-order 32 bits.
+    try {
+      updateJ(json( "[{'id':'1','big_integer_ti':12345678901234567890}]" ), null);
+      fail("A BigInteger value should overflow an integer field");
+    } catch (SolrException e) {
+      if ( ! (e.getCause() instanceof NumberFormatException)) {
+        throw e;
+      }
+    }
+
+    unIgnoreException("big_integer_t");
+  }
+
+  @Test
+  public void testAddBigDecimalValueToTrieField() throws Exception {
+    // Adding a BigDecimal to a double field should succeed by reducing precision
+    updateJ(json( "[{'id':'1','big_decimal_td':100000000000000000000000000001234567890.0987654321}]" ),
+            params("commit", "true"));
+    assertJQ(req("q","id:1", "fl","big_decimal_td"), 
+             "/response/docs/[0]=={'big_decimal_td':[1.0E38]}"
+    );
+
+    // Adding a BigDecimal to a float field should succeed by reducing precision
+    updateJ(json( "[{'id':'2','big_decimal_tf':100000000000000000000000000001234567890.0987654321}]" ),
+            params("commit", "true"));
+    assertJQ(req("q","id:2", "fl","big_decimal_tf"),
+             "/response/docs/[0]=={'big_decimal_tf':[1.0E38]}"
+    );
+  }
 
   // The delete syntax was both extended for simplification in 4.0
   @Test

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java Sun Aug 11 12:19:13 2013
@@ -17,6 +17,7 @@
 
 package org.apache.solr.handler;
 
+import org.apache.lucene.util._TestUtil;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.common.params.CommonParams;
@@ -35,12 +36,13 @@ public class TestCSVLoader extends SolrT
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
     initCore("solrconfig.xml","schema12.xml");
   }
 
-  String filename = "solr_tmp.csv";
+  String filename;
   String def_charset = "UTF-8";
-  File file = new File(filename);
+  File file;
 
   @Override
   @Before
@@ -48,6 +50,9 @@ public class TestCSVLoader extends SolrT
     // if you override setUp or tearDown, you better call
     // the super classes version
     super.setUp();
+    File tempDir = _TestUtil.getTempDir("TestCSVLoader");
+    file = new File(tempDir, "solr_tmp.csv");
+    filename = file.getPath();
     cleanup();
   }
   
@@ -107,6 +112,25 @@ public class TestCSVLoader extends SolrT
   }
 
   @Test
+  public void testCSVRowId() throws Exception {
+    makeFile("id\n100\n101\n102");
+    loadLocal("rowid", "rowid_i");//add a special field
+    // check default commit of false
+    assertU(commit());
+    assertQ(req("rowid_i:1"),"//*[@numFound='1']");
+    assertQ(req("rowid_i:2"),"//*[@numFound='1']");
+    assertQ(req("rowid_i:100"),"//*[@numFound='0']");
+
+    makeFile("id\n200\n201\n202");
+    loadLocal("rowid", "rowid_i", "rowidOffset", "100");//add a special field
+    // check default commit of false
+    assertU(commit());
+    assertQ(req("rowid_i:101"),"//*[@numFound='1']");
+    assertQ(req("rowid_i:102"),"//*[@numFound='1']");
+    assertQ(req("rowid_i:10000"),"//*[@numFound='0']");
+  }
+
+  @Test
   public void testCommitFalse() throws Exception {
     makeFile("id\n100\n101\n102");
     loadLocal("commit","false");

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Sun Aug 11 12:19:13 2013
@@ -103,7 +103,7 @@ public class TestReplicationHandler exte
     super.setUp();
 //    System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
     // For manual testing only
-    // useFactory(null); // force an FS factory
+    // useFactory(null); // force an FS factory.
     master = new SolrInstance("master", null);
     master.setUp();
     masterJetty = createJetty(master);
@@ -339,6 +339,40 @@ public class TestReplicationHandler exte
     }
   }
 
+
+  /**
+   * Verify that things still work if an IW has not been opened (and hence the CommitPoints have not been communicated to the deletion policy)
+   */
+  public void testNoWriter() throws Exception {
+    useFactory(null);    // force a persistent directory
+
+    // stop and start so they see the new directory setting
+    slaveJetty.stop();
+    masterJetty.stop();
+    slaveJetty.start(true);
+    masterJetty.start(true);
+
+    index(slaveClient, "id", "123456");
+    slaveClient.commit();
+    slaveJetty.stop();
+    slaveJetty.start(true);
+
+    // Currently we open a writer on-demand.  This is to test that we are correctly testing
+    // the code path when SolrDeletionPolicy.getLatestCommit() returns null.
+    // When we are using an ephemeral directory, an IW will always be opened to create the index and hence
+    // getLatestCommit will always be non-null.
+    CoreContainer cores = ((SolrDispatchFilter) slaveJetty.getDispatchFilter().getFilter()).getCores();
+    Collection<SolrCore> theCores = cores.getCores();
+    assertEquals(1, theCores.size());
+    SolrCore core = (SolrCore)theCores.toArray()[0];
+    assertNull( core.getDeletionPolicy().getLatestCommit() );
+
+
+    pullFromMasterToSlave();  // this will cause SnapPuller to be invoked and we will test when SolrDeletionPolicy.getLatestCommit() returns null
+
+    resetFactory();
+  }
+
   /**
    * Verify that empty commits and/or commits with openSearcher=false 
    * on the master do not cause subsequent replication problems on the slave 
@@ -1507,7 +1541,7 @@ public class TestReplicationHandler exte
     }
 
     public String getDataDir() {
-      return dataDir.toString();
+      return dataDir.getAbsolutePath();
     }
 
     public String getSolrConfigFile() {
@@ -1538,6 +1572,8 @@ public class TestReplicationHandler exte
 
       copyConfigFile(getSolrConfigFile(), "solrconfig.xml");
       copyConfigFile(getSchemaFile(), "schema.xml");
+      copyConfigFile(CONF_DIR + "solrconfig.snippet.randomindexconfig.xml", 
+                     "solrconfig.snippet.randomindexconfig.xml");
     }
 
     public void tearDown() throws Exception {

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java Sun Aug 11 12:19:13 2013
@@ -17,26 +17,25 @@
 
 package org.apache.solr.handler.admin;
 
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.handler.admin.CoreAdminHandler;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import org.apache.commons.io.FileUtils;
+import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrXMLCoresLocator;
 import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.SolrTestCaseJ4;
-
-import java.util.Map;
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.xpath.XPathExpressionException;
-
-import org.apache.commons.io.FileUtils;
-
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
-import org.xml.sax.SAXException;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+
+import java.io.File;
+import java.util.Map;
 
 public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
   
@@ -44,7 +43,89 @@ public class CoreAdminHandlerTest extend
   public static void beforeClass() throws Exception {
     initCore("solrconfig.xml", "schema.xml");
   }
-  
+
+  @Rule
+  public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());
+
+  public String getCoreName() { return this.getClass().getName() + "_sys_vars"; }
+
+  @Test
+  public void testCreateWithSysVars() throws Exception {
+    useFactory(null); // I require FS-based indexes for this test.
+
+    final File workDir = new File(TEMP_DIR, getCoreName());
+
+    if (workDir.exists()) {
+      FileUtils.deleteDirectory(workDir);
+    }
+    assertTrue("Failed to mkdirs workDir", workDir.mkdirs());
+    String coreName = "with_sys_vars";
+    File instDir = new File(workDir, coreName);
+    File subHome = new File(instDir, "conf");
+    assertTrue("Failed to make subdirectory ", subHome.mkdirs());
+
+    // Be sure we pick up sysvars when we create this
+    String srcDir = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
+    FileUtils.copyFile(new File(srcDir, "schema-tiny.xml"), new File(subHome, "schema_ren.xml"));
+    FileUtils.copyFile(new File(srcDir, "solrconfig-minimal.xml"), new File(subHome, "solrconfig_ren.xml"));
+    FileUtils.copyFile(new File(srcDir, "solrconfig.snippet.randomindexconfig.xml"),
+        new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
+
+    final CoreContainer cores = h.getCoreContainer();
+    SolrXMLCoresLocator.NonPersistingLocator locator
+        = (SolrXMLCoresLocator.NonPersistingLocator) cores.getCoresLocator();
+
+    final CoreAdminHandler admin = new CoreAdminHandler(cores);
+
+    // create a new core (using CoreAdminHandler) w/ properties
+    System.setProperty("INSTDIR_TEST", instDir.getAbsolutePath());
+    System.setProperty("CONFIG_TEST", "solrconfig_ren.xml");
+    System.setProperty("SCHEMA_TEST", "schema_ren.xml");
+
+    File dataDir = new File(workDir.getAbsolutePath(), "data_diff");
+    System.setProperty("DATA_TEST", dataDir.getAbsolutePath());
+
+    SolrQueryResponse resp = new SolrQueryResponse();
+    admin.handleRequestBody
+        (req(CoreAdminParams.ACTION,
+            CoreAdminParams.CoreAdminAction.CREATE.toString(),
+            CoreAdminParams.NAME, getCoreName(),
+            CoreAdminParams.INSTANCE_DIR, "${INSTDIR_TEST}",
+            CoreAdminParams.CONFIG, "${CONFIG_TEST}",
+            CoreAdminParams.SCHEMA, "${SCHEMA_TEST}",
+            CoreAdminParams.DATA_DIR, "${DATA_TEST}"),
+            resp);
+    assertNull("Exception on create", resp.getException());
+
+    // First assert that these values are persisted.
+    h.validateXPath
+        (locator.xml
+            ,"/solr/cores/core[@name='" + getCoreName() + "' and @instanceDir='${INSTDIR_TEST}']"
+            ,"/solr/cores/core[@name='" + getCoreName() + "' and @dataDir='${DATA_TEST}']"
+            ,"/solr/cores/core[@name='" + getCoreName() + "' and @schema='${SCHEMA_TEST}']"
+            ,"/solr/cores/core[@name='" + getCoreName() + "' and @config='${CONFIG_TEST}']"
+        );
+
+    // Now assert that certain values are properly dereferenced in the process of creating the core, see
+    // SOLR-4982.
+
+    // Should NOT be a datadir named ${DATA_TEST} (literal). This is the bug after all
+    File badDir = new File(instDir, "${DATA_TEST}");
+    assertFalse("Should have substituted the sys var, found file " + badDir.getAbsolutePath(), badDir.exists());
+
+    // For the other 3 vars, we couldn't get past creating the core fi dereferencing didn't work correctly.
+
+    // Should have segments in the directory pointed to by the ${DATA_TEST}.
+    File test = new File(dataDir, "index");
+    assertTrue("Should have found index dir at " + test.getAbsolutePath(), test.exists());
+    test = new File(test,"segments.gen");
+    assertTrue("Should have found segments.gen at " + test.getAbsolutePath(), test.exists());
+
+    // Cleanup
+    FileUtils.deleteDirectory(workDir);
+
+  }
+
   @Test
   public void testCoreAdminHandler() throws Exception {
     final File workDir = new File(TEMP_DIR, this.getClass().getName());
@@ -55,7 +136,6 @@ public class CoreAdminHandlerTest extend
     assertTrue("Failed to mkdirs workDir", workDir.mkdirs());
     
     final CoreContainer cores = h.getCoreContainer();
-    cores.setPersistent(false); // we'll do this explicitly as needed
 
     final CoreAdminHandler admin = new CoreAdminHandler(cores);
 
@@ -88,18 +168,13 @@ public class CoreAdminHandlerTest extend
        resp);
     assertNull("Exception on create", resp.getException());
 
-    // verify props are in persisted file
-
-    final File xml = new File(workDir, "persist-solr.xml");
-    cores.persistFile(xml);
-    
-    assertXmlFile
-      (xml
-       ,"/solr/cores/core[@name='props']/property[@name='hoss' and @value='man']"
-       ,"/solr/cores/core[@name='props']/property[@name='foo' and @value='baz']"
-       );
+    CoreDescriptor cd = cores.getCoreDescriptor("props");
+    assertNotNull("Core not added!", cd);
+    assertEquals(cd.getCoreProperty("hoss", null), "man");
+    assertEquals(cd.getCoreProperty("foo", null), "baz");
 
     // attempt to create a bogus core and confirm failure
+    ignoreException("Could not load config");
     try {
       resp = new SolrQueryResponse();
       admin.handleRequestBody
@@ -113,6 +188,7 @@ public class CoreAdminHandlerTest extend
       // :NOOP:
       // :TODO: CoreAdminHandler's exception messages are terrible, otherwise we could assert something useful here
     }
+    unIgnoreException("Could not load config");
 
     // check specifically for status of the failed core name
     resp = new SolrQueryResponse();
@@ -141,6 +217,8 @@ public class CoreAdminHandlerTest extend
                
     // :TODO: because of SOLR-3665 we can't ask for status from all cores
 
-  }
+    // cleanup
+    FileUtils.deleteDirectory(workDir);
 
+  }
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java Sun Aug 11 12:19:13 2013
@@ -17,15 +17,22 @@
 
 package org.apache.solr.handler.admin;
 
-import java.util.logging.Logger;
-
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.logging.jul.JulInfo;
+import org.apache.solr.logging.log4j.Log4jInfo;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+
 public class LoggingHandlerTest extends SolrTestCaseJ4 {
+
+  // TODO: This only tests Log4j at the moment, as that's what's defined
+  // through the CoreContainer.
+
+  // TODO: Would be nice to throw an exception on trying to set a
+  // log level that doesn't exist
   
   @BeforeClass
   public static void beforeClass() throws Exception {
@@ -35,7 +42,8 @@ public class LoggingHandlerTest extends 
   @Test
   public void testLogLevelHandlerOutput() throws Exception {
     Logger tst = Logger.getLogger("org.apache.solr.SolrTestCaseJ4");
-    JulInfo wrap = new JulInfo(tst.getName(), tst);
+    tst.setLevel(Level.INFO);
+    Log4jInfo wrap = new Log4jInfo(tst.getName(), tst);
     
     assertQ("Show Log Levels OK",
             req(CommonParams.QT,"/admin/logging")
@@ -46,8 +54,8 @@ public class LoggingHandlerTest extends 
     assertQ("Set and remove a level",
             req(CommonParams.QT,"/admin/logging",  
                 "set", "org.xxx.yyy.abc:null",
-                "set", "org.xxx.yyy.zzz:FINEST")
-            ,"//arr[@name='loggers']/lst/str[.='org.xxx.yyy.zzz']/../str[@name='level'][.='FINEST']"
+                "set", "org.xxx.yyy.zzz:TRACE")
+            ,"//arr[@name='loggers']/lst/str[.='org.xxx.yyy.zzz']/../str[@name='level'][.='TRACE']"
             );
   }
 }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java Sun Aug 11 12:19:13 2013
@@ -17,17 +17,18 @@
 
 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.schema.IndexSchema;
 import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.TestHarness;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.Arrays;
+import java.util.EnumSet;
+
 /**
  * :TODO: currently only tests some of the utilities in the LukeRequestHandler
  */
@@ -35,6 +36,7 @@ public class LukeRequestHandlerTest exte
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
     initCore("solrconfig.xml", "schema12.xml");
   }
 
@@ -155,7 +157,7 @@ public class LukeRequestHandlerTest exte
     try {
       // First, determine that the two fields ARE there
       String response = h.query(req);
-      assertNull(h.validateXPath(response,
+      assertNull(TestHarness.validateXPath(response,
           getFieldXPathPrefix("solr_t") + "[@name='index']",
           getFieldXPathPrefix("solr_s") + "[@name='index']"
       ));
@@ -164,7 +166,7 @@ public class LukeRequestHandlerTest exte
       for (String f : Arrays.asList("solr_ti",
           "solr_td", "solr_pl", "solr_dt", "solr_b")) {
 
-        assertNotNull(h.validateXPath(response,
+        assertNotNull(TestHarness.validateXPath(response,
             getFieldXPathPrefix(f) + "[@name='index']"));
 
       }
@@ -174,7 +176,7 @@ public class LukeRequestHandlerTest exte
       for (String f : Arrays.asList("solr_t", "solr_s", "solr_ti",
           "solr_td", "solr_pl", "solr_dt", "solr_b")) {
 
-        assertNull(h.validateXPath(response,
+        assertNull(TestHarness.validateXPath(response,
             getFieldXPathPrefix(f) + "[@name='index']"));
       }
     } catch (Exception e) {
@@ -182,11 +184,34 @@ public class LukeRequestHandlerTest exte
     }
   }
 
+  public void testNumTerms() throws Exception {
+    final String f = "name";
+    for (String n : new String[] {"2", "3", "100", "99999"}) {
+      assertQ(req("qt", "/admin/luke", "fl", f, "numTerms", n),
+              field(f) + "lst[@name='topTerms']/int[@name='Apache']",
+              field(f) + "lst[@name='topTerms']/int[@name='Solr']",
+              "count("+field(f)+"lst[@name='topTerms']/int)=2");
+    }
+    
+    assertQ(req("qt", "/admin/luke", "fl", f, "numTerms", "1"),
+            // no garuntee which one we find
+            "count("+field(f)+"lst[@name='topTerms']/int)=1");
+
+    assertQ(req("qt", "/admin/luke", "fl", f, "numTerms", "0"),
+            "count("+field(f)+"lst[@name='topTerms']/int)=0");
+
+    // field with no terms shouldn't error
+    for (String n : new String[] {"0", "1", "2", "100", "99999"}) {
+      assertQ(req("qt", "/admin/luke", "fl", "bogus_s", "numTerms", n),
+              "count("+field(f)+"lst[@name='topTerms']/int)=0");
+    }
+  }
+
   public void testCopyFieldLists() throws Exception {
     SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema");
 
     String xml = h.query(req);
-    String r = h.validateXPath
+    String r = TestHarness.validateXPath
       (xml,
        field("text") + "/arr[@name='copySources']/str[.='title']",
        field("text") + "/arr[@name='copySources']/str[.='subject']",
@@ -216,7 +241,7 @@ public class LukeRequestHandlerTest exte
 
     SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema", "indent", "on");
     String xml = h.query(req);
-    String result = h.validateXPath(xml, field("bday") + "/arr[@name='copyDests']/str[.='catchall_t']");
+    String result = TestHarness.validateXPath(xml, field("bday") + "/arr[@name='copyDests']/str[.='catchall_t']");
     assertNull(xml, result);
 
     // Put back the configuration expected by the rest of the tests in this suite

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java Sun Aug 11 12:19:13 2013
@@ -19,7 +19,6 @@ package org.apache.solr.handler.componen
  */
 
 import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
 import org.junit.Test;
 
 /**
@@ -34,14 +33,7 @@ public class BadComponentTest extends So
       ignoreException(".*QueryElevationComponent.*");
       System.setProperty("elevate.file", "foo.xml");
       initCore("solrconfig-elevate.xml", "schema12.xml");
-      assertTrue(false);
-    } catch (RuntimeException e) {
-      //TODO: better way of checking this?
-      if (e.getCause() instanceof SolrException){
-        assertTrue(true);
-      } else {
-        assertTrue(false);
-      }
+      assertTrue(hasInitException("QueryElevationComponent"));
     } finally {
       System.clearProperty("elevate.file");
       resetExceptionIgnores();

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java Sun Aug 11 12:19:13 2013
@@ -31,6 +31,7 @@ public class TermVectorComponentDistribu
     handle.put("maxScore", SKIPVAL);
     handle.put("score", SKIPVAL);
     handle.put("[docid]", SKIPVAL);
+    handle.put("_version_", SKIPVAL); // not a cloud test, but may use updateLog
 
     // SOLR-3720: TODO: TVC doesn't "merge" df and idf .. should it?
     handle.put("df", SKIPVAL);

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java Sun Aug 11 12:19:13 2013
@@ -32,6 +32,7 @@ public class TermsComponentTest extends 
 
   @BeforeClass
   public static void beforeTest() throws Exception {
+    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
     initCore("solrconfig.xml","schema12.xml");
 
     assertNull(h.validateUpdate(adoc("id", "0", "lowerfilt", "a", "standardfilt", "a", "foo_i","1")));

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java Sun Aug 11 12:19:13 2013
@@ -30,7 +30,6 @@ import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.StringReader;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -175,7 +174,7 @@ public class HighlighterTest extends Sol
   public void testTermOffsetsTokenStream() throws Exception {
     String[] multivalued = { "a b c d", "e f g", "h", "i j k l m n" };
     Analyzer a1 = new WhitespaceAnalyzer(TEST_VERSION_CURRENT);
-    TokenStream tokenStream = a1.tokenStream("", new StringReader("a b c d e f g h i j k l m n"));
+    TokenStream tokenStream = a1.tokenStream("", "a b c d e f g h i j k l m n");
     tokenStream.reset();
 
     TermOffsetsTokenStream tots = new TermOffsetsTokenStream(
@@ -183,7 +182,7 @@ public class HighlighterTest extends Sol
     for( String v : multivalued ){
       TokenStream ts1 = tots.getMultiValuedTokenStream( v.length() );
       Analyzer a2 = new WhitespaceAnalyzer(TEST_VERSION_CURRENT);
-      TokenStream ts2 = a2.tokenStream("", new StringReader(v));
+      TokenStream ts2 = a2.tokenStream("", v);
       ts2.reset();
 
       while (ts1.incrementToken()) {

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java Sun Aug 11 12:19:13 2013
@@ -19,7 +19,6 @@ package org.apache.solr.logging;
 
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.core.ConfigSolr;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -27,24 +26,16 @@ import org.slf4j.LoggerFactory;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 public class TestLogWatcher {
 
-  private ConfigSolr config;
+  private LogWatcherConfig config;
 
   @Before
   public void setUp() {
-    config = createMock(ConfigSolr.class);
-    expect(config.getBool(ConfigSolr.CfgProp.SOLR_LOGGING_ENABLED, true)).andReturn(true);
-    expect(config.getInt(ConfigSolr.CfgProp.SOLR_LOGGING_WATCHER_SIZE, 50)).andReturn(50);
-    expect(config.get(ConfigSolr.CfgProp.SOLR_LOGGING_WATCHER_THRESHOLD, null)).andReturn(null);
-    expect(config.get(ConfigSolr.CfgProp.SOLR_LOGGING_CLASS, null)).andReturn(null);
-    replay(config);
+    config = new LogWatcherConfig(true, null, null, 50);
   }
 
   @Test

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java Sun Aug 11 12:19:13 2013
@@ -621,6 +621,13 @@ public class SimpleFacetsTest extends So
                 )
             ,"*[count(//lst[@name='zerolen_s']/int)=1]"
      );
+
+    assertQ("a facet.query that analyzes to no query shoud not NPE",
+        req("q", "*:*",
+            "facet", "true",
+            "facet.query", "{!field key=k f=lengthfilt}a"),//2 char minimum
+        "//lst[@name='facet_queries']/int[@name='k'][.='0']"
+    );
   }
 
   public static void indexDateFacets() {

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java Sun Aug 11 12:19:13 2013
@@ -45,6 +45,7 @@ public class TestBinaryResponseWriter ex
   
   @BeforeClass
   public static void beforeClass() throws Exception {
+    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
     initCore("solrconfig.xml", "schema12.xml");
   }
 

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestFaceting.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestFaceting.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/request/TestFaceting.java Sun Aug 11 12:19:13 2013
@@ -112,7 +112,7 @@ public class TestFaceting extends SolrTe
 
     // test seeking before term
     if (size>0) {
-      assertEquals(size>0, te.seekCeil(new BytesRef("000"), true) != TermsEnum.SeekStatus.END);
+      assertEquals(size>0, te.seekCeil(new BytesRef("000")) != TermsEnum.SeekStatus.END);
       assertEquals(0, te.ord());
       assertEquals(t(0), te.term().utf8ToString());
     }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java Sun Aug 11 12:19:13 2013
@@ -32,6 +32,7 @@ import java.util.Arrays;
 public class TestCSVResponseWriter extends SolrTestCaseJ4 {
   @BeforeClass
   public static void beforeClass() throws Exception {
+    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
     initCore("solrconfig.xml","schema12.xml");
     createIndex();
   }

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java Sun Aug 11 12:19:13 2013
@@ -58,22 +58,21 @@ public class TestManagedSchemaFieldResou
   @Test
   public void testAddFieldBadFieldType() throws Exception {
     assertJPut("/schema/fields/newfield",
-        "{\"type\":\"not_in_there_at_all\",\"stored\":\"false\"}",
+        json( "{'type':'not_in_there_at_all','stored':'false'}" ),
         "/error/msg==\"Field \\'newfield\\': Field type \\'not_in_there_at_all\\' not found.\"");
   }
 
   @Test
   public void testAddFieldMismatchedName() throws Exception {
     assertJPut("/schema/fields/newfield",
-        "{\"name\":\"something_else\",\"type\":\"text\",\"stored\":\"false\"}",
-        "/error/msg==\"Field name in the request body \\'something_else\\'"
-            + " doesn\\'t match field name in the request URL \\'newfield\\'\"");
+        json( "{'name':'something_else','type':'text','stored':'false'}" ),
+        "/error/msg=='///regex:newfield///'");
   }
   
   @Test
   public void testAddFieldBadProperty() throws Exception {
     assertJPut("/schema/fields/newfield",
-        "{\"type\":\"text\",\"no_property_with_this_name\":\"false\"}",
+        json( "{'type':'text','no_property_with_this_name':'false'}" ),
         "/error/msg==\"java.lang.IllegalArgumentException: Invalid field property: no_property_with_this_name\"");
   }
   
@@ -85,7 +84,7 @@ public class TestManagedSchemaFieldResou
             "/response/lst[@name='error']/int[@name='code'] = '404'");
     
     assertJPut("/schema/fields/newfield",
-        "{\"type\":\"text\",\"stored\":\"false\"}",
+        json( "{'type':'text','stored':'false'}" ),
         "/responseHeader/status==0");
     
     assertQ("/schema/fields/newfield?indent=on&wt=xml",
@@ -103,6 +102,42 @@ public class TestManagedSchemaFieldResou
   }
 
   @Test
+  public void testAddCopyField() throws Exception {
+    assertQ("/schema/fields/newfield2?indent=on&wt=xml",
+            "count(/response/lst[@name='field']) = 0",
+            "/response/lst[@name='responseHeader']/int[@name='status'] = '404'",
+            "/response/lst[@name='error']/int[@name='code'] = '404'");
+
+    assertJPut("/schema/fields/fieldA",
+        "{\"type\":\"text\",\"stored\":\"false\"}",
+        "/responseHeader/status==0");
+    assertJPut("/schema/fields/fieldB",
+        "{\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[\"fieldA\"]}",
+        "/responseHeader/status==0");
+    assertJPut("/schema/fields/fieldC",
+        "{\"type\":\"text\",\"stored\":\"false\", \"copyFields\":\"fieldA\"}",
+        "/responseHeader/status==0");
+
+    assertQ("/schema/fields/fieldB?indent=on&wt=xml",
+            "count(/response/lst[@name='field']) = 1",
+            "/response/lst[@name='responseHeader']/int[@name='status'] = '0'");
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldB",
+        "count(/response/arr[@name='copyFields']/lst) = 1"
+    );
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldC",
+        "count(/response/arr[@name='copyFields']/lst) = 1"
+    );
+    //fine to pass in empty list, just won't do anything
+    assertJPut("/schema/fields/fieldD",
+        "{\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[]}",
+        "/responseHeader/status==0");
+    //some bad usages
+    assertJPut("/schema/fields/fieldF",
+        "{\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[\"some_nonexistent_field_ignore_exception\"]}",
+        "/error/msg==\"copyField dest :\\'some_nonexistent_field_ignore_exception\\' is not an explicit field and doesn\\'t match a dynamicField.\"");
+  }
+
+  @Test
   public void testPostMultipleFields() throws Exception {
     assertQ("/schema/fields/newfield1?indent=on&wt=xml",
             "count(/response/lst[@name='field']) = 0",
@@ -142,5 +177,59 @@ public class TestManagedSchemaFieldResou
         "count(/response/result[@name='response']/doc/*) = 1",
         "/response/result[@name='response']/doc/str[@name='id'][.='456']");
   }
+
+  @Test
+  public void testPostCopy() throws Exception {
+    assertJPost("/schema/fields",
+        json(    "[{'name':'fieldA','type':'text','stored':'false'},"
+               + " {'name':'fieldB','type':'text','stored':'false'},"
+               + " {'name':'fieldC','type':'text','stored':'false', 'copyFields':['fieldB']}]" ),
+                "/responseHeader/status==0");
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldC",
+        "count(/response/arr[@name='copyFields']/lst) = 1"
+    );
+    assertJPost("/schema/fields",
+              "[{\"name\":\"fieldD\",\"type\":\"text\",\"stored\":\"false\"},"
+               + "{\"name\":\"fieldE\",\"type\":\"text\",\"stored\":\"false\"},"
+               + " {\"name\":\"fieldF\",\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[\"fieldD\",\"fieldE\"]},"
+               + " {\"name\":\"fieldG\",\"type\":\"text\",\"stored\":\"false\", \"copyFields\":\"fieldD\"}"//single
+               + "]",
+                "/responseHeader/status==0");
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldF",
+        "count(/response/arr[@name='copyFields']/lst) = 2"
+    );
+    //passing in an empty list is perfectly acceptable, it just won't do anything
+    assertJPost("/schema/fields",
+        "[{\"name\":\"fieldX\",\"type\":\"text\",\"stored\":\"false\"},"
+            + "{\"name\":\"fieldY\",\"type\":\"text\",\"stored\":\"false\"},"
+            + " {\"name\":\"fieldZ\",\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[]}]",
+        "/responseHeader/status==0");
+    //some bad usages
+
+    assertJPost("/schema/fields",
+              "[{\"name\":\"fieldH\",\"type\":\"text\",\"stored\":\"false\"},"
+               + "{\"name\":\"fieldI\",\"type\":\"text\",\"stored\":\"false\"},"
+               + " {\"name\":\"fieldJ\",\"type\":\"text\",\"stored\":\"false\", \"copyFields\":[\"some_nonexistent_field_ignore_exception\"]}]",
+                "/error/msg==\"copyField dest :\\'some_nonexistent_field_ignore_exception\\' is not an explicit field and doesn\\'t match a dynamicField.\"");
+  }
+
+  @Test
+  public void testPostCopyFields() throws Exception {
+    assertJPost("/schema/fields",
+              "[{\"name\":\"fieldA\",\"type\":\"text\",\"stored\":\"false\"},"
+               + "{\"name\":\"fieldB\",\"type\":\"text\",\"stored\":\"false\"},"
+               + "{\"name\":\"fieldC\",\"type\":\"text\",\"stored\":\"false\"},"
+                  + "{\"name\":\"fieldD\",\"type\":\"text\",\"stored\":\"false\"},"
+               + " {\"name\":\"fieldE\",\"type\":\"text\",\"stored\":\"false\"}]",
+                "/responseHeader/status==0");
+    assertJPost("/schema/copyfields", "[{\"source\":\"fieldA\", \"dest\":\"fieldB\"},{\"source\":\"fieldD\", \"dest\":[\"fieldC\", \"fieldE\"]}]", "/responseHeader/status==0");
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldA",
+        "count(/response/arr[@name='copyFields']/lst) = 1");
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=fieldD",
+        "count(/response/arr[@name='copyFields']/lst) = 2");
+    assertJPost("/schema/copyfields", "[{\"source\":\"some_nonexistent_field_ignore_exception\", \"dest\":[\"fieldA\"]}]", "/error/msg==\"copyField source :\\'some_nonexistent_field_ignore_exception\\' is not a glob and doesn\\'t match any explicit field or dynamicField.\"");
+    assertJPost("/schema/copyfields", "[{\"source\":\"fieldD\", \"dest\":[\"some_nonexistent_field_ignore_exception\"]}]", "/error/msg==\"copyField dest :\\'some_nonexistent_field_ignore_exception\\' is not an explicit field and doesn\\'t match a dynamicField.\"");
+  }
+
 }
 

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java Sun Aug 11 12:19:13 2013
@@ -32,6 +32,7 @@ public class NotRequiredUniqueKeyTest ex
 
   @BeforeClass
   public static void beforeTests() throws Exception {
+    System.setProperty("enable.update.log", "false"); // usecase doesn't work with updateLog
     initCore("solrconfig.xml","schema-not-required-unique-key.xml");
   }
 

Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NumericFieldsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NumericFieldsTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NumericFieldsTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/schema/NumericFieldsTest.java Sun Aug 11 12:19:13 2013
@@ -26,7 +26,7 @@ import org.junit.Test;
 public class NumericFieldsTest extends SolrTestCaseJ4 {
   @BeforeClass
   public static void beforeClass() throws Exception {
-    initCore("solrconfig-master.xml", "schema-numeric.xml");
+    initCore("solrconfig-basic.xml", "schema-numeric.xml");
   }
 
   static String[] types = new String[]{"int", "long", "float", "double", "date"};