You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:53:50 UTC
[lucene] 04/08: cleanup
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch jira/solr14977
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 196d610783315930963558963eedfdc1ca1df252
Author: noblepaul <no...@gmail.com>
AuthorDate: Mon Nov 9 11:44:34 2020 +1100
cleanup
---
.../apache/solr/handler/TestContainerPlugin.java | 37 +++++++++++-----------
.../solr/client/solrj/request/V2Request.java | 20 ++++++++++++
2 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
index 5bf3375..7f9a927 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
@@ -61,7 +61,6 @@ import org.junit.Test;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
-import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
import static org.apache.solr.filestore.TestDistribPackageStore.readFile;
import static org.apache.solr.filestore.TestDistribPackageStore.uploadKey;
@@ -91,7 +90,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
//test with an invalid class
V2Request req = new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(POST)
+ .POST()
.withPayload(singletonMap("add", plugin))
.build();
expectError(req, cluster.getSolrClient(), errPath, "No method with @Command in class");
@@ -103,7 +102,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
//just check if the plugin is indeed registered
V2Request readPluginState = new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build();
V2Response rsp = readPluginState.process(cluster.getSolrClient());
assertEquals(C3.class.getName(), rsp._getStr("/plugin/testplugin/class", null));
@@ -112,13 +111,13 @@ public class TestContainerPlugin extends SolrCloudTestCase {
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("/plugin/my/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of("/testkey", "testval"));
//now remove the plugin
new V2Request.Builder("/cluster/plugin")
- .withMethod(POST)
+ .POST()
.forceV2(true)
.withPayload("{remove : testplugin}")
.build()
@@ -143,19 +142,19 @@ public class TestContainerPlugin extends SolrCloudTestCase {
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("/my-random-name/my/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of("/method.name", "m1"));
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("/my-random-prefix/their/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of("/method.name", "m2"));
//now remove the plugin
new V2Request.Builder("/cluster/plugin")
- .withMethod(POST)
+ .POST()
.forceV2(true)
.withPayload("{remove : my-random-name}")
.build()
@@ -163,12 +162,12 @@ public class TestContainerPlugin extends SolrCloudTestCase {
expectFail( () -> new V2Request.Builder("/my-random-prefix/their/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build()
.process(cluster.getSolrClient()));
expectFail(() -> new V2Request.Builder("/my-random-prefix/their/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build()
.process(cluster.getSolrClient()));
@@ -180,7 +179,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
//just check if the plugin is indeed registered
readPluginState = new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build();
rsp = readPluginState.process(cluster.getSolrClient());
assertEquals(C6.class.getName(), rsp._getStr("/plugin/clusterSingleton/class", null));
@@ -202,14 +201,14 @@ public class TestContainerPlugin extends SolrCloudTestCase {
new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(POST)
+ .POST()
.withPayload(singletonMap("add", p))
.build()
.process(cluster.getSolrClient());
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("hello/plugin")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of("/config/boolVal", "true", "/config/strVal", "Something","/config/longVal", "1234" ));
@@ -263,7 +262,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
add.files = singletonList(FILE1);
V2Request addPkgVersionReq = new V2Request.Builder("/cluster/package")
.forceV2(true)
- .withMethod(POST)
+ .POST()
.withPayload(singletonMap("add", add))
.build();
addPkgVersionReq.process(cluster.getSolrClient());
@@ -280,14 +279,14 @@ public class TestContainerPlugin extends SolrCloudTestCase {
plugin.version = add.version;
final V2Request req1 = new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(POST)
+ .POST()
.withPayload(singletonMap("add", plugin))
.build();
req1.process(cluster.getSolrClient());
//verify the plugin creation
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("/cluster/plugin").
- withMethod(GET)
+ GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of(
"/plugin/myplugin/class", plugin.klass,
@@ -296,7 +295,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
//let's test this now
Callable<NavigableObject> invokePlugin = () -> new V2Request.Builder("/plugin/my/path")
.forceV2(true)
- .withMethod(GET)
+ .GET()
.build().process(cluster.getSolrClient());
TestDistribPackageStore.assertResponseValues(10,
invokePlugin,
@@ -311,7 +310,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
plugin.version = add.version;
new V2Request.Builder("/cluster/plugin")
.forceV2(true)
- .withMethod(POST)
+ .POST()
.withPayload(singletonMap("update", plugin))
.build()
.process(cluster.getSolrClient());
@@ -319,7 +318,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {
//now verify if it is indeed updated
TestDistribPackageStore.assertResponseValues(10,
() -> new V2Request.Builder("/cluster/plugin").
- withMethod(GET)
+ GET()
.build().process(cluster.getSolrClient()),
ImmutableMap.of(
"/plugin/myplugin/class", plugin.klass,
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
index 932eb6b..fda9ed3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
@@ -165,6 +165,26 @@ public class V2Request extends SolrRequest<V2Response> implements MapWriter {
return this;
}
+ public Builder POST() {
+ this.method = METHOD.POST;
+ return this;
+ }
+
+ public Builder GET() {
+ this.method = METHOD.GET;
+ return this;
+ }
+
+ public Builder PUT() {
+ this.method = METHOD.PUT;
+ return this;
+ }
+
+ public Builder DELETE() {
+ this.method = METHOD.DELETE;
+ return this;
+ }
+
/**
* Only for testing. It's always true otherwise
*/