You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rj...@apache.org on 2015/03/31 07:22:50 UTC

svn commit: r1670257 [38/39] - in /lucene/dev/branches/lucene6271: ./ dev-tools/ dev-tools/idea/.idea/libraries/ dev-tools/scripts/ lucene/ lucene/analysis/ lucene/analysis/common/ lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneou...

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/JsonRecordReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/JsonRecordReader.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/JsonRecordReader.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/JsonRecordReader.java Tue Mar 31 05:22:40 2015
@@ -320,7 +320,7 @@ public class JsonRecordReader {
 
       final boolean isRecordStarted = recordStarted || isRecord;
       Set<String> valuesAddedinThisFrame = null;
-      if (isRecord) {
+      if (isRecord || !recordStarted) {
         // This Node is a match for an PATH from a forEach attribute,
         // prepare for the clean up that will occurr when the record
         // is emitted after its END_ELEMENT is matched
@@ -384,7 +384,7 @@ public class JsonRecordReader {
               Object val = parseSingleFieldValue(event, parser, runnable);
               if (val != null) {
                 putValue(values, nameInRecord, val);
-                if (isRecordStarted) valuesAddedinThisFrame.add(nameInRecord);
+                valuesAddedinThisFrame.add(nameInRecord);
               }
 
             } else {
@@ -414,12 +414,9 @@ public class JsonRecordReader {
           }
         }
       } finally {
-        if ((isRecord() || !isRecordStarted) && !stack.empty()) {
-          Set<String> cleanThis = stack.pop();
-          if (cleanThis != null) {
-            for (String fld : cleanThis) {
-              values.remove(fld);
-            }
+        if ((isRecord() || !isRecordStarted)) {
+          for (String fld : valuesAddedinThisFrame) {
+            values.remove(fld);
           }
         }
       }

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java Tue Mar 31 05:22:40 2015
@@ -65,6 +65,12 @@ public class NamedList<T> implements Clo
     nvPairs = new ArrayList<>();
   }
 
+
+  public NamedList(int sz) {
+    nvPairs = new ArrayList<>(sz<<1);
+  }
+
+
   /**
    * Creates a NamedList instance containing the "name,value" pairs contained in the
    * Entry[].

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java Tue Mar 31 05:22:40 2015
@@ -43,6 +43,10 @@ public class SimpleOrderedMap<T> extends
     super();
   }
 
+  public SimpleOrderedMap(int sz) {
+    super(sz);
+  }
+
   /**
    * Creates an instance backed by an explicitly specified list of
    * pairwise names/values.

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java Tue Mar 31 05:22:40 2015
@@ -17,6 +17,7 @@
 
 package org.apache.solr.common.util;
 
+import java.text.MessageFormat;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -305,5 +306,9 @@ public class StrUtils {
     }
   }
 
-
+  /**Format using MesssageFormat but with the ROOT locale
+   */
+  public static String formatString(String pattern, Object... args)  {
+    return new MessageFormat(pattern, Locale.ROOT).format(args);
+  }
 }

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java Tue Mar 31 05:22:40 2015
@@ -26,6 +26,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -65,7 +66,7 @@ public abstract class LargeVolumeTestBas
     log.info("done");
   }
 
-  private void query(int count) throws SolrServerException {
+  private void query(int count) throws SolrServerException, IOException {
     SolrClient client = this.getSolrClient();
     SolrQuery query = new SolrQuery("*:*");
     QueryResponse response = client.query(query);

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Tue Mar 31 05:22:40 2015
@@ -32,7 +32,7 @@ import org.junit.BeforeClass;
 public class SolrExampleBinaryTest extends SolrExampleTests {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 
   @Override

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Tue Mar 31 05:22:40 2015
@@ -1441,7 +1441,7 @@ abstract public class SolrExampleTests e
   }
   
   @Test
-  public void testQueryWithParams() throws SolrServerException {
+  public void testQueryWithParams() throws SolrServerException, IOException {
     SolrClient client = getSolrClient();
     SolrQuery q = new SolrQuery("query");
     q.setParam("debug", true);

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java Tue Mar 31 05:22:40 2015
@@ -31,7 +31,7 @@ import org.junit.BeforeClass;
 public class SolrExampleXMLTest extends SolrExampleTests {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
   
   @Override

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java Tue Mar 31 05:22:40 2015
@@ -68,7 +68,7 @@ public class SolrSchemalessExampleTest e
         } catch (Exception ignore){}
       }
     }
-    createJetty(tempSolrHome.getAbsolutePath(), null, null);
+    createJetty(tempSolrHome.getAbsolutePath());
   }
   @Test
   public void testArbitraryJsonIndexing() throws Exception  {

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java Tue Mar 31 05:22:40 2015
@@ -41,7 +41,7 @@ public class TestBatchUpdate extends Sol
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 
   static final int numdocs = 1000;  

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java Tue Mar 31 05:22:40 2015
@@ -26,6 +26,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.QuickPatchThreadsFilter;
 import org.apache.solr.SolrIgnoredThreadsFilter;
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
@@ -45,6 +46,7 @@ import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Properties;
 import java.util.Set;
 
 /**
@@ -308,8 +310,14 @@ public class TestLBHttpSolrClient extend
     }
 
     public void startJetty() throws Exception {
-      jetty = new JettySolrRunner(getHomeDir(), "/solr", port, "bad_solrconfig.xml", null, true, null, sslConfig);
-      jetty.setDataDir(getDataDir());
+
+      Properties props = new Properties();
+      props.setProperty("solrconfig", "bad_solrconfig.xml");
+      props.setProperty("solr.data.dir", getDataDir());
+
+      JettyConfig jettyConfig = JettyConfig.builder(buildJettyConfig("/solr")).setPort(port).build();
+
+      jetty = new JettySolrRunner(getHomeDir(), props, jettyConfig);
       jetty.start();
       int newPort = jetty.getLocalPort();
       if (port != 0 && newPort != port) {

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java Tue Mar 31 05:22:40 2015
@@ -27,6 +27,6 @@ import org.junit.BeforeClass;
 public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 }

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java Tue Mar 31 05:22:40 2015
@@ -24,6 +24,6 @@ import org.junit.BeforeClass;
 public class LargeVolumeJettyTest extends LargeVolumeTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 }

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java Tue Mar 31 05:22:40 2015
@@ -46,7 +46,7 @@ public class SolrExampleJettyTest extend
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 
   @Test

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Tue Mar 31 05:22:40 2015
@@ -44,7 +44,7 @@ public class SolrExampleStreamingTest ex
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 
   @Override

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java Tue Mar 31 05:22:40 2015
@@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.client.solrj.response.QueryResponse;
@@ -36,6 +37,7 @@ import org.apache.solr.common.SolrInputD
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.util.SSLTestConfig;
+import org.eclipse.jetty.servlet.ServletHolder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -147,13 +149,13 @@ public class BasicHttpSolrClientTest ext
   
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
-    jetty.getDispatchFilter().getServletHandler()
-        .addServletWithMapping(RedirectServlet.class, "/redirect/*");
-    jetty.getDispatchFilter().getServletHandler()
-        .addServletWithMapping(SlowServlet.class, "/slow/*");
-    jetty.getDispatchFilter().getServletHandler()
-        .addServletWithMapping(DebugServlet.class, "/debug/*");
+    JettyConfig jettyConfig = JettyConfig.builder()
+        .withServlet(new ServletHolder(RedirectServlet.class), "/redirect/*")
+        .withServlet(new ServletHolder(SlowServlet.class), "/slow/*")
+        .withServlet(new ServletHolder(DebugServlet.class), "/debug/*")
+        .withSSLConfig(sslConfig)
+        .build();
+    createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
   }
   
   @Test
@@ -507,6 +509,24 @@ public class BasicHttpSolrClientTest ext
       assertEquals(0, response.getStatus());
     }
   }
+
+  @Test
+  public void testCollectionParameters() throws IOException, SolrServerException {
+
+    try (HttpSolrClient client = new HttpSolrClient(jetty.getBaseUrl().toString())) {
+      SolrInputDocument doc = new SolrInputDocument();
+      doc.addField("id", "collection");
+      client.add("collection1", doc);
+      client.commit("collection1");
+
+      assertEquals(1, client.query("collection1", new SolrQuery("id:collection")).getResults().getNumFound());
+    }
+
+    try (HttpSolrClient client = new HttpSolrClient(jetty.getBaseUrl().toString() + "/collection1")) {
+      assertEquals(1, client.query(new SolrQuery("id:collection")).getResults().getNumFound());
+    }
+
+  }
   
   @Test
   public void testSetParametersExternalClient() throws IOException{

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java Tue Mar 31 05:22:40 2015
@@ -17,12 +17,6 @@ package org.apache.solr.client.solrj.imp
  * limitations under the License.
  */
 
-import static org.apache.solr.cloud.OverseerCollectionProcessor.CREATE_NODE_SET;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
-import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
-import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
-
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -51,10 +45,11 @@ import org.apache.solr.common.params.Mod
 import org.apache.solr.common.params.ShardParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.zookeeper.KeeperException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -72,6 +67,11 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeoutException;
 
+import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
+import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
+import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
+import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
+
 
 /**
  * This test would be faster if we simulated the zk state instead.
@@ -122,6 +122,7 @@ public class CloudSolrClientTest extends
 
   @Test
   public void test() throws Exception {
+    checkCollectionParameters();
     allTests();
     stateVersionParamTest();
     customHttpClientTest();
@@ -498,11 +499,49 @@ public class CloudSolrClientTest extends
     indexDoc(doc);
   }
 
+  private void checkCollectionParameters() throws Exception {
+
+    try (CloudSolrClient client = createCloudClient("multicollection1")) {
+
+      createCollection("multicollection1", client, 2, 2);
+      createCollection("multicollection2", client, 2, 2);
+      waitForRecoveriesToFinish("multicollection1", false);
+      waitForRecoveriesToFinish("multicollection2", false);
+
+      List<SolrInputDocument> docs = new ArrayList<>(3);
+      for (int i = 0; i < 3; i++) {
+        SolrInputDocument doc = new SolrInputDocument();
+        doc.addField(id, Integer.toString(i));
+        doc.addField("a_t", "hello");
+        docs.add(doc);
+      }
+
+      client.add(docs);     // default - will add them to multicollection1
+      client.commit();
+
+      ModifiableSolrParams queryParams = new ModifiableSolrParams();
+      queryParams.add("q", "*:*");
+      assertEquals(3, client.query(queryParams).getResults().size());
+      assertEquals(0, client.query("multicollection2", queryParams).getResults().size());
+
+      SolrQuery query = new SolrQuery("*:*");
+      query.set("collection", "multicollection2");
+      assertEquals(0, client.query(query).getResults().size());
+
+      client.add("multicollection2", docs);
+      client.commit("multicollection2");
+
+      assertEquals(3, client.query("multicollection2", queryParams).getResults().size());
+
+    }
+
+  }
+
   private void stateVersionParamTest() throws Exception {
 
     try (CloudSolrClient client = createCloudClient(null)) {
       String collectionName = "checkStateVerCol";
-      createCollection(collectionName, client, 2, 2);
+      createCollection(collectionName, client, 1, 3);
       waitForRecoveriesToFinish(collectionName, false);
       DocCollection coll = client.getZkStateReader().getClusterState().getCollection(collectionName);
       Replica r = coll.getSlices().iterator().next().getReplicas().iterator().next();
@@ -520,19 +559,13 @@ public class CloudSolrClientTest extends
 
         q.setParam(CloudSolrClient.STATE_VERSION, collectionName + ":" + (coll.getZNodeVersion() - 1)); //an older version expect error
 
-        try {
-          solrClient.query(q);
-          log.info("expected query error");
-        } catch (HttpSolrClient.RemoteSolrException e) {
-          sse = e;
-        }
-
-        assertNotNull(sse);
-        assertEquals(" Error code should be ", sse.code(), SolrException.ErrorCode.INVALID_STATE.code);
-
+        QueryResponse rsp = solrClient.query(q);
+        Map m = (Map) rsp.getResponse().get(CloudSolrClient.STATE_VERSION, rsp.getResponse().size()-1);
+        assertNotNull("Expected an extra information from server with the list of invalid collection states", m);
+        assertNotNull(m.get(collectionName));
       }
 
-      //now send the request to another node that does n ot serve the collection
+      //now send the request to another node that does not serve the collection
 
       Set<String> allNodesOfColl = new HashSet<>();
       for (Slice slice : coll.getSlices()) {
@@ -541,27 +574,28 @@ public class CloudSolrClientTest extends
         }
       }
       String theNode = null;
-      for (String s : client.getZkStateReader().getClusterState().getLiveNodes()) {
+      Set<String> liveNodes = client.getZkStateReader().getClusterState().getLiveNodes();
+      for (String s : liveNodes) {
         String n = client.getZkStateReader().getBaseUrlForNodeName(s);
-        if(!allNodesOfColl.contains(s)){
+        if(!allNodesOfColl.contains(n)){
           theNode = n;
           break;
         }
       }
-      log.info("thenode which does not serve this collection{} ",theNode);
+      log.info("the node which does not serve this collection{} ",theNode);
       assertNotNull(theNode);
 
       try (SolrClient solrClient = new HttpSolrClient(theNode + "/"+collectionName)) {
 
-        q.setParam(CloudSolrClient.STATE_VERSION, collectionName + ":" + coll.getZNodeVersion());
+        q.setParam(CloudSolrClient.STATE_VERSION, collectionName + ":" + (coll.getZNodeVersion()-1));
         try {
-          solrClient.query(q);
+          QueryResponse rsp = solrClient.query(q);
           log.info("error was expected");
         } catch (HttpSolrClient.RemoteSolrException e) {
           sse = e;
         }
         assertNotNull(sse);
-        assertEquals(" Error code should be ", sse.code(), SolrException.ErrorCode.INVALID_STATE.code);
+        assertEquals(" Error code should be 510", SolrException.ErrorCode.INVALID_STATE.code, sse.code());
       }
     }
 
@@ -577,17 +611,20 @@ public class CloudSolrClientTest extends
     }
   }
 
+  @Rule
+  public ExpectedException exception = ExpectedException.none();
+
   public void testWrongZkChrootTest() throws IOException {
+
+    exception.expect(SolrException.class);
+    exception.expectMessage("cluster not found/not ready");
+
     try (CloudSolrClient client = new CloudSolrClient(zkServer.getZkAddress() + "/xyz/foo")) {
       client.setDefaultCollection(DEFAULT_COLLECTION);
       client.setZkClientTimeout(1000 * 60);
       client.connect();
       fail("Expected exception");
-    } catch(SolrException e) {
-      assertTrue(e.getCause() instanceof KeeperException);
     }
-    // see SOLR-6146 - this test will fail by virtue of the zkClient tracking performed
-    // in the afterClass method of the base class
   }
 
   public void customHttpClientTest() throws IOException {

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java Tue Mar 31 05:22:40 2015
@@ -19,10 +19,12 @@ package org.apache.solr.client.solrj.imp
 
 import org.apache.http.HttpResponse;
 import org.apache.solr.SolrJettyTestBase;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.util.SolrjNamedThreadFactory;
+import org.eclipse.jetty.servlet.ServletHolder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -123,9 +125,11 @@ public class ConcurrentUpdateSolrClientT
   
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
-    jetty.getDispatchFilter().getServletHandler()
-        .addServletWithMapping(TestServlet.class, "/cuss/*");
+    JettyConfig jettyConfig = JettyConfig.builder()
+        .withServlet(new ServletHolder(TestServlet.class), "/cuss/*")
+        .withSSLConfig(sslConfig)
+        .build();
+    createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
   }
   
   @Test

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java Tue Mar 31 05:22:40 2015
@@ -25,6 +25,8 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
+import org.eclipse.jetty.servlet.ServletHolder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -32,9 +34,11 @@ import org.junit.Test;
 public class ExternalHttpClientTest extends SolrJettyTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
-    jetty.getDispatchFilter().getServletHandler()
-        .addServletWithMapping(BasicHttpSolrClientTest.SlowServlet.class, "/slow/*");
+    JettyConfig jettyConfig = JettyConfig.builder()
+        .withServlet(new ServletHolder(BasicHttpSolrClientTest.SlowServlet.class), "/slow/*")
+        .withSSLConfig(sslConfig)
+        .build();
+    createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
   }
 
   /**

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java Tue Mar 31 05:22:40 2015
@@ -55,7 +55,7 @@ public class NoOpResponseParserTest exte
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(legacyExampleCollection1SolrHome(), null, null);
+    createJetty(legacyExampleCollection1SolrHome());
   }
 
   @Before

Modified: lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java (original)
+++ lucene/dev/branches/lucene6271/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java Tue Mar 31 05:22:40 2015
@@ -220,4 +220,38 @@ public class TestJsonRecordReader extend
     records = streamer.getAllRecords(new StringReader(json));
     assertEquals(2, records.size());
   }
+
+  public void testClearPreviousRecordFields() throws Exception {
+    String json = "{\n" +
+        "'first': 'John',\n" +
+        "'exams': [\n" +
+        "{'subject': 'Maths', 'test'   : 'term1', 'marks':90},\n" +
+        "{'subject': 'Biology', 'test'   : 'term1', 'marks':86}\n" +
+        "]\n" +
+        "}\n" +
+        "{\n" +
+        "'first': 'Bob',\n" +
+        "'exams': [\n" +
+        "{'subject': 'Maths', 'test': 'term1', 'marks': 95\n" +
+        "}\n" +
+        ",\n" +
+        "{\n" +
+        "'subject': 'Biology', 'test'   : 'term1', 'marks': 92}\n" +
+        "]\n" +
+        "}";
+
+
+    JsonRecordReader streamer;
+    List<Map<String, Object>> records;
+
+    streamer = JsonRecordReader.getInst("/exams", Collections.singletonList("/**"));
+    records = streamer.getAllRecords(new StringReader(json));
+    assertEquals(4, records.size());
+
+    for (Map<String, Object> record : records) {
+      for (Map.Entry<String, Object> e : record.entrySet()) {
+        assertFalse(e.getValue() instanceof List);
+      }
+    }
+  }
 }

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Tue Mar 31 05:22:40 2015
@@ -24,6 +24,7 @@ import org.apache.lucene.util.TestUtil;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrResponse;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.UpdateRequest;
@@ -46,12 +47,14 @@ import org.junit.runners.model.Statement
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.servlet.Filter;
 import java.io.File;
 import java.io.IOException;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -227,6 +230,8 @@ public abstract class BaseDistributedSea
   protected boolean verifyStress = true;
   protected int nThreads = 3;
 
+  protected int clientConnectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
+  protected int clientSoTimeout = 90000;
 
   public static int ORDERED = 1;
   public static int SKIP = 2;
@@ -304,9 +309,11 @@ public abstract class BaseDistributedSea
   }
 
   protected JettySolrRunner createControlJetty() throws Exception {
-    writeCoreProperties(testDir.toPath().resolve("control/cores"), DEFAULT_TEST_CORENAME);
-    System.setProperty("coreRootDirectory", testDir.toPath().resolve("control").toString());
-    JettySolrRunner jetty = createJetty(new File(getSolrHome()), testDir + "/control/data", null, getSolrConfigFile(), getSchemaFile());
+    Path jettyHome = testDir.toPath().resolve("control");
+    File jettyHomeFile = jettyHome.toFile();
+    seedSolrHome(jettyHomeFile);
+    seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
+    JettySolrRunner jetty = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
     return jetty;
   }
 
@@ -321,13 +328,12 @@ public abstract class BaseDistributedSea
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < numShards; i++) {
       if (sb.length() > 0) sb.append(',');
-      String shardname = "shard" + i;
-      Path coresPath = testDir.toPath().resolve(shardname).resolve("cores");
-      writeCoreProperties(coresPath, DEFAULT_TEST_CORENAME);
-      System.setProperty("coreRootDirectory", testDir.toPath().resolve(shardname).toString());
-      JettySolrRunner j = createJetty(new File(getSolrHome()),
-          testDir + "/shard" + i + "/data", null, getSolrConfigFile(),
-          getSchemaFile());
+      final String shardname = "shard" + i;
+      Path jettyHome = testDir.toPath().resolve(shardname);
+      File jettyHomeFile = jettyHome.toFile();
+      seedSolrHome(jettyHomeFile);
+      seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
+      JettySolrRunner j = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
       jettys.add(j);
       clients.add(createNewSolrClient(j.getLocalPort()));
       String shardStr = buildUrl(j.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME;
@@ -389,15 +395,29 @@ public abstract class BaseDistributedSea
   
   public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception {
 
-    boolean stopAtShutdown = true;
-    JettySolrRunner jetty = new JettySolrRunner
-        (solrHome.getAbsolutePath(), context, 0, solrConfigOverride, schemaOverride, stopAtShutdown,
-          getExtraServlets(), sslConfig, getExtraRequestFilters());
-    jetty.setShards(shardList);
-    jetty.setDataDir(dataDir);
+    Properties props = new Properties();
+    if (solrConfigOverride != null)
+      props.setProperty("solrconfig", solrConfigOverride);
+    if (schemaOverride != null)
+      props.setProperty("schema", schemaOverride);
+    if (shardList != null)
+      props.setProperty("shards", shardList);
+    if (dataDir != null) {
+      props.setProperty("solr.data.dir", dataDir);
+    }
     if (explicitCoreNodeName) {
-      jetty.setCoreNodeName(Integer.toString(nodeCnt.incrementAndGet()));
+      props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
     }
+    props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
+
+    JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, JettyConfig.builder()
+        .stopAtShutdown(true)
+        .setContext(context)
+        .withFilters(getExtraRequestFilters())
+        .withServlets(getExtraServlets())
+        .withSSLConfig(sslConfig)
+        .build());
+
     jetty.start();
     
     return jetty;
@@ -409,7 +429,7 @@ public abstract class BaseDistributedSea
   }
 
   /** Override this method to insert extra filters into the JettySolrRunners that are created using createJetty() */
-  public SortedMap<Class,String> getExtraRequestFilters() {
+  public SortedMap<Class<? extends Filter>,String> getExtraRequestFilters() {
     return null;
   }
 
@@ -417,8 +437,8 @@ public abstract class BaseDistributedSea
     try {
       // setup the client...
       HttpSolrClient client = new HttpSolrClient(buildUrl(port) + "/" + DEFAULT_TEST_CORENAME);
-      client.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
-      client.setSoTimeout(90000);
+      client.setConnectionTimeout(clientConnectionTimeout);
+      client.setSoTimeout(clientSoTimeout);
       client.setDefaultMaxConnectionsPerHost(100);
       client.setMaxTotalConnections(100);
       return client;
@@ -531,7 +551,7 @@ public abstract class BaseDistributedSea
     }
   }
 
-  protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
+  protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
     // query a random server
     int which = r.nextInt(clients.size());
     SolrClient client = clients.get(which);
@@ -602,7 +622,7 @@ public abstract class BaseDistributedSea
                 if (verifyStress) {
                   compareResponses(rsp, controlRsp);
                 }
-              } catch (SolrServerException e) {
+              } catch (SolrServerException | IOException e) {
                 throw new RuntimeException(e);
               }
             }
@@ -618,10 +638,10 @@ public abstract class BaseDistributedSea
     return rsp;
   }
   
-  public QueryResponse queryAndCompare(SolrParams params, SolrClient... clients) throws SolrServerException {
+  public QueryResponse queryAndCompare(SolrParams params, SolrClient... clients) throws SolrServerException, IOException {
     return queryAndCompare(params, Arrays.<SolrClient>asList(clients));
   }
-  public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients) throws SolrServerException {
+  public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients) throws SolrServerException, IOException {
     QueryResponse first = null;
     for (SolrClient client : clients) {
       QueryResponse rsp = client.query(new ModifiableSolrParams(params));
@@ -1036,12 +1056,38 @@ public abstract class BaseDistributedSea
     return null;
   }
   
-  protected void setupJettySolrHome(File jettyHome) throws IOException {
+  /**
+   * Given a directory that will be used as the SOLR_HOME for a jetty instance, seeds that 
+   * directory with the contents of {@link #getSolrHome} and ensures that the proper {@link #getSolrXml} 
+   * file is in place.
+   */
+  protected void seedSolrHome(File jettyHome) throws IOException {
     FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
     String solrxml = getSolrXml();
     if (solrxml != null) {
       FileUtils.copyFile(new File(getSolrHome(), solrxml), new File(jettyHome, "solr.xml"));
     }
+  }
+
+  /**
+   * Given a directory that will be used as the <code>coreRootDirectory</code> for a jetty instance, 
+   * Creates a core directory named {@link #DEFAULT_TEST_CORENAME} using a trivial
+   * <code>core.properties</code> if this file does not already exist.
+   *
+   * @see #writeCoreProperties(Path,String)
+   * @see #CORE_PROPERTIES_FILENAME
+   */
+  private void seedCoreRootDirWithDefaultTestCore(Path coreRootDirectory) throws IOException {
+    // Kludgy and brittle with assumptions about writeCoreProperties, but i don't want to 
+    // try to change the semantics of that method to ignore existing files
+    Path coreDir = coreRootDirectory.resolve(DEFAULT_TEST_CORENAME);
+    if (Files.notExists(coreDir.resolve(CORE_PROPERTIES_FILENAME))) {
+      writeCoreProperties(coreDir, DEFAULT_TEST_CORENAME);
+    } // else nothing to do, DEFAULT_TEST_CORENAME already exists
+  }
+
+  protected void setupJettySolrHome(File jettyHome) throws IOException {
+    seedSolrHome(jettyHome);
 
     Properties coreProperties = new Properties();
     coreProperties.setProperty("name", "collection1");
@@ -1051,7 +1097,7 @@ public abstract class BaseDistributedSea
     coreProperties.setProperty("schema", "${schema:schema.xml}");
     coreProperties.setProperty("coreNodeName", "${coreNodeName:}");
 
-    writeCoreProperties(jettyHome.toPath().resolve("cores/collection1"), coreProperties, "collection1");
+    writeCoreProperties(jettyHome.toPath().resolve("cores").resolve("collection1"), coreProperties, "collection1");
 
      //   <core name="collection1" instanceDir="collection1" shard="${shard:}"
      // collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java Tue Mar 31 05:22:40 2015
@@ -17,9 +17,11 @@
 
 package org.apache.solr;
 
+import org.noggit.JSONParser;
 import org.noggit.ObjectBuilder;
 import org.apache.solr.common.util.StrUtils;
 
+import java.io.IOException;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -31,6 +33,7 @@ public class JSONTestUtil {
    * Default delta used in numeric equality comparisons for floats and doubles.
    */
   public final static double DEFAULT_DELTA = 1e-5;
+  public static boolean failRepeatedKeys = false;
 
   /**
    * comparison using default delta
@@ -78,11 +81,25 @@ public class JSONTestUtil {
    * @param delta tollerance allowed in comparing float/double values
    */
   public static String match(String path, String input, String expected, double delta) throws Exception {
-    Object inputObj = ObjectBuilder.fromJSON(input);
-    Object expectObj = ObjectBuilder.fromJSON(expected);
+    Object inputObj = failRepeatedKeys ? new NoDupsObjectBuilder(new JSONParser(input)).getVal() : ObjectBuilder.fromJSON(input);
+    Object expectObj = failRepeatedKeys ? new NoDupsObjectBuilder(new JSONParser(expected)).getVal() : ObjectBuilder.fromJSON(expected);
     return matchObj(path, inputObj, expectObj, delta);
   }
 
+  static class NoDupsObjectBuilder extends ObjectBuilder {
+    public NoDupsObjectBuilder(JSONParser parser) throws IOException {
+      super(parser);
+    }
+
+    @Override
+    public void addKeyVal(Object map, Object key, Object val) throws IOException {
+      Object prev = ((Map<Object, Object>) map).put(key, val);
+      if (prev != null) {
+        throw new RuntimeException("REPEATED JSON OBJECT KEY: key=" + key + " prevValue=" + prev + " thisValue" + val);
+      }
+    }
+  }
+
   /**
    * @param path JSON path expression
    * @param input JSON Structure

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java Tue Mar 31 05:22:40 2015
@@ -21,6 +21,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.util.ExternalPaths;
@@ -56,13 +57,47 @@ abstract public class SolrJettyTestBase
                                             boolean stopAtShutdown, SortedMap<ServletHolder,String> extraServlets) 
       throws Exception { 
     // creates the data dir
+
+    context = context==null ? "/solr" : context;
+    SolrJettyTestBase.context = context;
+
+    JettyConfig jettyConfig = JettyConfig.builder()
+        .setContext(context)
+        .stopAtShutdown(stopAtShutdown)
+        .withServlets(extraServlets)
+        .withSSLConfig(sslConfig)
+        .build();
+
+    Properties nodeProps = new Properties();
+    if (configFile != null)
+      nodeProps.setProperty("solrconfig", configFile);
+    if (schemaFile != null)
+      nodeProps.setProperty("schema", schemaFile);
+    if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
+      nodeProps.setProperty("solr.data.dir", createTempDir().toFile().getCanonicalPath());
+    }
+
+    return createJetty(solrHome, nodeProps, jettyConfig);
+  }
+
+  public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception {
+    return createJetty(solrHome, configFile, null, context, true, null);
+  }
+
+  public static JettySolrRunner createJetty(String solrHome, JettyConfig jettyConfig) throws Exception {
+    return createJetty(solrHome, new Properties(), jettyConfig);
+  }
+
+  public static JettySolrRunner createJetty(String solrHome) throws Exception {
+    return createJetty(solrHome, new Properties(), JettyConfig.builder().withSSLConfig(sslConfig).build());
+  }
+
+  public static JettySolrRunner createJetty(String solrHome, Properties nodeProperties, JettyConfig jettyConfig) throws Exception {
+
     initCore(null, null, solrHome);
 
     Path coresDir = createTempDir().resolve("cores");
 
-    System.setProperty("coreRootDirectory", coresDir.toString());
-    System.setProperty("configSetBaseDir", solrHome);
-
     Properties props = new Properties();
     props.setProperty("name", DEFAULT_TEST_CORENAME);
     props.setProperty("configSet", "collection1");
@@ -71,27 +106,19 @@ abstract public class SolrJettyTestBase
 
     writeCoreProperties(coresDir.resolve("core"), props, "RestTestBase");
 
-    ignoreException("maxWarmingSearchers");
+    Properties nodeProps = new Properties(nodeProperties);
+    nodeProps.setProperty("coreRootDirectory", coresDir.toString());
+    nodeProps.setProperty("configSetBaseDir", solrHome);
 
-    context = context==null ? "/solr" : context;
-    SolrJettyTestBase.context = context;
-    jetty = new JettySolrRunner(solrHome, context, 0, configFile, schemaFile, stopAtShutdown, extraServlets, sslConfig);
+    ignoreException("maxWarmingSearchers");
 
-    // this sets the property for jetty starting SolrDispatchFilter
-    if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
-      jetty.setDataDir(createTempDir().toFile().getCanonicalPath());
-    }
-    
+    jetty = new JettySolrRunner(solrHome, nodeProps, jettyConfig);
     jetty.start();
     port = jetty.getLocalPort();
     log.info("Jetty Assigned Port#" + port);
     return jetty;
   }
 
-  public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception {
-    return createJetty(solrHome, configFile, null, context, true, null);
-  }
-
 
   @AfterClass
   public static void afterSolrJettyTestBase() throws Exception {

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Tue Mar 31 05:22:40 2015
@@ -32,6 +32,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.apache.lucene.util.QuickPatchThreadsFilter;
 import org.apache.lucene.util.TestUtil;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.util.ClientUtils;
@@ -46,12 +47,15 @@ import org.apache.solr.common.params.Mod
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.ObjectReleaseTracker;
 import org.apache.solr.common.util.XML;
-import org.apache.solr.core.ConfigSolr;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.CoresLocator;
+import org.apache.solr.core.NodeConfig;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.SolrXmlConfig;
+import org.apache.solr.core.ZkContainer;
 import org.apache.solr.handler.UpdateRequestHandler;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
@@ -65,6 +69,7 @@ import org.apache.solr.util.AbstractSolr
 import org.apache.solr.util.RevertDefaultThreadHandlerRule;
 import org.apache.solr.util.SSLTestConfig;
 import org.apache.solr.util.TestHarness;
+import org.apache.zookeeper.KeeperException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -130,6 +135,7 @@ import static com.google.common.base.Pre
 public abstract class SolrTestCaseJ4 extends LuceneTestCase {
 
   public static final String DEFAULT_TEST_CORENAME = "collection1";
+  protected static final String CORE_PROPERTIES_FILENAME = "core.properties";
 
   private static String coreName = DEFAULT_TEST_CORENAME;
 
@@ -149,7 +155,7 @@ public abstract class SolrTestCaseJ4 ext
     log.info("Writing core.properties file to {}", coreDirectory);
     Files.createDirectories(coreDirectory);
     try (Writer writer =
-             new OutputStreamWriter(Files.newOutputStream(coreDirectory.resolve("core.properties")), Charset.forName("UTF-8"))) {
+             new OutputStreamWriter(Files.newOutputStream(coreDirectory.resolve(CORE_PROPERTIES_FILENAME)), Charset.forName("UTF-8"))) {
       properties.store(writer, testname);
     }
   }
@@ -166,6 +172,18 @@ public abstract class SolrTestCaseJ4 ext
     public String bugUrl() default "None";
   }
   
+  /**
+   * Annotation for test classes that want to disable ObjectReleaseTracker
+   */
+  @Documented
+  @Inherited
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public @interface SuppressObjectReleaseTracker {
+    /** Point to JIRA entry. */
+    public String bugUrl();
+  }
+  
   // these are meant to be accessed sequentially, but are volatile just to ensure any test
   // thread will read the latest value
   protected static volatile SSLTestConfig sslConfig;
@@ -212,7 +230,13 @@ public abstract class SolrTestCaseJ4 ext
       deleteCore();
       resetExceptionIgnores();
       endTrackingSearchers();
-      assertTrue("Some resources were not closed, shutdown, or released.", ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
+      if (!RandomizedContext.current().getTargetClass().isAnnotationPresent(SuppressObjectReleaseTracker.class)) {
+        assertTrue("Some resources were not closed, shutdown, or released.", ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
+      } else {
+        if (!ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty()) {
+          log.warn("Some resources were not closed, shutdown, or released. Remove the SuppressObjectReleaseTracker annotation to get more information on the fail.");
+        }
+      }
       resetFactory();
       coreName = DEFAULT_TEST_CORENAME;
     } finally {
@@ -283,6 +307,10 @@ public abstract class SolrTestCaseJ4 ext
     
     return new SSLTestConfig(trySsl, trySslClientAuth);
   }
+
+  protected static JettyConfig buildJettyConfig(String context) {
+    return JettyConfig.builder().setContext(context).withSSLConfig(sslConfig).build();
+  }
   
   protected static String buildUrl(final int port, final String context) {
     return (isSSLMode() ? "https" : "http") + "://127.0.0.1:" + port + context;
@@ -309,14 +337,14 @@ public abstract class SolrTestCaseJ4 ext
    */
   public static void setupNoCoreTest(File solrHome, String xmlStr) throws Exception {
 
-    File tmpFile = new File(solrHome, ConfigSolr.SOLR_XML_FILE);
+    File tmpFile = new File(solrHome, SolrXmlConfig.SOLR_XML_FILE);
     if (xmlStr == null) {
       xmlStr = "<solr></solr>";
     }
     FileUtils.write(tmpFile, xmlStr, IOUtils.UTF_8);
 
     SolrResourceLoader loader = new SolrResourceLoader(solrHome.getAbsolutePath());
-    h = new TestHarness(ConfigSolr.fromFile(loader, new File(solrHome, "solr.xml")));
+    h = new TestHarness(SolrXmlConfig.fromFile(loader, new File(solrHome, "solr.xml")));
     lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
   }
   
@@ -598,15 +626,17 @@ public abstract class SolrTestCaseJ4 ext
     return h.getCoreContainer();
   }
 
-  public static CoreContainer createCoreContainer(ConfigSolr config) {
+  public static CoreContainer createCoreContainer(NodeConfig config, CoresLocator locator) {
     testSolrHome = config.getSolrResourceLoader().getInstanceDir();
-    h = new TestHarness(config);
+    h = new TestHarness(config, locator);
     lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
     return h.getCoreContainer();
   }
 
   public static CoreContainer createCoreContainer(String coreName, String dataDir, String solrConfig, String schema) {
-    CoreContainer cc = createCoreContainer(new TestHarness.TestConfigSolr(coreName, dataDir, solrConfig, schema));
+    NodeConfig nodeConfig = TestHarness.buildTestNodeConfig(new SolrResourceLoader(SolrResourceLoader.locateSolrHome()));
+    CoresLocator locator = new TestHarness.TestCoresLocator(coreName, dataDir, solrConfig, schema);
+    CoreContainer cc = createCoreContainer(nodeConfig, locator);
     h.coreName = coreName;
     return cc;
   }
@@ -658,7 +688,21 @@ public abstract class SolrTestCaseJ4 ext
    */
   public static void deleteCore() {
     log.info("###deleteCore" );
-    if (h != null) { h.close(); }
+    if (h != null) {
+      // If the test case set up Zk, it should still have it as available,
+      // otherwise the core close will just be unnecessarily delayed.
+      CoreContainer cc = h.getCoreContainer();
+      if (! cc.getCores().isEmpty() && cc.isZooKeeperAware()) {
+        try {
+          cc.getZkController().getZkClient().exists("/", false);
+        } catch (KeeperException e) {
+          log.error("Testing connectivity to ZK by checking for root path failed", e);
+          fail("Trying to tear down a ZK aware core container with ZK not reachable");
+        } catch (InterruptedException ignored) {}
+      }
+
+      h.close();
+    }
 
     if (factoryProp == null) {
       System.clearProperty("solr.directoryFactory");
@@ -786,9 +830,9 @@ public abstract class SolrTestCaseJ4 ext
   }
   /**
    * Validates a query matches some JSON test expressions and closes the
-   * query. The text expression is of the form path:JSON.  To facilitate
-   * easy embedding in Java strings, the JSON tests can have double quotes
-   * replaced with single quotes.
+   * query. The text expression is of the form path:JSON.  The Noggit JSON
+   * parser used accepts single quoted strings and bare strings to allow
+   * easy embedding in Java Strings.
    * <p>
    * Please use this with care: this makes it easy to match complete
    * structures, but doing so can result in fragile tests if you are
@@ -1101,22 +1145,15 @@ public abstract class SolrTestCaseJ4 ext
     return Arrays.asList(docs);
   }
 
-  /** Converts "test JSON" and returns standard JSON.
-   *  Currently this only consists of changing unescaped single quotes to double quotes,
-   *  and escaped single quotes to single quotes.
-   *
-   * The primary purpose is to be able to easily embed JSON strings in a JAVA string
-   * with the best readability.
+  /** Converts "test JSON" strings into JSON parseable by our JSON parser.
+   *  For example, this method changed single quoted strings into double quoted strings before
+   *  the parser could natively handle them.
    *
    * This transformation is automatically applied to JSON test srings (like assertJQ).
    */
   public static String json(String testJSON) {
-    testJSON = nonEscapedSingleQuotePattern.matcher(testJSON).replaceAll("\"");
-    testJSON = escapedSingleQuotePattern.matcher(testJSON).replaceAll("'");
     return testJSON;
   }
-  private static Pattern nonEscapedSingleQuotePattern = Pattern.compile("(?<!\\\\)\'");
-  private static Pattern escapedSingleQuotePattern = Pattern.compile("\\\\\'");
 
 
   /** Creates JSON from a SolrInputDocument.  Doesn't currently handle boosts.
@@ -1860,6 +1897,7 @@ public abstract class SolrTestCaseJ4 ext
     FileUtils.copyFile(new File(top, "open-exchange-rates.json"), new File(subHome, "open-exchange-rates.json"));
     FileUtils.copyFile(new File(top, "protwords.txt"), new File(subHome, "protwords.txt"));
     FileUtils.copyFile(new File(top, "schema.xml"), new File(subHome, "schema.xml"));
+    FileUtils.copyFile(new File(top, "enumsConfig.xml"), new File(subHome, "enumsConfig.xml"));
     FileUtils.copyFile(new File(top, "solrconfig.snippet.randomindexconfig.xml"), new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
     FileUtils.copyFile(new File(top, "solrconfig.xml"), new File(subHome, "solrconfig.xml"));
     FileUtils.copyFile(new File(top, "stopwords.txt"), new File(subHome, "stopwords.txt"));

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java Tue Mar 31 05:22:40 2015
@@ -133,7 +133,7 @@ public abstract class AbstractDistribZkT
     waitForRecoveriesToFinish(collection, zkStateReader, verbose, failOnTimeout, 330);
   }
   
-  protected void waitForRecoveriesToFinish(String collection,
+  public static void waitForRecoveriesToFinish(String collection,
       ZkStateReader zkStateReader, boolean verbose, boolean failOnTimeout, int timeoutSeconds)
       throws Exception {
     log.info("Wait for recoveries to finish - collection: " + collection + " failOnTimeout:" + failOnTimeout + " timeout (sec):" + timeoutSeconds);
@@ -170,7 +170,7 @@ public abstract class AbstractDistribZkT
           if (verbose) System.out.println("Gave up waiting for recovery to finish..");
           if (failOnTimeout) {
             Diagnostics.logThreadDumps("Gave up waiting for recovery to finish.  THREAD DUMP:");
-            printLayout();
+            zkStateReader.getZkClient().printLayoutToStdOut();
             fail("There are still nodes recoverying - waited for " + timeoutSeconds + " seconds");
             // won't get here
             return;
@@ -232,4 +232,13 @@ public abstract class AbstractDistribZkT
     zkClient.printLayoutToStdOut();
     zkClient.close();
   }
+
+  protected void restartZk(int pauseMillis) throws Exception {
+    log.info("Restarting ZK with a pause of {}ms in between", pauseMillis);
+    zkServer.shutdown();
+    // disconnect enough to test stalling, if things stall, then clientSoTimeout w""ill be hit
+    Thread.sleep(pauseMillis);
+    zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());
+    zkServer.run();
+  }
 }

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Tue Mar 31 05:22:40 2015
@@ -17,13 +17,34 @@ package org.apache.solr.cloud;
  * limitations under the License.
  */
 
-import org.apache.commons.io.FilenameUtils;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.*;
+import static org.apache.solr.common.cloud.ZkNodeProps.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
@@ -51,7 +72,6 @@ import org.apache.solr.common.util.Named
 import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.servlet.SolrDispatchFilter;
 import org.apache.solr.update.DirectUpdateHandler2;
 import org.apache.zookeeper.CreateMode;
@@ -62,30 +82,6 @@ import org.noggit.JSONWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.apache.solr.cloud.OverseerCollectionProcessor.CREATE_NODE_SET;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
-import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
-import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
-import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
-
 /**
  * TODO: we should still test this works as a custom update chain as well as
  * what we test now - the default update chain
@@ -126,7 +122,7 @@ public abstract class AbstractFullDistri
   protected boolean checkCreatedVsState;
   protected boolean useJettyDataDir = true;
 
-  protected Map<URI,SocketProxy> proxies = new HashMap<URI,SocketProxy>();
+  protected Map<URI,SocketProxy> proxies = new HashMap<>();
 
   public static class CloudJettyRunner {
     public JettySolrRunner jetty;
@@ -205,14 +201,11 @@ public abstract class AbstractFullDistri
 
     if (isSSLMode()) {
       System.clearProperty("urlScheme");
-      ZkStateReader zkStateReader = new ZkStateReader(zkServer.getZkAddress(),
-          AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT);
-      try {
+      try (ZkStateReader zkStateReader = new ZkStateReader(zkServer.getZkAddress(),
+          AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT)) {
         zkStateReader.getZkClient().create(ZkStateReader.CLUSTER_PROPS,
-          ZkStateReader.toJSON(Collections.singletonMap("urlScheme","https")),
-          CreateMode.PERSISTENT, true);
-      } finally {
-        zkStateReader.close();
+            ZkStateReader.toJSON(Collections.singletonMap("urlScheme", "https")),
+            CreateMode.PERSISTENT, true);
       }
     }
   }
@@ -280,7 +273,6 @@ public abstract class AbstractFullDistri
       File controlJettyDir = createTempDir("control").toFile();
       setupJettySolrHome(controlJettyDir);
 
-      System.setProperty("coreRootDirectory", controlJettyDir.toPath().resolve("cores").toString());
       controlJetty = createJetty(controlJettyDir, useJettyDataDir ? getDataDir(testDir
           + "/control/data") : null); // don't pass shard name... let it default to
                                // "shard1"
@@ -390,8 +382,7 @@ public abstract class AbstractFullDistri
 
       jettyDir.mkdirs();
       setupJettySolrHome(jettyDir);
-      log.info("create jetty " + i);
-      System.setProperty("coreRootDirectory", jettyDir.toPath().resolve("cores").toString());
+      log.info("create jetty {} in directory {}", i, jettyDir);
       JettySolrRunner j = createJetty(jettyDir, useJettyDataDir ? getDataDir(testDir + "/jetty"
           + cnt) : null, null, "solrconfig.xml", null);
       jettys.add(j);
@@ -452,13 +443,13 @@ public abstract class AbstractFullDistri
 
     int cnt = this.jettyIntCntr.incrementAndGet();
 
-      File jettyDir = createTempDir("jetty").toFile();
-      jettyDir.mkdirs();
-      org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
-      JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
-      jettys.add(j);
-      SolrClient client = createNewSolrClient(j.getLocalPort());
-      clients.add(client);
+    File jettyDir = createTempDir("jetty").toFile();
+    jettyDir.mkdirs();
+    setupJettySolrHome(jettyDir);
+    JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
+    jettys.add(j);
+    SolrClient client = createNewSolrClient(j.getLocalPort());
+    clients.add(client);
 
     int retries = 60;
     while (--retries >= 0) {
@@ -494,10 +485,22 @@ public abstract class AbstractFullDistri
   public JettySolrRunner createJetty(String dataDir, String ulogDir, String shardList,
       String solrConfigOverride) throws Exception {
 
-    JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), context, 0,
-        solrConfigOverride, null, false, getExtraServlets(), sslConfig, getExtraRequestFilters());
-    jetty.setShards(shardList);
-    jetty.setDataDir(getDataDir(dataDir));
+    JettyConfig jettyconfig = JettyConfig.builder()
+        .setContext(context)
+        .stopAtShutdown(false)
+        .withServlets(getExtraServlets())
+        .withFilters(getExtraRequestFilters())
+        .withSSLConfig(sslConfig)
+        .build();
+
+    Properties props = new Properties();
+    props.setProperty("solr.data.dir", getDataDir(dataDir));
+    props.setProperty("shards", shardList);
+    props.setProperty("solr.ulog.dir", ulogDir);
+    props.setProperty("solrconfig", solrConfigOverride);
+    
+    JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), props, jettyconfig);
+
     jetty.start();
 
     return jetty;
@@ -509,9 +512,26 @@ public abstract class AbstractFullDistri
       solrHome = getRelativeSolrHomePath(solrHome);
     }
 
-    JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), context, 0, solrConfigOverride, schemaOverride, false, getExtraServlets(), sslConfig, getExtraRequestFilters());
-    jetty.setShards(shardList);
-    jetty.setDataDir(getDataDir(dataDir));
+    JettyConfig jettyconfig = JettyConfig.builder()
+        .setContext(context)
+        .stopAtShutdown(false)
+        .withServlets(getExtraServlets())
+        .withFilters(getExtraRequestFilters())
+        .withSSLConfig(sslConfig)
+        .build();
+
+    Properties props = new Properties();
+    if (solrConfigOverride != null)
+      props.setProperty("solrconfig", solrConfigOverride);
+    if (schemaOverride != null)
+      props.setProperty("schema", schemaOverride);
+    if (shardList != null)
+      props.setProperty("shards", shardList);
+    if (dataDir != null)
+      props.setProperty("solr.data.dir", getDataDir(dataDir));
+    props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
+    
+    JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
     jetty.start();
 
     return jetty;
@@ -526,13 +546,28 @@ public abstract class AbstractFullDistri
                                      String shardList, String solrConfigOverride, String schemaOverride)
       throws Exception {
 
-    JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), context,
-        0, solrConfigOverride, schemaOverride, false,
-        getExtraServlets(), sslConfig, getExtraRequestFilters());
-    jetty.setShards(shardList);
-    jetty.setDataDir(getDataDir(dataDir));
+    JettyConfig jettyconfig = JettyConfig.builder()
+        .setContext(context)
+        .stopAtShutdown(false)
+        .withServlets(getExtraServlets())
+        .withFilters(getExtraRequestFilters())
+        .withSSLConfig(sslConfig)
+        .build();
+
+    Properties props = new Properties();
+    if (solrConfigOverride != null)
+      props.setProperty("solrconfig", solrConfigOverride);
+    if (schemaOverride != null)
+      props.setProperty("schema", schemaOverride);
+    if (shardList != null)
+      props.setProperty("shards", shardList);
+    if (dataDir != null)
+      props.setProperty("solr.data.dir", getDataDir(dataDir));
+    props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
 
-    SocketProxy proxy = new SocketProxy(0, sslConfig == null ? false : sslConfig.isSSLMode());
+    JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
+
+    SocketProxy proxy = new SocketProxy(0, sslConfig != null && sslConfig.isSSLMode());
     jetty.setProxyPort(proxy.getListenPort());
     jetty.start();
     proxy.open(jetty.getBaseUrl().toURI());
@@ -592,31 +627,24 @@ public abstract class AbstractFullDistri
   }
 
   private File getRelativeSolrHomePath(File solrHome) {
-    String path = SolrResourceLoader.normalizeDir(new File(".").getAbsolutePath());
-    String base = new File(solrHome.getPath()).getAbsolutePath();
-
-    if (base.startsWith(".")) {
-      base = base.replaceFirst("\\.", new File(".").getName());
-    }
-
-    if (path.endsWith(File.separator + ".")) {
-      path = path.substring(0, path.length() - 2);
-    }
-
-    int splits = path.split("\\" + File.separator).length;
-
-    StringBuilder p = new StringBuilder();
-    for (int i = 0; i < splits - 2; i++) {
-      p.append("..").append(File.separator);
-    }
-
-    String prefix = FilenameUtils.getPrefix(path);
-    if (base.startsWith(prefix)) {
-      base = base.substring(prefix.length());
+    final Path solrHomePath = solrHome.toPath();
+    final Path curDirPath = new File("").getAbsoluteFile().toPath();
+    
+    if (!solrHomePath.getRoot().equals(curDirPath.getRoot())) {
+      // root of current directory and solrHome are not the same, therefore cannot relativize
+      return solrHome;
     }
-
-    solrHome = new File(p.toString() + base);
-    return solrHome;
+    
+    final Path root = solrHomePath.getRoot();
+    
+    // relativize current directory to root: /tmp/foo -> /tmp/foo/../..
+    final File relativizedCurDir = new File(curDirPath.toFile(), curDirPath.relativize(root).toString());
+    
+    // exclude the root from solrHome: /tmp/foo/solrHome -> tmp/foo/solrHome
+    final Path solrHomeRelativeToRoot = root.relativize(solrHomePath);
+    
+    // create the relative solrHome: /tmp/foo/../../tmp/foo/solrHome
+    return new File(relativizedCurDir, solrHomeRelativeToRoot.toString()).getAbsoluteFile();
   }
   
   protected void updateMappingsFromZk(List<JettySolrRunner> jettys, List<SolrClient> clients) throws Exception {
@@ -734,6 +762,30 @@ public abstract class AbstractFullDistri
     }
   }
 
+  @SuppressWarnings("rawtypes")
+  protected int sendDocsWithRetry(List<SolrInputDocument> batch, int minRf, int maxRetries, int waitBeforeRetry) throws Exception {
+    UpdateRequest up = new UpdateRequest();
+    up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
+    up.add(batch);
+    NamedList resp = null;
+    int numRetries = 0;
+    while(true) {
+      try {
+        resp = cloudClient.request(up);
+        return cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), resp);
+      } catch (Exception exc) {
+        Throwable rootCause = SolrException.getRootCause(exc);
+        if (++numRetries <= maxRetries) {
+          log.warn("ERROR: " + rootCause + " ... Sleeping for " + waitBeforeRetry + " seconds before re-try ...");
+          Thread.sleep(waitBeforeRetry * 1000L);
+        } else {
+          log.error("No more retries available! Add batch failed due to: " + rootCause);
+          throw exc;
+        }
+      }
+    }
+  }
+
   @Override
   protected void indexDoc(SolrInputDocument doc) throws IOException,
       SolrServerException {
@@ -1167,11 +1219,7 @@ public abstract class AbstractFullDistri
           long num = cjetty.client.solrClient.query(query).getResults()
               .getNumFound();
           System.err.println("DOCS:" + num);
-        } catch (SolrServerException e) {
-          System.err.println("error contacting client: " + e.getMessage()
-              + "\n");
-          continue;
-        } catch (SolrException e) {
+        } catch (SolrServerException | SolrException | IOException e) {
           System.err.println("error contacting client: " + e.getMessage()
               + "\n");
           continue;
@@ -1322,16 +1370,13 @@ public abstract class AbstractFullDistri
         .getNumFound();
 
     // do some really inefficient mapping...
-    ZkStateReader zk = new ZkStateReader(zkServer.getZkAddress(), 10000,
-        AbstractZkTestCase.TIMEOUT);
     Map<String,Slice> slices = null;
     ClusterState clusterState;
-    try {
+    try (ZkStateReader zk = new ZkStateReader(zkServer.getZkAddress(), 10000,
+        AbstractZkTestCase.TIMEOUT)) {
       zk.createClusterStateWatchersAndUpdate();
       clusterState = zk.getClusterState();
       slices = clusterState.getSlicesMap(DEFAULT_COLLECTION);
-    } finally {
-      zk.close();
     }
 
     if (slices == null) {
@@ -1377,71 +1422,20 @@ public abstract class AbstractFullDistri
 
   @Override
   protected QueryResponse queryServer(ModifiableSolrParams params)
-      throws SolrServerException {
+      throws SolrServerException, IOException {
 
     if (r.nextBoolean()) params.set("collection", DEFAULT_COLLECTION);
 
-    QueryResponse rsp = cloudClient.query(params);
-    return rsp;
+    return cloudClient.query(params);
   }
 
-  static abstract class StopableThread extends Thread {
-    public StopableThread(String name) {
+  static abstract class StoppableThread extends Thread {
+    public StoppableThread(String name) {
       super(name);
     }
     public abstract void safeStop();
   }
 
-  class StopableSearchThread extends StopableThread {
-    private volatile boolean stop = false;
-    protected final AtomicInteger queryFails = new AtomicInteger();
-    private String[] QUERIES = new String[] {"to come","their country","aid","co*"};
-
-    public StopableSearchThread() {
-      super("StopableSearchThread");
-      setDaemon(true);
-    }
-
-    @Override
-    public void run() {
-      Random random = random();
-      int numSearches = 0;
-
-      while (true && !stop) {
-        numSearches++;
-        try {
-          //to come to the aid of their country.
-          cloudClient.query(new SolrQuery(QUERIES[random.nextInt(QUERIES.length)]));
-        } catch (Exception e) {
-          System.err.println("QUERY REQUEST FAILED:");
-          e.printStackTrace();
-          if (e instanceof SolrServerException) {
-            System.err.println("ROOT CAUSE:");
-            ((SolrServerException) e).getRootCause().printStackTrace();
-          }
-          queryFails.incrementAndGet();
-        }
-        try {
-          Thread.sleep(random.nextInt(4000) + 300);
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-        }
-      }
-
-      log.info("num searches done:" + numSearches + " with " + queryFails + " fails");
-    }
-
-    @Override
-    public void safeStop() {
-      stop = true;
-    }
-
-    public int getFails() {
-      return queryFails.get();
-    }
-
-  };
-
   public void waitForThingsToLevelOut(int waitForRecTimeSeconds) throws Exception {
     log.info("Wait for recoveries to finish - wait " + waitForRecTimeSeconds + " for each attempt");
     int cnt = 0;
@@ -1870,14 +1864,14 @@ public abstract class AbstractFullDistri
         REPLICATION_FACTOR, replicationFactor,
         MAX_SHARDS_PER_NODE, maxShardsPerNode,
         NUM_SLICES, numShards);
-    Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+    Map<String,List<Integer>> collectionInfos = new HashMap<>();
     createCollection(collectionInfos, collName, props, client);
   }
 
   protected List<Replica> ensureAllReplicasAreActive(String testCollectionName, String shardId, int shards, int rf, int maxWaitSecs) throws Exception {
     long startMs = System.currentTimeMillis();
 
-    Map<String,Replica> notLeaders = new HashMap<String,Replica>();
+    Map<String,Replica> notLeaders = new HashMap<>();
 
     ZkStateReader zkr = cloudClient.getZkStateReader();
     zkr.updateClusterState(true); // force the state to be fresh
@@ -1937,7 +1931,7 @@ public abstract class AbstractFullDistri
     long diffMs = (System.currentTimeMillis() - startMs);
     log.info("Took " + diffMs + " ms to see all replicas become active.");
 
-    List<Replica> replicas = new ArrayList<Replica>();
+    List<Replica> replicas = new ArrayList<>();
     replicas.addAll(notLeaders.values());
     return replicas;
   }
@@ -1953,7 +1947,7 @@ public abstract class AbstractFullDistri
     if (collection != null) {
       cs = clusterState.getCollection(collection).toString();
     } else {
-      Map<String,DocCollection> map = new HashMap<String,DocCollection>();
+      Map<String,DocCollection> map = new HashMap<>();
       for (String coll : clusterState.getCollections())
         map.put(coll, clusterState.getCollection(coll));
       CharArr out = new CharArr();

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java Tue Mar 31 05:22:40 2015
@@ -147,6 +147,8 @@ public abstract class AbstractZkTestCase
   
   @AfterClass
   public static void azt_afterClass() throws Exception {
+    deleteCore();
+
     System.clearProperty("zkHost");
     System.clearProperty("solr.test.sys.prop1");
     System.clearProperty("solr.test.sys.prop2");

Modified: lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java (original)
+++ lucene/dev/branches/lucene6271/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java Tue Mar 31 05:22:40 2015
@@ -9,6 +9,7 @@ import org.apache.solr.common.params.Sol
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -161,7 +162,7 @@ public class CloudInspectUtil {
    * @return true if the compared results are illegal.
    */
   public static boolean compareResults(SolrClient controlClient, SolrClient cloudClient)
-      throws SolrServerException {
+      throws SolrServerException, IOException {
     return compareResults(controlClient, cloudClient, null, null);
   }
   
@@ -171,7 +172,7 @@ public class CloudInspectUtil {
    * @return true if the compared results are illegal.
    */
   public static boolean compareResults(SolrClient controlClient, SolrClient cloudClient, Set<String> addFails, Set<String> deleteFails)
-      throws SolrServerException {
+      throws SolrServerException, IOException {
     
     SolrParams q = SolrTestCaseJ4.params("q","*:*","rows","0", "tests","checkShardConsistency(vsControl)");    // add a tag to aid in debugging via logs