コード例 #1
0
  public void testRemoveNamespace() {
    SailGraph graph = new MemoryStoreSailGraph();
    GremlinScriptContext context = new GremlinScriptContext();
    context
        .getBindings(ScriptContext.ENGINE_SCOPE)
        .put(Tokens.GRAPH_VARIABLE, new Atom<Graph>(graph));

    Function<Object> function = new RemoveNamespaceFunction();
    assertNotNull(graph.getNamespaces().get("rdf"));
    this.stopWatch();
    Atom<Object> atom = function.compute(createUnaryArgs(graph, "rdf"), context);
    printPerformance(
        function.getFunctionName() + " function", 1, "namespace removed", this.stopWatch());
    assertNull(atom.getValue());
    assertNull(graph.getNamespaces().get("rdf"));

    assertNotNull(graph.getNamespaces().get("rdfs"));
    this.stopWatch();
    atom = function.compute(createUnaryArgs("rdfs"), context);
    printPerformance(
        function.getFunctionName() + " function", 1, "namespace removed", this.stopWatch());
    assertTrue(atom.isNull());
    assertNull(graph.getNamespaces().get("rdfs"));

    graph.shutdown();
  }