You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/06/14 02:02:43 UTC

[07/35] lucene-solr:jira/SOLR-10834: SOLR-10715: /v2/ should not be an alias for /v2/collections

SOLR-10715: /v2/ should not be an alias for /v2/collections


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6075956b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6075956b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6075956b

Branch: refs/heads/jira/SOLR-10834
Commit: 6075956b65ab378f67c3c7c2d3116ec8d43a312e
Parents: 95841d9
Author: Cao Manh Dat <da...@apache.org>
Authored: Mon Jun 12 10:32:45 2017 +0700
Committer: Cao Manh Dat <da...@apache.org>
Committed: Mon Jun 12 10:32:45 2017 +0700

----------------------------------------------------------------------
 .../java/org/apache/solr/api/V2HttpCall.java    | 11 ++++-
 .../solr/handler/V2ApiIntegrationTest.java      |  8 ++++
 .../apache/solr/handler/V2StandaloneTest.java   | 49 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6075956b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
index baf4abc..da2781e 100644
--- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
+++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
@@ -80,8 +80,15 @@ public class V2HttpCall extends HttpSolrCall {
     try {
       pieces = getPathSegments(path);
       if (pieces.size() == 0) {
-        prefix = "c";
-        path = "/c";
+        api = new Api(null) {
+          @Override
+          public void call(SolrQueryRequest req, SolrQueryResponse rsp) {
+            rsp.add("documentation", "https://cwiki.apache.org/confluence/display/solr/v2+API");
+            rsp.add("description", "V2 API root path");
+          }
+        };
+        initAdminRequest(path);
+        return;
       } else {
         prefix = pieces.get(0);
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6075956b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java
index 70b7f8a..4741ef4 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java
@@ -52,6 +52,14 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase {
   }
 
   @Test
+  public void testWelcomeMessage() throws Exception {
+    NamedList res = cluster.getSolrClient().request(
+        new V2Request.Builder("").build());
+    NamedList header = (NamedList) res.get("responseHeader");
+    assertEquals(0, header.get("status"));
+  }
+
+  @Test
   public void testIntrospect() throws Exception {
     ModifiableSolrParams params = new ModifiableSolrParams();
     params.set("command","XXXX");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6075956b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java
new file mode 100644
index 0000000..2d5b2a9
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.solr.handler;
+
+import java.io.File;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.common.util.NamedList;
+import org.junit.Test;
+
+public class V2StandaloneTest extends SolrTestCaseJ4{
+
+  @Test
+  public void testWelcomeMessage() throws Exception {
+    File solrHomeTmp = createTempDir().toFile().getAbsoluteFile();
+    FileUtils.copyDirectory(new File(TEST_HOME(), "configsets/minimal/conf"), new File(solrHomeTmp,"/conf"));
+    FileUtils.copyFile(new File(TEST_HOME(), "solr.xml"), new File(solrHomeTmp, "solr.xml"));
+
+    JettySolrRunner jetty = new JettySolrRunner(solrHomeTmp.getAbsolutePath(), buildJettyConfig("/solr"));
+    jetty.start();
+
+    try (HttpSolrClient client = getHttpSolrClient(buildUrl(jetty.getLocalPort(),"/solr/"))) {
+      NamedList res = client.request(new V2Request.Builder("/").build());
+      NamedList header = (NamedList) res.get("responseHeader");
+      assertEquals(0, header.get("status"));
+    }
+
+    jetty.stop();
+  }
+}