use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class GraphExpressionTest method testGraphHandler.
@Test
public void testGraphHandler() throws Exception {
new UpdateRequest().add(id, "0", "from_s", "bill", "to_s", "jim", "message_t", "Hello jim").add(id, "1", "from_s", "bill", "to_s", "sam", "message_t", "Hello sam").add(id, "2", "from_s", "bill", "to_s", "max", "message_t", "Hello max").add(id, "3", "from_s", "max", "to_s", "kip", "message_t", "Hello kip").add(id, "4", "from_s", "sam", "to_s", "steve", "message_t", "Hello steve").add(id, "5", "from_s", "jim", "to_s", "ann", "message_t", "Hello steve").commit(cluster.getSolrClient(), COLLECTION);
commit();
List<JettySolrRunner> runners = cluster.getJettySolrRunners();
JettySolrRunner runner = runners.get(0);
String url = runner.getBaseUrl().toString();
HttpSolrClient client = getHttpSolrClient(url);
ModifiableSolrParams params = new ModifiableSolrParams();
String expr = "sort(by=\"node asc\", gatherNodes(collection1, " + "walk=\"bill->from_s\"," + "trackTraversal=\"true\"," + "gather=\"to_s\"))";
params.add("expr", expr);
QueryRequest query = new QueryRequest(params);
query.setPath("/collection1/graph");
query.setResponseParser(new InputStreamResponseParser("xml"));
query.setMethod(SolrRequest.METHOD.POST);
NamedList<Object> genericResponse = client.request(query);
InputStream stream = (InputStream) genericResponse.get("stream");
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
String xml = readString(reader);
//Validate the nodes
String error = h.validateXPath(xml, "//graph/node[1][@id ='jim']", "//graph/node[2][@id ='max']", "//graph/node[3][@id ='sam']");
if (error != null) {
throw new Exception(error);
}
//Validate the edges
error = h.validateXPath(xml, "//graph/edge[1][@source ='bill']", "//graph/edge[1][@target ='jim']", "//graph/edge[2][@source ='bill']", "//graph/edge[2][@target ='max']", "//graph/edge[3][@source ='bill']", "//graph/edge[3][@target ='sam']");
if (error != null) {
throw new Exception(error);
}
client.close();
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class SearchHandlerTest method testZkConnected.
@Test
public void testZkConnected() throws Exception {
MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig("/solr"));
final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
try {
assertNotNull(miniCluster.getZkServer());
List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
assertEquals(5, jettys.size());
for (JettySolrRunner jetty : jettys) {
assertTrue(jetty.isRunning());
}
// create collection
String collectionName = "testSolrCloudCollection";
String configName = "solrCloudCollectionConfig";
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1/conf"), configName);
CollectionAdminRequest.createCollection(collectionName, configName, 2, 2).process(miniCluster.getSolrClient());
QueryRequest req = new QueryRequest();
QueryResponse rsp = req.process(cloudSolrClient, collectionName);
assertTrue(rsp.getResponseHeader().getBooleanArg("zkConnected"));
} finally {
miniCluster.shutdown();
}
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class TestDelegationWithHadoopAuth method setupClass.
@BeforeClass
public static void setupClass() throws Exception {
assumeFalse("Hadoop does not work on Windows", Constants.WINDOWS);
// nodes
configureCluster(NUM_SERVERS).withSecurityJson(TEST_PATH().resolve("security").resolve("hadoop_simple_auth_with_delegation.json")).configure();
JettySolrRunner runnerPrimary = cluster.getJettySolrRunners().get(0);
primarySolrClient = new HttpSolrClient.Builder(runnerPrimary.getBaseUrl().toString()).build();
JettySolrRunner runnerSecondary = cluster.getJettySolrRunners().get(1);
secondarySolrClient = new HttpSolrClient.Builder(runnerSecondary.getBaseUrl().toString()).build();
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class BasicAuthStandaloneTest method createJetty.
private JettySolrRunner createJetty(SolrInstance instance) throws Exception {
Properties nodeProperties = new Properties();
nodeProperties.setProperty("solr.data.dir", instance.getDataDir().toString());
JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir().toString(), nodeProperties, buildJettyConfig("/solr"));
jetty.start();
return jetty;
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class BaseDistributedSearchTestCase method createJetty.
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception {
Properties props = new Properties();
if (solrConfigOverride != null)
props.setProperty("solrconfig", solrConfigOverride);
if (schemaOverride != null)
props.setProperty("schema", schemaOverride);
if (shardList != null)
props.setProperty("shards", shardList);
if (dataDir != null) {
props.setProperty("solr.data.dir", dataDir);
}
if (explicitCoreNodeName) {
props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
}
props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, JettyConfig.builder().stopAtShutdown(true).setContext(context).withFilters(getExtraRequestFilters()).withServlets(getExtraServlets()).withSSLConfig(sslConfig).build());
jetty.start();
return jetty;
}
Aggregations