@Before
  public void init()
      throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
          TableExistsException {

    mock = new MockInstance("accumulo");
    PasswordToken pToken = new PasswordToken("pass".getBytes());
    conn = mock.getConnector("user", pToken);

    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);

    if (conn.tableOperations().exists("rya_prospects")) {
      conn.tableOperations().delete("rya_prospects");
    }
    if (conn.tableOperations().exists("rya_selectivity")) {
      conn.tableOperations().delete("rya_selectivity");
    }

    arc = new AccumuloRdfConfiguration();
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);
    res = new ProspectorServiceEvalStatsDAO(conn, arc);
  }
  @Test
  public void visibilitySimplified() throws Exception {
    // Create a PCJ index within Rya.
    final String sparql =
        "SELECT ?customer ?worker ?city "
            + "{ "
            + "?customer <"
            + TALKS_TO
            + "> ?worker. "
            + "?worker <"
            + LIVES_IN
            + "> ?city. "
            + "?worker <"
            + WORKS_AT
            + "> <"
            + BURGER_JOINT
            + ">. "
            + "}";

    final RyaClient ryaClient =
        AccumuloRyaClientFactory.build(
            new AccumuloConnectionDetails(
                ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers),
            accumuloConn);

    final String pcjId = ryaClient.getCreatePCJ().createPCJ(RYA_INSTANCE_NAME, sparql);

    // Grant the root user the "u" authorization.
    accumuloConn
        .securityOperations()
        .changeUserAuthorizations(ACCUMULO_USER, new Authorizations("u"));

    // Setup a connection to the Rya instance that uses the "u" authorizations. This ensures
    // any statements that are inserted will have the "u" authorization on them and that the
    // PCJ updating application will have to maintain visibilities.
    final AccumuloRdfConfiguration ryaConf = super.makeConfig(instanceName, zookeepers);
    ryaConf.set(ConfigUtils.CLOUDBASE_AUTHS, "u");
    ryaConf.set(RdfCloudTripleStoreConfiguration.CONF_CV, "u");

    Sail sail = null;
    RyaSailRepository ryaRepo = null;
    RepositoryConnection ryaConn = null;

    try {
      sail = RyaSailFactory.getInstance(ryaConf);
      ryaRepo = new RyaSailRepository(sail);
      ryaConn = ryaRepo.getConnection();

      // Load a few Statements into Rya.
      ryaConn.add(VF.createStatement(ALICE, TALKS_TO, BOB));
      ryaConn.add(VF.createStatement(BOB, LIVES_IN, HAPPYVILLE));
      ryaConn.add(VF.createStatement(BOB, WORKS_AT, BURGER_JOINT));

      // Wait for Fluo to finish processing.
      fluo.waitForObservers();

      // Fetch the exported result and show that its column visibility has been simplified.
      final String pcjTableName = new PcjTableNameFactory().makeTableName(RYA_INSTANCE_NAME, pcjId);
      final Scanner scan = accumuloConn.createScanner(pcjTableName, new Authorizations("u"));
      scan.fetchColumnFamily(new Text("customer;worker;city"));

      final Entry<Key, Value> result = scan.iterator().next();
      final Key key = result.getKey();
      assertEquals(new Text("u"), key.getColumnVisibility());

    } finally {
      if (ryaConn != null) {
        try {
          ryaConn.close();
        } finally {
        }
      }

      if (ryaRepo != null) {
        try {
          ryaRepo.shutDown();
        } finally {
        }
      }

      if (sail != null) {
        try {
          sail.shutDown();
        } finally {
        }
      }
    }
  }