Search in sources :

Example 1 with UpdateCreate

use of org.apache.jena.sparql.modify.request.UpdateCreate in project jena by apache.

the class AbstractTestUpdateGraphMgt method testCreateDrop2.

@Test
public void testCreateDrop2() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    Update u = new UpdateCreate(graphIRI);
    UpdateAction.execute(u, gStore);
    u = new UpdateCreate(graphIRI, true);
    UpdateAction.execute(u, gStore);
    // JENA-1068
    //        assertTrue(gStore.containsGraph(graphIRI)) ;
    assertTrue(graphEmpty(gStore.getGraph(graphIRI)));
    u = new UpdateDrop(graphIRI);
    UpdateAction.execute(u, gStore);
    assertFalse(gStore.containsGraph(graphIRI));
    u = new UpdateDrop(graphIRI, true);
    UpdateAction.execute(u, gStore);
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) Update(org.apache.jena.update.Update) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop) Test(org.junit.Test)

Example 2 with UpdateCreate

use of org.apache.jena.sparql.modify.request.UpdateCreate in project jena by apache.

the class UpdateProgrammatic method main.

public static void main(String[] args) {
    Dataset dataset = DatasetFactory.createTxnMem();
    UpdateRequest request = UpdateFactory.create();
    request.add(new UpdateDrop(Target.ALL));
    request.add(new UpdateCreate("http://example/g2"));
    request.add(new UpdateLoad("file:etc/update-data.ttl", "http://example/g2"));
    UpdateAction.execute(request, dataset);
    System.out.println("# Debug format");
    SSE.write(dataset);
    System.out.println();
    System.out.println("# N-Quads: S P O G");
    RDFDataMgr.write(System.out, dataset, Lang.NQUADS);
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) UpdateLoad(org.apache.jena.sparql.modify.request.UpdateLoad) Dataset(org.apache.jena.query.Dataset) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop)

Example 3 with UpdateCreate

use of org.apache.jena.sparql.modify.request.UpdateCreate in project jena by apache.

the class AbstractTestUpdateGraphMgt method testCreateDrop1.

@Test
public void testCreateDrop1() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    Update u = new UpdateCreate(graphIRI);
    UpdateAction.execute(u, gStore);
    // Only true if a graph caching layer exists.
    // JENA-1068 removed that layer 
    // (which wasn't safe anyway - it only "existed" in the memory cache) 
    //        assertTrue(gStore.containsGraph(graphIRI)) ;
    assertTrue(graphEmpty(gStore.getGraph(graphIRI)));
    // With "auto SILENT" then these aren't errors.
    boolean silentMode = true;
    if (!silentMode) {
        // try again - should fail (already exists)
        try {
            UpdateAction.execute(u, gStore);
            fail();
        } catch (UpdateException ex) {
        }
    }
    // Drop it.
    u = new UpdateDrop(graphIRI);
    UpdateAction.execute(u, gStore);
    assertFalse(gStore.containsGraph(graphIRI));
    if (!silentMode) {
        // Drop it again. - should fail
        try {
            UpdateAction.execute(u, gStore);
            fail();
        } catch (UpdateException ex) {
        }
    }
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) UpdateException(org.apache.jena.update.UpdateException) Update(org.apache.jena.update.Update) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop) Test(org.junit.Test)

Aggregations

UpdateCreate (org.apache.jena.sparql.modify.request.UpdateCreate)3 UpdateDrop (org.apache.jena.sparql.modify.request.UpdateDrop)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 Update (org.apache.jena.update.Update)2 Test (org.junit.Test)2 Dataset (org.apache.jena.query.Dataset)1 UpdateLoad (org.apache.jena.sparql.modify.request.UpdateLoad)1 UpdateException (org.apache.jena.update.UpdateException)1