Apache Solr open-source search software
SOLR-10715: /v2/ should not be an alias for /v2/collections
Cao Manh Dat6075956b65ab
diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.javaindex baf4abc9972..da2781e967b 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);}diff --git a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.javaindex 70b7f8a9757..4741ef4edac 100644--- a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java@@ -51,6 +51,14 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase {.process(cluster.getSolrClient());}+ @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"));+ }+@Testpublic void testIntrospect() throws Exception {ModifiableSolrParams params = new ModifiableSolrParams();diff --git a/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.javanew file mode 100644index 00000000000..2d5b2a96fa1--- /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();+ }+}