Java Code Examples for org.apache.solr.client.solrj.impl.HttpSolrClient#close()

The following examples show how to use org.apache.solr.client.solrj.impl.HttpSolrClient#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZookeeperStatusHandlerTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void monitorZookeeper() throws IOException, SolrServerException, InterruptedException, ExecutionException, TimeoutException {
  URL baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
  HttpSolrClient solr = new HttpSolrClient.Builder(baseUrl.toString()).build();
  GenericSolrRequest mntrReq = new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/zookeeper/status", new ModifiableSolrParams());
  mntrReq.setResponseParser(new DelegationTokenResponse.JsonMapResponseParser());
  NamedList<Object> nl = solr.httpUriRequest(mntrReq).future.get(10000, TimeUnit.MILLISECONDS);

  assertEquals("zkStatus", nl.getName(1));
  @SuppressWarnings({"unchecked"})
  Map<String,Object> zkStatus = (Map<String,Object>) nl.get("zkStatus");
  assertEquals("green", zkStatus.get("status"));
  assertEquals("standalone", zkStatus.get("mode"));
  assertEquals(1L, zkStatus.get("ensembleSize"));
  @SuppressWarnings({"unchecked"})
  List<Object> detailsList = (List<Object>)zkStatus.get("details");
  assertEquals(1, detailsList.size());
  @SuppressWarnings({"unchecked"})
  Map<String,Object> details = (Map<String,Object>) detailsList.get(0);
  assertEquals(true, details.get("ok"));
  assertTrue(Integer.parseInt((String) details.get("zk_znode_count")) > 50);
  solr.close();
}
 
Example 2
Source File: TestV2Request.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
// 12-Jun-2018   @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
  public void testHttpSolrClient() throws Exception {
    HttpSolrClient solrClient = new HttpSolrClient.Builder(
        cluster.getJettySolrRunner(0).getBaseUrl().toString()).build();
    doTest(solrClient);
    solrClient.close();
  }
 
Example 3
Source File: TestDelegationWithHadoopAuth.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Test HttpSolrServer's delegation token support
 */
@Test
public void testDelegationTokenSolrClient() throws Exception {
  // Get token
  String token = getDelegationToken(null, USER_1, primarySolrClient);
  assertNotNull(token);

  @SuppressWarnings({"rawtypes"})
  SolrRequest request = getAdminRequest(new ModifiableSolrParams());

  // test without token
  HttpSolrClient ss =
      new HttpSolrClient.Builder(primarySolrClient.getBaseURL().toString())
          .withResponseParser(primarySolrClient.getParser())
          .build();
  try {
    doSolrRequest(ss, request, ErrorCode.UNAUTHORIZED.code);
  } finally {
    ss.close();
  }

  try (HttpSolrClient client = new HttpSolrClient.Builder(primarySolrClient.getBaseURL())
           .withKerberosDelegationToken(token)
           .withResponseParser(primarySolrClient.getParser())
           .build()) {
    // test with token via property
    doSolrRequest(client, request, HttpStatus.SC_OK);

    // test with param -- should throw an exception
    ModifiableSolrParams tokenParam = new ModifiableSolrParams();
    tokenParam.set("delegation", "invalidToken");
    expectThrows(IllegalArgumentException.class, () -> doSolrRequest(client, getAdminRequest(tokenParam), ErrorCode.FORBIDDEN.code));
  }
}
 
Example 4
Source File: TestCloudJSONFacetJoinDomain.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 5
Source File: TestCloudJSONFacetSKGEquiv.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 6
Source File: TestCloudJSONFacetSKG.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 7
Source File: TestSolrCloudWithDelegationTokens.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Test HttpSolrServer's delegation token support for Update Requests
 */
@Test
public void testDelegationTokenSolrClientWithUpdateRequests() throws Exception {
  String collectionName = "testDelegationTokensWithUpdate";

  // Get token
  String token = getDelegationToken(null, "bar", solrClientPrimary);
  assertNotNull(token);

  // Tests with update request.
  // Before SOLR-13921, the request without commit will fail with a NullpointerException in DelegationTokenHttpSolrClient.createMethod
  // due to a missing null check in the createMethod. (When requesting a commit, the setAction method will call setParams on the
  // request so there is no NPE in the createMethod.)
  final HttpSolrClient scUpdateWToken = new HttpSolrClient.Builder(solrClientPrimary.getBaseURL().toString())
      .withKerberosDelegationToken(token)
      .withResponseParser(solrClientPrimary.getParser())
      .build();

  // Create collection
  CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName, 1, 1);
  create.process(scUpdateWToken);

  try {
    // test update request with token via property and commit=true
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = getUpdateRequest(true);
    doSolrRequest(scUpdateWToken, request, collectionName, HttpStatus.SC_OK);

    // test update request with token via property and commit=false
    request = getUpdateRequest(false);
    doSolrRequest(scUpdateWToken, request, collectionName, HttpStatus.SC_OK);

  } finally {
    scUpdateWToken.close();
  }
}
 
Example 8
Source File: TestCloudPhrasesIdentificationComponent.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 9
Source File: TestCloudPseudoReturnFields.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 10
Source File: TestSolrCloudWithDelegationTokens.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Test HttpSolrServer's delegation token support
 */
@Test
public void testDelegationTokenSolrClient() throws Exception {
  // Get token
  String token = getDelegationToken(null, "bar", solrClientPrimary);
  assertNotNull(token);

  @SuppressWarnings({"rawtypes"})
  SolrRequest request = getAdminRequest(new ModifiableSolrParams());

  // test without token
  final HttpSolrClient ssWoToken =
    new HttpSolrClient.Builder(solrClientPrimary.getBaseURL().toString())
        .withResponseParser(solrClientPrimary.getParser())
        .build();
  try {
    doSolrRequest(ssWoToken, request, ErrorCode.UNAUTHORIZED.code);
  } finally {
    ssWoToken.close();
  }

  final HttpSolrClient ssWToken = new HttpSolrClient.Builder(solrClientPrimary.getBaseURL().toString())
      .withKerberosDelegationToken(token)
      .withResponseParser(solrClientPrimary.getParser())
      .build();
  try {
    // test with token via property
    doSolrRequest(ssWToken, request, HttpStatus.SC_OK);

    // test with param -- should throw an exception
    ModifiableSolrParams tokenParam = new ModifiableSolrParams();
    tokenParam.set("delegation", "invalidToken");
    expectThrows(IllegalArgumentException.class,
        () -> doSolrRequest(ssWToken, getAdminRequest(tokenParam), ErrorCode.FORBIDDEN.code));
  } finally {
    ssWToken.close();
  }
}
 
Example 11
Source File: TestTolerantUpdateProcessorRandomCloud.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void afterClass() throws IOException {
  if (NODE_CLIENTS != null) {
    for (HttpSolrClient client : NODE_CLIENTS) {
      client.close();
    }
  }
  NODE_CLIENTS = null;
  if (CLOUD_CLIENT != null) {
    CLOUD_CLIENT.close();
  }
  CLOUD_CLIENT = null;
}
 
Example 12
Source File: TestRandomFlRTGCloud.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@AfterClass
private static void afterClass() throws Exception {
  if (null != CLOUD_CLIENT) {
    CLOUD_CLIENT.close();
    CLOUD_CLIENT = null;
  }
  for (HttpSolrClient client : CLIENTS) {
    client.close();
  }
  CLIENTS.clear();
}
 
Example 13
Source File: CaseController.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@GetMapping("/solrj")
public String solrj() throws SolrServerException, IOException {
    HttpSolrClient client = getClient();
    add(client);

    commit(client);

    optimize(client);

    search(client);

    get(client);

    deleteById(client);

    deleteByQuery(client);

    client.close();
    return "Success";
}
 
Example 14
Source File: TestSolrCLIRunExample.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
protected void testExample(String exampleName) throws Exception {
  File solrHomeDir = new File(ExternalPaths.SERVER_HOME);
  if (!solrHomeDir.isDirectory())
    fail(solrHomeDir.getAbsolutePath()+" not found and is required to run this test!");

  Path tmpDir = createTempDir();
  File solrExampleDir = tmpDir.toFile();
  File solrServerDir = solrHomeDir.getParentFile();

  for (int pass = 0; pass<2; pass++){
    // need a port to start the example server on
    int bindPort = -1;
    try (ServerSocket socket = new ServerSocket(0)) {
      bindPort = socket.getLocalPort();
    }

    log.info("Selected port {} to start {} example Solr instance on ...", bindPort, exampleName);

    String[] toolArgs = new String[] {
        "-e", exampleName,
        "-serverDir", solrServerDir.getAbsolutePath(),
        "-exampleDir", solrExampleDir.getAbsolutePath(),
        "-p", String.valueOf(bindPort)
    };

    // capture tool output to stdout
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream stdoutSim = new PrintStream(baos, true, StandardCharsets.UTF_8.name());

    RunExampleExecutor executor = new RunExampleExecutor(stdoutSim);
    closeables.add(executor);

    SolrCLI.RunExampleTool tool = new SolrCLI.RunExampleTool(executor, System.in, stdoutSim);
    try {
      int status = tool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(tool.getOptions()), toolArgs));
      
      if (status == -1) {
        // maybe it's the port, try again
        try (ServerSocket socket = new ServerSocket(0)) {
          bindPort = socket.getLocalPort();
        }
        Thread.sleep(100);
        status = tool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(tool.getOptions()), toolArgs));  
      }
      
      assertEquals("it should be ok "+tool+" "+Arrays.toString(toolArgs),0, status);
    } catch (Exception e) {
      log.error("RunExampleTool failed due to: {}; stdout from tool prior to failure: {}"
          , e , baos.toString(StandardCharsets.UTF_8.name())); // logOk
      throw e;
    }

    String toolOutput = baos.toString(StandardCharsets.UTF_8.name());

    // dump all the output written by the SolrCLI commands to stdout
    //System.out.println("\n\n"+toolOutput+"\n\n");

    File exampleSolrHomeDir = new File(solrExampleDir, exampleName+"/solr");
    assertTrue(exampleSolrHomeDir.getAbsolutePath() + " not found! run " +
            exampleName + " example failed; output: " + toolOutput,
        exampleSolrHomeDir.isDirectory());

    if ("techproducts".equals(exampleName)) {
      HttpSolrClient solrClient = getHttpSolrClient("http://localhost:" + bindPort + "/solr/" + exampleName);
      try{
        SolrQuery query = new SolrQuery("*:*");
        QueryResponse qr = solrClient.query(query);
        long numFound = qr.getResults().getNumFound();
        if (numFound == 0) {
          // brief wait in case of timing issue in getting the new docs committed
          log.warn("Going to wait for 1 second before re-trying query for techproduct example docs ...");
          try {
            Thread.sleep(1000);
          } catch (InterruptedException ignore) {
            Thread.interrupted();
          }
          numFound = solrClient.query(query).getResults().getNumFound();
        }
        assertTrue("expected 32 docs in the " + exampleName + " example but found " + numFound + ", output: " + toolOutput,
            numFound == 32);
      }finally{
        solrClient.close();
      }
    }

    // stop the test instance
    executor.execute(org.apache.commons.exec.CommandLine.parse("bin/solr stop -p " + bindPort));
  }
}
 
Example 15
Source File: TestTolerantUpdateProcessorRandomCloud.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void createMiniSolrCloudCluster() throws Exception {
  
  final String configName = "solrCloudCollectionConfig";
  final File configDir = new File(TEST_HOME() + File.separator + "collection1" + File.separator + "conf");

  final int numShards = TestUtil.nextInt(random(), 2, TEST_NIGHTLY ? 5 : 3);
  final int repFactor = TestUtil.nextInt(random(), 2, TEST_NIGHTLY ? 5 : 3);
  // at least one server won't have any replicas
  final int numServers = 1 + (numShards * repFactor);

  log.info("Configuring cluster: servers={}, shards={}, repfactor={}", numServers, numShards, repFactor);
  configureCluster(numServers)
    .addConfig(configName, configDir.toPath())
    .configure();
  
  Map<String, String> collectionProperties = new HashMap<>();
  collectionProperties.put("config", "solrconfig-distrib-update-processor-chains.xml");
  collectionProperties.put("schema", "schema15.xml"); // string id 

  CLOUD_CLIENT = cluster.getSolrClient();
  CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);

  CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, numShards, repFactor)
      .setProperties(collectionProperties)
      .process(CLOUD_CLIENT);

  cluster.waitForActiveCollection(COLLECTION_NAME, numShards, numShards * repFactor);
  
  if (NODE_CLIENTS != null) {
    for (HttpSolrClient client : NODE_CLIENTS) {
      client.close();
    }
  }
  NODE_CLIENTS = new ArrayList<HttpSolrClient>(numServers);
  
  for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
    URL jettyURL = jetty.getBaseUrl();
    NODE_CLIENTS.add(getHttpSolrClient(jettyURL.toString() + "/" + COLLECTION_NAME + "/"));
  }
  assertEquals(numServers, NODE_CLIENTS.size());
  
}
 
Example 16
Source File: DistributedQueryElevationComponentTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
@ShardsFixed(num = 3)
public void test() throws Exception {


  del("*:*");
  indexr(id,"1", "int_i", "1", "text", "XXXX XXXX", "field_t", "anything");
  indexr(id,"2", "int_i", "2", "text", "YYYY YYYY", "plow_t", "rake");
  indexr(id,"3", "int_i", "3", "text", "ZZZZ ZZZZ");
  indexr(id,"4", "int_i", "4", "text", "XXXX XXXX");
  indexr(id,"5", "int_i", "5", "text", "ZZZZ ZZZZ ZZZZ");
  indexr(id,"6", "int_i", "6", "text", "ZZZZ");

  index_specific(2, id, "7", "int_i", "7", "text", "solr");
  commit();

  handle.put("explain", SKIPVAL);
  handle.put("debug", SKIPVAL);
  handle.put("maxScore", SKIPVAL);
  handle.put("timestamp", SKIPVAL);
  handle.put("score", SKIPVAL);
  handle.put("wt", SKIP);
  handle.put("distrib", SKIP);
  handle.put("shards.qt", SKIP);
  handle.put("shards", SKIP);
  handle.put("q", SKIP);
  handle.put("qt", SKIP);
  query("q", "*:*", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", "sort", "id desc", CommonParams.FL, "id, score, [elevated]");

  query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "int_i desc");

  query("q", "solr", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "int_i asc");

  query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "id desc");

  // See SOLR-4854 for background on following test code

  // Uses XML response format by default
  QueryResponse response = query("q", "XXXX", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "id, [elevated]", "enableElevation", "true",
      "forceElevation", "true", "elevateIds", "6", "sort", "id desc");

  assertTrue(response.getResults().getNumFound() > 0);
  SolrDocument document = response.getResults().get(0);
  assertEquals("6", document.getFieldValue("id"));
  assertEquals(true, document.getFieldValue("[elevated]"));

  // Force javabin format
  final String clientUrl = ((HttpSolrClient)clients.get(0)).getBaseURL();
  HttpSolrClient client = getHttpSolrClient(clientUrl);
  client.setParser(new BinaryResponseParser());
  SolrQuery solrQuery = new SolrQuery("XXXX").setParam("qt", "/elevate").setParam("shards.qt", "/elevate").setRows(500).setFields("id,[elevated]")
      .setParam("enableElevation", "true").setParam("forceElevation", "true").setParam("elevateIds", "6", "wt", "javabin")
      .setSort("id", SolrQuery.ORDER.desc);
  setDistributedParams(solrQuery);
  response = client.query(solrQuery);
  client.close();

  assertTrue(response.getResults().getNumFound() > 0);
  document = response.getResults().get(0);
  assertEquals("6", document.getFieldValue("id"));
  assertEquals(true, document.getFieldValue("[elevated]"));
}
 
Example 17
Source File: BasicAuthStandaloneTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasicAuth() throws Exception {

  String authcPrefix = "/admin/authentication";
  String authzPrefix = "/admin/authorization";

  HttpClient cl = null;
  HttpSolrClient httpSolrClient = null;
  try {
    cl = HttpClientUtil.createClient(null);
    String baseUrl = buildUrl(jetty.getLocalPort(), "/solr"); 
    httpSolrClient = getHttpSolrClient(baseUrl);
    
    verifySecurityStatus(cl, baseUrl + authcPrefix, "/errorMessages", null, 20);

    // Write security.json locally. Should cause security to be initialized
    securityConfHandler.persistConf(new SecurityConfHandler.SecurityConfig()
        .setData(Utils.fromJSONString(STD_CONF.replaceAll("'", "\""))));
    securityConfHandler.securityConfEdited();
    verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication/class", "solr.BasicAuthPlugin", 20);

    String command = "{\n" +
        "'set-user': {'harry':'HarryIsCool'}\n" +
        "}";

    doHttpPost(cl, baseUrl + authcPrefix, command, null, null, 401);
    verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication.enabled", "true", 20);

    command = "{\n" +
        "'set-user': {'harry':'HarryIsUberCool'}\n" +
        "}";


    doHttpPost(cl, baseUrl + authcPrefix, command, "solr", "SolrRocks");
    verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication/credentials/harry", NOT_NULL_PREDICATE, 20);

    // Read file from SOLR_HOME and verify that it contains our new user
    assertTrue(new String(Utils.toJSON(securityConfHandler.getSecurityConfig(false).getData()), 
        Charset.forName("UTF-8")).contains("harry"));

    // Edit authorization
    verifySecurityStatus(cl, baseUrl + authzPrefix, "authorization/permissions[1]/role", null, 20);
    doHttpPost(cl, baseUrl + authzPrefix, "{'set-permission': {'name': 'update', 'role':'updaterole'}}", "solr", "SolrRocks");
    command = "{\n" +
        "'set-permission': {'name': 'read', 'role':'solr'}\n" +
        "}";
    doHttpPost(cl, baseUrl + authzPrefix, command, "solr", "SolrRocks");
    try {
      httpSolrClient.query("collection1", new MapSolrParams(Collections.singletonMap("q", "foo")));
      fail("Should return a 401 response");
    } catch (Exception e) {
      // Test that the second doPost request to /security/authorization went through
      verifySecurityStatus(cl, baseUrl + authzPrefix, "authorization/permissions[2]/role", "solr", 20);
    }
  } finally {
    if (cl != null) {
      HttpClientUtil.close(cl);
      httpSolrClient.close();
    }
  }
}
 
Example 18
Source File: GraphExpressionTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@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, StandardCharsets.UTF_8);
  String xml = readString(reader);
  //Validate the nodes
  String error = BaseTestHarness.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 = BaseTestHarness.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();
}