From 767bfbcb143a26bf325a00888c350d06a2486662 Mon Sep 17 00:00:00 2001 From: abhidemon Date: Wed, 10 Jan 2018 01:44:34 +0530 Subject: [PATCH] test: Add test case for ResponseBuilder.isDistributed --- .../handler/component/ResponseBuilder.java | 4 ++ .../solr/handler/ResponseBuilderTest.java | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java index 8e9477b76ede..c36d6a8c5fb4 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java +++ b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java @@ -139,6 +139,10 @@ public ResponseBuilder(SolrQueryRequest req, SolrQueryResponse rsp, List finished; // requests that have received responses from all shards public String shortCircuitedURL; + public boolean isDistributed() { + return this.isDistrib; + } + public int getShardNum(String shard) { for (int i = 0; i < shards.length; i++) { if (shards[i] == shard || shards[i].equals(shard)) return i; diff --git a/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java b/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java new file mode 100644 index 000000000000..e7d1e961f024 --- /dev/null +++ b/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java @@ -0,0 +1,46 @@ +/* + * 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.util.ArrayList; + +import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.handler.component.ResponseBuilder; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.response.SolrQueryResponse; +import org.junit.BeforeClass; + +public class ResponseBuilderTest extends SolrTestCaseJ4 { + + @BeforeClass + public static void beforeClass() throws Exception { + initCore("solrconfig.xml", "schema.xml"); + } + + //This test is being added to verify responseBuilder.isDistributed() Exists. + public void testIsDistrib(){ + + SolrQueryRequest req = req("q", "title:test"); + SolrQueryResponse rsp = new SolrQueryResponse(); + + ResponseBuilder responseBuilder = new ResponseBuilder(req, rsp, new ArrayList<>(0)); + assertFalse(responseBuilder.isDistributed()); + + } + +}