From e826b1f3446cf5ac2e95b205dfec442f6719ec25 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Thu, 22 Oct 2020 12:35:47 +1100 Subject: [PATCH] refactor method names --- .../solr/packagemanager/PackageManager.java | 3 +- .../solr/packagemanager/PackageUtils.java | 3 +- .../packagemanager/RepositoryManager.java | 3 +- .../solr/cloud/AliasIntegrationTest.java | 3 +- .../solr/cloud/CollectionsAPISolrJTest.java | 17 ++++----- .../filestore/TestDistribPackageStore.java | 6 +-- .../solr/handler/TestContainerPlugin.java | 37 +++++++++---------- .../solr/handler/V2ApiIntegrationTest.java | 11 +++--- .../org/apache/solr/pkg/TestPackages.java | 30 +++++++-------- .../security/BasicAuthIntegrationTest.java | 2 +- .../RoutedAliasUpdateProcessorTest.java | 5 +-- .../solr/client/solrj/request/V2Request.java | 20 ++++++++++ .../client/solrj/request/TestV2Request.java | 15 ++++---- 13 files changed, 84 insertions(+), 71 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java index 6f2f618f85d..cd802c68828 100644 --- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java +++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java @@ -37,7 +37,6 @@ import java.util.stream.Collectors; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.HashSetValuedHashMap; import org.apache.http.client.methods.HttpDelete; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.request.V2Request; @@ -129,7 +128,7 @@ public class PackageManager implements Closeable { V2Request req = new V2Request.Builder(PackageUtils.PACKAGE_PATH) .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("delete", del)) .build(); diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageUtils.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageUtils.java index d5220c00ef1..5f0c0936173 100644 --- a/solr/core/src/java/org/apache/solr/packagemanager/PackageUtils.java +++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageUtils.java @@ -31,7 +31,6 @@ import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.lucene.util.SuppressForbidden; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.request.V2Request; @@ -96,7 +95,7 @@ public class PackageUtils { params.add("sig", sig); } V2Response rsp = new V2Request.Builder(resource) - .withMethod(SolrRequest.METHOD.PUT) + .PUT() .withPayload(buffer) .forceV2(true) .withMimeType("application/octet-stream") diff --git a/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java b/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java index b5c371eb079..58a8d0f597c 100644 --- a/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java +++ b/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java @@ -38,7 +38,6 @@ import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.lucene.util.Version; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.request.V2Request; @@ -207,7 +206,7 @@ public class RepositoryManager { V2Request req = new V2Request.Builder(PackageUtils.PACKAGE_PATH) .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("add", add)) .build(); diff --git a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java index 0acb7e89a7a..212a5afb140 100644 --- a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java @@ -33,7 +33,6 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import org.apache.lucene.util.IOUtils; import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.cloud.SolrCloudManager; import org.apache.solr.client.solrj.embedded.JettySolrRunner; @@ -708,7 +707,7 @@ public class AliasIntegrationTest extends SolrCloudTestCase { /////////////// // use v2 API new V2Request.Builder("/collections") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{\"create-alias\": {\"name\": \"testalias6\", collections:[\"collection2\",\"collection1\"]}}") .build().process(cluster.getSolrClient()); diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java index c4fc4e4d5b3..e8352cd8ad9 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -41,7 +41,6 @@ import com.google.common.collect.ImmutableList; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.TestUtil; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -134,7 +133,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { String COLL_NAME = "CollWithDefaultClusterProperties"; try { V2Response rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{collectionDefaults:{numShards : 2 , nrtReplicas : 2}}}") .build() .process(cluster.getSolrClient()); @@ -167,7 +166,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { // unset only a single value using old format rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{\n" + " \"set-obj-property\": {\n" + " \"collectionDefaults\": {\n" + @@ -190,7 +189,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { // delete all defaults the old way rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{collectionDefaults:null}}") .build() .process(cluster.getSolrClient()); @@ -206,7 +205,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { } finally { // clean up in case there was an exception during the test V2Response rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{collectionDefaults: null}}") .build() .process(cluster.getSolrClient()); @@ -219,7 +218,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { String COLL_NAME = "CollWithDefaultClusterProperties"; try { V2Response rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{defaults : {collection:{numShards : 2 , nrtReplicas : 2}}}}") .build() .process(cluster.getSolrClient()); @@ -251,7 +250,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { // unset only a single value rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{\n" + " \"set-obj-property\": {\n" + " \"defaults\" : {\n" + @@ -272,7 +271,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { assertNull(clusterProperty); rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{defaults: {collection:null}}}") .build() .process(cluster.getSolrClient()); @@ -287,7 +286,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { assertNull(clusterProperty); } finally { V2Response rsp = new V2Request.Builder("/cluster") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{set-obj-property:{defaults: null}}") .build() .process(cluster.getSolrClient()); diff --git a/solr/core/src/test/org/apache/solr/filestore/TestDistribPackageStore.java b/solr/core/src/test/org/apache/solr/filestore/TestDistribPackageStore.java index f6930d064df..d6ef63dd06d 100644 --- a/solr/core/src/test/org/apache/solr/filestore/TestDistribPackageStore.java +++ b/solr/core/src/test/org/apache/solr/filestore/TestDistribPackageStore.java @@ -101,7 +101,7 @@ public class TestDistribPackageStore extends SolrCloudTestCase { assertResponseValues(10, cluster.getSolrClient(), new V2Request.Builder("/node/files/package/mypkg/v1.0") - .withMethod(SolrRequest.METHOD.GET) + .GET() .build(), Utils.makeMap( ":files:/package/mypkg/v1.0[0]:name", "runtimelibs.jar", @@ -113,7 +113,7 @@ public class TestDistribPackageStore extends SolrCloudTestCase { assertResponseValues(10, cluster.getSolrClient(), new V2Request.Builder("/node/files/package/mypkg") - .withMethod(SolrRequest.METHOD.GET) + .GET() .build(), Utils.makeMap( ":files:/package/mypkg[0]:name", "v1.0", @@ -278,7 +278,7 @@ public class TestDistribPackageStore extends SolrCloudTestCase { ModifiableSolrParams params = new ModifiableSolrParams(); params.add("sig", sig); V2Response rsp = new V2Request.Builder(resource) - .withMethod(SolrRequest.METHOD.PUT) + .PUT() .withPayload(buffer) .forceV2(true) .withMimeType("application/octet-stream") 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 6f7a18a54d9..72b59a8c5e2 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java +++ b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java @@ -58,7 +58,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; @@ -88,7 +87,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"); @@ -107,7 +106,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)); @@ -116,13 +115,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() @@ -147,19 +146,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() @@ -167,12 +166,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())); @@ -184,7 +183,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)); @@ -241,7 +240,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()); @@ -258,14 +257,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) + () -> new V2Request.Builder("/cluster/plugin") + .GET() .build().process(cluster.getSolrClient()), ImmutableMap.of( "/plugin/myplugin/class", plugin.klass, @@ -274,7 +273,7 @@ public class TestContainerPlugin extends SolrCloudTestCase { //let's test this now Callable invokePlugin = () -> new V2Request.Builder("/plugin/my/path") .forceV2(true) - .withMethod(GET) + .GET() .build().process(cluster.getSolrClient()); TestDistribPackageStore.assertResponseValues(10, invokePlugin, @@ -289,15 +288,15 @@ public class TestContainerPlugin extends SolrCloudTestCase { plugin.version = add.version; new V2Request.Builder("/cluster/plugin") .forceV2(true) - .withMethod(POST) + .GET() .withPayload(singletonMap("update", plugin)) .build() .process(cluster.getSolrClient()); //now verify if it is indeed updated TestDistribPackageStore.assertResponseValues(10, - () -> new V2Request.Builder("/cluster/plugin"). - withMethod(GET) + () -> new V2Request.Builder("/cluster/plugin") + .GET() .build().process(cluster.getSolrClient()), ImmutableMap.of( "/plugin/myplugin/class", plugin.klass, 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 6fc1a8e1d9f..179277e6b5f 100644 --- a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java @@ -18,7 +18,6 @@ package org.apache.solr.handler; import org.apache.solr.client.solrj.ResponseParser; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.*; import org.apache.solr.client.solrj.request.CollectionAdminRequest; @@ -63,7 +62,7 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase { private void testException(ResponseParser responseParser, int expectedCode, String path, String payload) throws IOException, SolrServerException { V2Request v2Request = new V2Request.Builder(path) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(payload) .build(); v2Request.setResponseParser(responseParser); @@ -150,10 +149,12 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase { public void testSetPropertyValidationOfCluster() throws IOException, SolrServerException { @SuppressWarnings({"rawtypes"}) NamedList resp = cluster.getSolrClient().request( - new V2Request.Builder("/cluster").withMethod(SolrRequest.METHOD.POST).withPayload("{set-property: {name: maxCoresPerNode, val:42}}").build()); + new V2Request.Builder("/cluster") + .POST() + .withPayload("{set-property: {name: maxCoresPerNode, val:42}}").build()); assertTrue(resp.toString().contains("status=0")); resp = cluster.getSolrClient().request( - new V2Request.Builder("/cluster").withMethod(SolrRequest.METHOD.POST).withPayload("{set-property: {name: maxCoresPerNode, val:null}}").build()); + new V2Request.Builder("/cluster").POST().withPayload("{set-property: {name: maxCoresPerNode, val:null}}").build()); assertTrue(resp.toString().contains("status=0")); } @@ -174,7 +175,7 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase { backupParams.put("location", tempDir); cluster.getJettySolrRunners().forEach(j -> j.getCoreContainer().getAllowPaths().add(Paths.get(tempDir))); client.request(new V2Request.Builder("/c") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Utils.toJSONString(backupPayload)) .build()); } diff --git a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java index bea5d0c1104..38a28023b49 100644 --- a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java +++ b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java @@ -135,7 +135,7 @@ public class TestPackages extends SolrCloudTestCase { add.files = Arrays.asList(new String[]{FILE1, URP1, EXPR1}); V2Request req = new V2Request.Builder("/cluster/package") .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("add", add)) .build(); @@ -148,8 +148,8 @@ public class TestPackages extends SolrCloudTestCase { cluster.waitForActiveCollection(COLLECTION_NAME, 2, 4); TestDistribPackageStore.assertResponseValues(10, - () -> new V2Request.Builder("/cluster/package"). - withMethod(SolrRequest.METHOD.GET) + () -> new V2Request.Builder("/cluster/package") + .GET() .build().process(cluster.getSolrClient()), Utils.makeMap( ":result:packages:mypkg[0]:version", "1.0", @@ -183,7 +183,7 @@ public class TestPackages extends SolrCloudTestCase { V2Request v2r = new V2Request.Builder( "/c/"+COLLECTION_NAME+ "/config") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(plugins) .forceV2(true) .build(); @@ -319,7 +319,7 @@ public class TestPackages extends SolrCloudTestCase { delVersion.pkg = "mypkg"; delVersion.version = "1.0"; V2Request delete = new V2Request.Builder("/cluster/package") - .withMethod(SolrRequest.METHOD.POST) + .POST() .forceV2(true) .withPayload(Collections.singletonMap("delete", delVersion)) .build(); @@ -393,7 +393,7 @@ public class TestPackages extends SolrCloudTestCase { //now, let's force every collection using 'mypkg' to refresh //so that it uses version 2.1 new V2Request.Builder("/cluster/package") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{refresh : mypkg}") .forceV2(true) .build() @@ -424,7 +424,7 @@ public class TestPackages extends SolrCloudTestCase { plugins.put("create-queryparser", p); v2r = new V2Request.Builder( "/c/"+COLLECTION_NAME+ "/config") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(plugins) .forceV2(true) .build(); @@ -500,7 +500,7 @@ public class TestPackages extends SolrCloudTestCase { add.files = Arrays.asList(new String[]{FILE1, FILE2}); V2Request req = new V2Request.Builder("/cluster/package") .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("add", add)) .build(); @@ -569,7 +569,7 @@ public class TestPackages extends SolrCloudTestCase { delVersion.pkg = "test_pkg"; req = new V2Request.Builder("/cluster/package") .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("delete", delVersion)) .build(); @@ -669,14 +669,14 @@ public class TestPackages extends SolrCloudTestCase { add.files = Arrays.asList(FILE1,FILE2); V2Request req = new V2Request.Builder("/cluster/package") .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("add", add)) .build(); req.process(cluster.getSolrClient()); TestDistribPackageStore.assertResponseValues(10, - () -> new V2Request.Builder("/cluster/package"). - withMethod(SolrRequest.METHOD.GET) + () -> new V2Request.Builder("/cluster/package") + .GET() .build().process(cluster.getSolrClient()), Utils.makeMap( ":result:packages:schemapkg[0]:version", "1.0", @@ -699,14 +699,14 @@ public class TestPackages extends SolrCloudTestCase { add.files = Arrays.asList(FILE1); req = new V2Request.Builder("/cluster/package") .forceV2(true) - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload(Collections.singletonMap("add", add)) .build(); req.process(cluster.getSolrClient()); TestDistribPackageStore.assertResponseValues(10, - () -> new V2Request.Builder("/cluster/package"). - withMethod(SolrRequest.METHOD.GET) + () -> new V2Request.Builder("/cluster/package") + .GET() .build().process(cluster.getSolrClient()), Utils.makeMap( ":result:packages:schemapkg[0]:version", "2.0", diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java index c23a4f030c9..f39453e41ca 100644 --- a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java @@ -142,7 +142,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase { @SuppressWarnings({"rawtypes"}) final SolrRequest genericReq; if (isUseV2Api) { - genericReq = new V2Request.Builder("/cluster/security/authentication").withMethod(SolrRequest.METHOD.POST).build(); + genericReq = new V2Request.Builder("/cluster/security/authentication").POST().build(); } else { genericReq = new GenericSolrRequest(SolrRequest.METHOD.POST, authcPrefix, new ModifiableSolrParams()); ((GenericSolrRequest)genericReq).setContentWriter(new StringPayloadContentWriter(command, CommonParams.JSON_MIME)); diff --git a/solr/core/src/test/org/apache/solr/update/processor/RoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/RoutedAliasUpdateProcessorTest.java index 906e393c66c..3ba4a033ed1 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/RoutedAliasUpdateProcessorTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/RoutedAliasUpdateProcessorTest.java @@ -30,7 +30,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.stream.Collectors; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -123,7 +122,7 @@ public abstract class RoutedAliasUpdateProcessorTest extends SolrCloudTestCase { Thread.sleep(500); // YUCK but works (beasts 2500x20 ok vs failing in ~500x20 every time) // manipulate the config... checkNoError(getSolrClient().request(new V2Request.Builder("/collections/" + configName + "/config") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{" + " 'set-user-property' : {'update.autoCreateFields':false}," + // no data driven " 'add-updateprocessor' : {" + @@ -141,7 +140,7 @@ public abstract class RoutedAliasUpdateProcessorTest extends SolrCloudTestCase { // only sometimes test with "tolerant" URP: final String urpNames = "inc" + (random().nextBoolean() ? ",tolerant" : ""); checkNoError(getSolrClient().request(new V2Request.Builder("/collections/" + configName + "/config/params") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{" + " 'set' : {" + " '_UPDATE' : {'processor':'" + urpNames + "'}" + 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 932eb6bdd5b..2af8bf76474 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 @@ -160,6 +160,26 @@ public class V2Request extends SolrRequest implements MapWriter { this.resource = resource; } + public Builder GET() { + this.method = METHOD.GET; + return this; + } + + public Builder POST() { + this.method = METHOD.POST; + return this; + } + + public Builder DELETE() { + this.method = METHOD.DELETE; + return this; + } + + public Builder PUT() { + this.method = METHOD.PUT; + return this; + } + public Builder withMethod(METHOD m) { this.method = m; return this; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java index c663e9955f6..55450ad22d8 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java @@ -22,7 +22,6 @@ import java.lang.invoke.MethodHandles; import java.util.List; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.BaseHttpSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient; @@ -51,7 +50,7 @@ public class TestV2Request extends SolrCloudTestCase { public void testApiPathAvailability() throws Exception { V2Response rsp = new V2Request.Builder("/cluster/nodes") .forceV2(true) - .withMethod(SolrRequest.METHOD.GET).build() + .GET().build() .process(cluster.getSolrClient()); @SuppressWarnings({"rawtypes"}) List l = (List) rsp._get("nodes",null); @@ -98,7 +97,7 @@ public class TestV2Request extends SolrCloudTestCase { private void doTest(SolrClient client) throws IOException, SolrServerException { assertSuccess(client, new V2Request.Builder("/collections") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{" + " 'create' : {" + " 'name' : 'test'," + @@ -113,12 +112,12 @@ public class TestV2Request extends SolrCloudTestCase { String requestHandlerName = "/x" + random().nextInt(); assertSuccess(client, new V2Request.Builder("/c/test/config") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{'create-requesthandler' : { 'name' : '" + requestHandlerName + "', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}}") .build()); - assertSuccess(client, new V2Request.Builder("/c/test").withMethod(SolrRequest.METHOD.DELETE).build()); + assertSuccess(client, new V2Request.Builder("/c/test").DELETE().build()); NamedList res = client.request(new V2Request.Builder("/c").build()); @@ -127,7 +126,7 @@ public class TestV2Request extends SolrCloudTestCase { // assertFalse( collections.contains("test")); try{ NamedList res1 = client.request(new V2Request.Builder("/collections") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{" + " 'create' : {" + " 'name' : 'jsontailtest'," + @@ -144,7 +143,7 @@ public class TestV2Request extends SolrCloudTestCase { public void testV2Forwarding() throws Exception { SolrClient client = cluster.getSolrClient(); assertSuccess(client, new V2Request.Builder("/collections") - .withMethod(SolrRequest.METHOD.POST) + .POST() .withPayload("{" + " 'create' : {" + " 'name' : 'v2forward'," + @@ -168,7 +167,7 @@ public class TestV2Request extends SolrCloudTestCase { String testServer = cluster.getSolrClient().getZkStateReader().getBaseUrlForNodeName(testNode[0]); V2Request v2r = new V2Request.Builder("/c/v2forward/_introspect") - .withMethod(SolrRequest.METHOD.GET).build(); + .GET().build(); try(HttpSolrClient client1 = new HttpSolrClient.Builder() .withBaseSolrUrl(testServer)