Search in sources :

Example 1 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.

the class StageStorageTest method setUp.

@Before
public void setUp() throws Exception {
    File tempFolder = temporaryFolder.newFolder("shine");
    stageStorage = new StageStorage(tempFolder.getAbsolutePath());
    stageStorage.clear();
    graphFactory = new InMemoryTempGraphFactory();
}
Also used : File(java.io.File) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Before(org.junit.Before)

Example 2 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.

the class XMLArtifactImporterTest method testSubsequentHandlerIsUsedWhenFirstHandlerBlowsUp.

@Test
public void testSubsequentHandlerIsUsedWhenFirstHandlerBlowsUp() throws Exception {
    artifactImporter.registerHandler(new ExplodingHandler());
    artifactImporter.registerHandler(new StubHandler(true, "http://A-OK/"));
    Graph graph = new InMemoryTempGraphFactory().createTempGraph();
    URIReference parent = graph.createURIReference(BAR_CLASS, "http://parent/");
    artifactImporter.importFile(graph, parent, new ByteArrayInputStream("<foo />".getBytes()));
    String askForSecondHandler = "PREFIX ex: <http://example.com/example.owl#> " + "ASK WHERE { " + "<http://parent/> ex:foo <http://A-OK/> " + "}";
    assertAskIsTrue(graph, askForSecondHandler);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 3 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.

the class XMLArtifactImporterTest method testSubsequentHandlerIsUsedWhenFirstCannotHandleArtifact.

@Test
public void testSubsequentHandlerIsUsedWhenFirstCannotHandleArtifact() throws Exception {
    artifactImporter.registerHandler(new StubHandler(false, "http://foobar/"));
    artifactImporter.registerHandler(new StubHandler(true, "http://A-OK/"));
    Graph graph = new InMemoryTempGraphFactory().createTempGraph();
    URIReference parent = graph.createURIReference(BAR_CLASS, "http://parent/");
    artifactImporter.importFile(graph, parent, new ByteArrayInputStream("<foo />".getBytes()));
    String askForFirstHandler = "PREFIX ex: <http://example.com/example.owl#> " + "ASK WHERE { " + "<http://parent/> ex:foo <http://foobar/> " + "}";
    assertAskIsFalse(graph, askForFirstHandler);
    String askForSecondHandler = "PREFIX ex: <http://example.com/example.owl#> " + "ASK WHERE { " + "<http://parent/> ex:foo <http://A-OK/> " + "}";
    assertAskIsTrue(graph, askForSecondHandler);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 4 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.

the class XMLArtifactImporterTest method testImportedDataWasAdded.

@Test
public void testImportedDataWasAdded() throws IOException {
    artifactImporter.registerHandler(new StubHandler(true));
    Graph graph = new InMemoryTempGraphFactory().createTempGraph();
    URIReference parent = graph.createURIReference(BAR_CLASS, "http://parent/");
    artifactImporter.importFile(graph, parent, new ByteArrayInputStream("<foo />".getBytes()));
    String ask = "PREFIX ex: <http://example.com/example.owl#> " + "ASK WHERE { " + "<http://parent/> ex:foo <http://yadda/> " + "}";
    assertAskIsTrue(graph, (ask));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 5 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.

the class GraphActionsTest method canRemoveStatements.

@Test
public void canRemoveStatements() {
    Graph graph = new InMemoryTempGraphFactory().createTempGraph();
    String rdf = "" + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ." + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ." + "" + "<http://pipeline/1> rdf:type cruise:Pipeline ." + "<http://pipeline/1> cruise:hasStage <http://stage/1> ." + "<http://pipeline/1> cruise:hasStage <http://stage/2> ." + "<http://stage/1> rdf:type cruise:Stage .  " + "<http://stage/2> rdf:type cruise:Stage .  ";
    GraphActions actions = new GraphActions(graph);
    actions.queueRemoveResourceStatement(graph.createURIReference(GoOntology.PIPELINE_RESOURCE, "http://pipeline/1"), GoOntology.HAS_STAGE, graph.createURIReference(GoOntology.STAGE_RESOURCE, "http://stage/1"));
    actions.queueRemoveResourceStatement(graph.createURIReference(GoOntology.PIPELINE_RESOURCE, "http://pipeline/1"), RDFOntology.TYPE, graph.createURIReference(GoOntology.STAGE_RESOURCE, "http://stage/2"));
    actions.execute();
    assertEquals(3L, graph.size());
}
Also used : InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Aggregations

InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)37 Test (org.junit.Test)28 Graph (com.thoughtworks.studios.shine.semweb.Graph)18 File (java.io.File)14 ByteArrayInputStream (java.io.ByteArrayInputStream)9 InputStream (java.io.InputStream)7 Before (org.junit.Before)6 JobXmlViewModel (com.thoughtworks.go.server.domain.xml.JobXmlViewModel)2 XSLTTransformerRegistry (com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry)2 JobInstance (com.thoughtworks.go.domain.JobInstance)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)1 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)1 StageStorage (com.thoughtworks.studios.shine.cruise.stage.details.StageStorage)1 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)1 GRDDLTransformer (com.thoughtworks.studios.shine.semweb.grddl.GRDDLTransformer)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1