You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/06/28 19:18:04 UTC

svn commit: r1688025 - in /lucene/dev/trunk/solr: core/src/test/org/apache/solr/ solrj/src/java/org/apache/solr/common/params/ solrj/src/test/org/apache/solr/client/solrj/impl/ solrj/src/test/org/apache/solr/common/params/

Author: andyetitmoves
Date: Sun Jun 28 17:18:04 2015
New Revision: 1688025

URL: http://svn.apache.org/r1688025
Log:
SOLR-7485: Replace shards.info occurrences with ShardParams.SHARDS_INFO

Added:
    lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java   (with props)
Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
    lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java?rev=1688025&r1=1688024&r2=1688025&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java Sun Jun 28 17:18:04 2015
@@ -141,7 +141,7 @@ public class TestTolerantSearch extends
     query.set(ShardParams.SHARDS_TOLERANT, "true");
     QueryResponse response = collection1.query(query);
     assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));
-    NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));
+    NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));
     boolean foundError = false;
     for (int i = 0; i < shardsInfo.size(); i++) {
       if (shardsInfo.getName(i).contains("collection2")) {
@@ -189,7 +189,7 @@ public class TestTolerantSearch extends
     query.set(ShardParams.SHARDS_TOLERANT, "true");
     QueryResponse response = collection1.query(query);
     assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));
-    NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));
+    NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));
     boolean foundError = false;
     for (int i = 0; i < shardsInfo.size(); i++) {
       if (shardsInfo.getName(i).contains("collection2")) {

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java?rev=1688025&r1=1688024&r2=1688025&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java Sun Jun 28 17:18:04 2015
@@ -19,6 +19,10 @@ package org.apache.solr.common.params;
 
 /**
  * Parameters used for distributed search.
+ * 
+ * When adding a new parameter here, please also add the corresponding
+ * one-line test case in the ShardParamsTest class.
+ * 
  */
 public interface ShardParams {
   /** the shards to use (distributed configuration) */

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java?rev=1688025&r1=1688024&r2=1688025&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java Sun Jun 28 17:18:04 2015
@@ -423,7 +423,7 @@ public class CloudSolrClientTest extends
 
     ModifiableSolrParams qParams = new ModifiableSolrParams();
     qParams.add("preferLocalShards", Boolean.toString(preferLocalShards));
-    qParams.add("shards.info", "true");
+    qParams.add(ShardParams.SHARDS_INFO, "true");
     qRequest.add(qParams);
 
     // CloudSolrClient sends the request to some node.
@@ -432,8 +432,8 @@ public class CloudSolrClientTest extends
     // local shards only
     QueryResponse qResponse = cloudClient.query (qRequest);
 
-    Object shardsInfo = qResponse.getResponse().get("shards.info");
-    assertNotNull("Unable to obtain shards.info", shardsInfo);
+    Object shardsInfo = qResponse.getResponse().get(ShardParams.SHARDS_INFO);
+    assertNotNull("Unable to obtain "+ShardParams.SHARDS_INFO, shardsInfo);
 
     // Iterate over shards-info and check what cores responded
     SimpleOrderedMap<?> shardsInfoMap = (SimpleOrderedMap<?>)shardsInfo;
@@ -441,9 +441,9 @@ public class CloudSolrClientTest extends
     List<String> shardAddresses = new ArrayList<String>();
     while (itr.hasNext()) {
       Map.Entry<String, ?> e = itr.next();
-      assertTrue("Did not find map-type value in shards.info", e.getValue() instanceof Map);
+      assertTrue("Did not find map-type value in "+ShardParams.SHARDS_INFO, e.getValue() instanceof Map);
       String shardAddress = (String)((Map)e.getValue()).get("shardAddress");
-      assertNotNull("shards.info did not return 'shardAddress' parameter", shardAddress);
+      assertNotNull(ShardParams.SHARDS_INFO+" did not return 'shardAddress' parameter", shardAddress);
       shardAddresses.add(shardAddress);
     }
     log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));

Added: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java?rev=1688025&view=auto
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java (added)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java Sun Jun 28 17:18:04 2015
@@ -0,0 +1,50 @@
+package org.apache.solr.common.params;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.LuceneTestCase;
+
+/**
+ * This class tests backwards compatibility of {@link ShardParams} parameter constants.
+ * If someone accidentally changes those constants then this test will flag that up. 
+ */
+public class ShardParamsTest extends LuceneTestCase
+{
+  public void testShards() { assertEquals(ShardParams.SHARDS, "shards"); }
+
+  public void testShardsRows() { assertEquals(ShardParams.SHARDS_ROWS, "shards.rows"); }
+  public void testShardsStart() { assertEquals(ShardParams.SHARDS_START, "shards.start"); }
+
+  public void testIds() { assertEquals(ShardParams.IDS, "ids"); }
+  
+  public void testIsShard() { assertEquals(ShardParams.IS_SHARD, "isShard"); }
+  
+  public void testShardUrl() { assertEquals(ShardParams.SHARD_URL, "shard.url"); }
+  
+  public void testShardsQt() { assertEquals(ShardParams.SHARDS_QT, "shards.qt"); }
+  
+  public void testShardsInfo() { assertEquals(ShardParams.SHARDS_INFO, "shards.info"); }
+  
+  public void testShardsTolerant() { assertEquals(ShardParams.SHARDS_TOLERANT, "shards.tolerant"); }
+  
+  public void testShardsPurpose() { assertEquals(ShardParams.SHARDS_PURPOSE, "shards.purpose"); }
+  
+  public void testRoute() { assertEquals(ShardParams._ROUTE_, "_route_"); }
+  
+  public void testDistribSinglePass() { assertEquals(ShardParams.DISTRIB_SINGLE_PASS, "distrib.singlePass"); }
+}