public void testHost() { HttpClient client = new HttpClientConfigurator().host("bob").getClient(); DefaultRoutePlanner routePlanner = getRoutePlanner(client); assertThat(routePlanner).isInstanceOf(HttpClientConfigurator.DefaultHostRoutePlanner.class); assertEquals(((HttpClientConfigurator.DefaultHostRoutePlanner) routePlanner).getDefaultHost().getHostName(), "bob", "Unexpected host."); }
/** * Initilisation procedure for this test case. * * @throws UnableToBuildSolRDFClientException in case the client cannot be built. * @throws Exception in case of Solr startup failure. */ @BeforeClass public static void initITTest() { System.setProperty("tests.asserts", "false"); System.setProperty("jetty.port", "8080"); System.setProperty("solr.core.name", "store"); System.setProperty("solr.data.dir", initCoreDataDir.getAbsolutePath()); try { SOLR = createJetty( "target/solrdf-integration-tests-1.1-dev/solrdf", JettyConfig.builder() .setPort(8080) .setContext("/solr") .stopAtShutdown(true) .build()); final HttpClient httpClient = HttpClientBuilder.create() .setRoutePlanner( new DefaultRoutePlanner( new SchemePortResolver() { @Override public int resolve(final HttpHost host) throws UnsupportedSchemeException { return SOLR.getLocalPort(); } })).build(); SOLRDF_CLIENT = SolRDF.newBuilder() .withEndpoint("http://127.0.0.1:8080/solr/store") .withGraphStoreProtocolEndpointPath("/rdf-graph-store") .withHttpClient(httpClient) .withSPARQLEndpointPath("/sparql") .build(); PLAIN_SOLR_CLIENT = new HttpSolrClient(SOLR_URI); } catch (final Exception exception) { throw new RuntimeException(exception); } }
private DefaultRoutePlanner getRoutePlanner(HttpClient client) { return TestUtils.getField(client, "routePlanner", DefaultRoutePlanner.class); }