コード例 #1
0
  @Test
  public void testCreateAndClear() throws Exception {
    AccumuloGraphConfiguration cfg =
        AccumuloGraphTestUtils.generateGraphConfig("noCreate").setCreate(false);
    try {
      new AccumuloGraph(cfg);
      fail("Create is disabled and graph does not exist");
    } catch (Exception e) {
      assertTrue(true);
    }

    cfg = AccumuloGraphTestUtils.generateGraphConfig("yesCreate").setCreate(true);
    for (String t : cfg.getTableNames()) {
      assertFalse(cfg.getConnector().tableOperations().exists(t));
    }
    AccumuloGraph graph = new AccumuloGraph(cfg);
    for (String t : cfg.getTableNames()) {
      assertTrue(cfg.getConnector().tableOperations().exists(t));
    }
    graph.shutdown();

    graph = new AccumuloGraph(cfg.clone().setCreate(false));
    assertTrue(graph.isEmpty());
    graph.addVertex("A");
    graph.addVertex("B");
    assertFalse(graph.isEmpty());
    graph.shutdown();

    graph = new AccumuloGraph(cfg.clone().setClear(true));
    assertTrue(graph.isEmpty());
    graph.shutdown();
  }