use of org.apache.solr.util.RESTfulServerProvider in project lucene-solr by apache.
the class TestBulkSchemaAPI method before.
@Before
public void before() throws Exception {
tmpSolrHome = createTempDir().toFile();
FileUtils.copyDirectory(new File(TEST_HOME()), tmpSolrHome.getAbsoluteFile());
System.setProperty("managed.schema.mutable", "true");
System.setProperty("enable.update.log", "false");
createJettyAndHarness(tmpSolrHome.getAbsolutePath(), "solrconfig-managed-schema.xml", "schema-rest.xml", "/solr", true, null);
if (random().nextBoolean()) {
log.info("These tests are run with V2 API");
restTestHarness.setServerProvider(new RESTfulServerProvider() {
@Override
public String getBaseURL() {
return jetty.getBaseUrl().toString() + "/____v2/cores/" + DEFAULT_TEST_CORENAME;
}
});
}
}
use of org.apache.solr.util.RESTfulServerProvider in project lucene-solr by apache.
the class TestSolrConfigHandler method testReqParams.
public void testReqParams() throws Exception {
RestTestHarness harness = restTestHarness;
String payload = " {\n" + " 'set' : {'x': {" + " 'a':'A val',\n" + " 'b': 'B val'}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "x", "a"), "A val", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "x", "b"), "B val", 10);
payload = "{\n" + "'create-requesthandler' : { 'name' : '/d', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/overlay?wt=json", null, Arrays.asList("overlay", "requestHandler", "/d", "name"), "/d", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/d?wt=json&useParams=x", null, Arrays.asList("params", "a"), "A val", 5);
TestSolrConfigHandler.testForResponseElement(harness, null, "/d?wt=json&useParams=x&a=fomrequest", null, Arrays.asList("params", "a"), "fomrequest", 5);
payload = "{\n" + "'create-requesthandler' : { 'name' : '/dump1', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/overlay?wt=json", null, Arrays.asList("overlay", "requestHandler", "/dump1", "name"), "/dump1", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/dump1?wt=json", null, Arrays.asList("params", "a"), "A val", 5);
payload = " {\n" + " 'set' : {'y':{\n" + " 'c':'CY val',\n" + " 'b': 'BY val', " + " 'd': ['val 1', 'val 2']}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "c"), "CY val", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/dump1?wt=json&useParams=y", null, Arrays.asList("params", "c"), "CY val", 5);
TestSolrConfigHandler.testForResponseElement(harness, null, "/dump1?wt=json&useParams=y", null, Arrays.asList("params", "b"), "BY val", 5);
TestSolrConfigHandler.testForResponseElement(harness, null, "/dump1?wt=json&useParams=y", null, Arrays.asList("params", "a"), "A val", 5);
TestSolrConfigHandler.testForResponseElement(harness, null, "/dump1?wt=json&useParams=y", null, Arrays.asList("params", "d"), Arrays.asList("val 1", "val 2"), 5);
payload = " {\n" + " 'update' : {'y': {\n" + " 'c':'CY val modified',\n" + " 'e':'EY val',\n" + " 'b': 'BY val'" + "}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "c"), "CY val modified", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "e"), "EY val", 10);
payload = " {\n" + " 'set' : {'y': {\n" + " 'p':'P val',\n" + " 'q': 'Q val'" + "}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "p"), "P val", 10);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "c"), null, 10);
payload = " {'delete' : 'y'}";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/params?wt=json", null, Arrays.asList("response", "params", "y", "p"), null, 10);
payload = "{\n" + " 'create-requesthandler': {\n" + " 'name': 'aRequestHandler',\n" + " 'registerPath': '/v2',\n" + " 'class': 'org.apache.solr.handler.DumpRequestHandler',\n" + " 'spec': {\n" + " 'methods': [\n" + " 'GET',\n" + " 'POST'\n" + " ],\n" + " 'url': {\n" + " 'paths': [\n" + " '/something/{part1}/fixed/{part2}'\n" + " ]\n" + " }\n" + " }\n" + " }\n" + "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(harness, null, "/config/overlay?wt=json", null, Arrays.asList("overlay", "requestHandler", "aRequestHandler", "class"), "org.apache.solr.handler.DumpRequestHandler", 10);
RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
restTestHarness.setServerProvider(() -> jetty.getBaseUrl().toString() + "/____v2/cores/" + DEFAULT_TEST_CORENAME);
Map rsp = TestSolrConfigHandler.testForResponseElement(harness, null, "/something/part1_Value/fixed/part2_Value?urlTemplateValues=part1&urlTemplateValues=part2", null, Arrays.asList("urlTemplateValues"), new ValidatingJsonMap.PredicateWithErrMsg() {
@Override
public String test(Object o) {
if (o instanceof Map) {
Map m = (Map) o;
if ("part1_Value".equals(m.get("part1")) && "part2_Value".equals(m.get("part2")))
return null;
}
return "no match";
}
@Override
public String toString() {
return "{part1:part1_Value, part2 : part2_Value]";
}
}, 10);
restTestHarness.setServerProvider(oldProvider);
}
Aggregations