mirror of https://github.com/apache/lucene.git
SOLR-12527: factor out a test-framework/ConfigRequest class
This commit is contained in:
parent
1a4b1358ea
commit
a444e82bab
|
@ -157,6 +157,8 @@ Other Changes
|
|||
|
||||
* SOLR-12468: Upgrade Jetty to 9.4.11.v20180605 (Michael Braun, shalin)
|
||||
|
||||
* SOLR-12527: factor out a test-framework/ConfigRequest class (Christine Poerschke)
|
||||
|
||||
================== 7.4.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -22,22 +22,16 @@ import java.util.Set;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
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.SolrResponse;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.RequestWriter;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.SolrResponseBase;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.cloud.CollectionStatePredicate;
|
||||
import org.apache.solr.common.cloud.CollectionStateWatcher;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrEventListener;
|
||||
|
@ -52,8 +46,6 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JSON_MIME;
|
||||
|
||||
/**
|
||||
* Tests related to SOLR-6086
|
||||
*/
|
||||
|
@ -108,7 +100,7 @@ public class TestCloudSearcherWarming extends SolrCloudTestCase {
|
|||
"'add-listener' : {'name':'firstSearcherListener','event':'firstSearcher', 'class':'" + SleepingSolrEventListener.class.getName() + "'}" +
|
||||
"}";
|
||||
|
||||
ConfigRequest request = new ConfigRequest(SolrRequest.METHOD.POST, "/config", addListenerCommand);
|
||||
ConfigRequest request = new ConfigRequest(addListenerCommand);
|
||||
solrClient.request(request);
|
||||
|
||||
solrClient.add(new SolrInputDocument("id", "1"));
|
||||
|
@ -147,7 +139,7 @@ public class TestCloudSearcherWarming extends SolrCloudTestCase {
|
|||
"'add-listener' : {'name':'firstSearcherListener','event':'firstSearcher', 'class':'" + SleepingSolrEventListener.class.getName() + "'}" +
|
||||
"}";
|
||||
|
||||
ConfigRequest request = new ConfigRequest(SolrRequest.METHOD.POST, "/config", addListenerCommand);
|
||||
ConfigRequest request = new ConfigRequest(addListenerCommand);
|
||||
solrClient.request(request);
|
||||
|
||||
solrClient.add(new SolrInputDocument("id", "1"));
|
||||
|
@ -328,33 +320,4 @@ public class TestCloudSearcherWarming extends SolrCloudTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfigRequest extends SolrRequest {
|
||||
protected final String message;
|
||||
|
||||
public ConfigRequest(METHOD m, String path, String message) {
|
||||
super(m, path);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public Collection<ContentStream> getContentStreams() throws IOException {
|
||||
return message != null ? Collections.singletonList(new ContentStreamBase.StringStream(message)) : null;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
|
||||
return message == null? null: new RequestWriter.StringPayloadContentWriter(message, JSON_MIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SolrResponse createResponse(SolrClient client) {
|
||||
return new SolrResponseBase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,13 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.cloud.AbstractDistribZkTestBase;
|
||||
import org.apache.solr.cloud.ConfigRequest;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.cloud.TestCloudSearcherWarming.ConfigRequest;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.highlight.SolrFragmentsBuilder;
|
||||
|
@ -145,8 +144,6 @@ public class CustomHighlightComponentTest extends SolrCloudTestCase {
|
|||
highlightComponentName = "customhighlight"+random().nextInt();
|
||||
cluster.getSolrClient().request(
|
||||
new ConfigRequest(
|
||||
SolrRequest.METHOD.POST,
|
||||
"/config",
|
||||
"{\n" +
|
||||
" 'add-searchcomponent': {\n" +
|
||||
" 'name': '"+highlightComponentName+"',\n" +
|
||||
|
@ -158,8 +155,6 @@ public class CustomHighlightComponentTest extends SolrCloudTestCase {
|
|||
// handler
|
||||
cluster.getSolrClient().request(
|
||||
new ConfigRequest(
|
||||
SolrRequest.METHOD.POST,
|
||||
"/config",
|
||||
"{\n" +
|
||||
" 'add-requesthandler': {\n" +
|
||||
" 'name' : '"+customSearchHandlerName+"',\n" +
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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.cloud;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.client.solrj.request.RequestWriter;
|
||||
import org.apache.solr.client.solrj.response.SolrResponseBase;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
/**
|
||||
* A class for making a request to the config handler. Tests can use this
|
||||
* e.g. to add custom components, handlers, parsers, etc. to an otherwise
|
||||
* generic configset.
|
||||
*/
|
||||
public class ConfigRequest extends SolrRequest {
|
||||
|
||||
protected final String message;
|
||||
|
||||
public ConfigRequest(String message) {
|
||||
super(SolrRequest.METHOD.POST, "/config");
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
|
||||
return message == null? null: new RequestWriter.StringPayloadContentWriter(message, CommonParams.JSON_MIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrResponse createResponse(SolrClient client) {
|
||||
return new SolrResponseBase();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue