use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.
the class LazyStageGraphLoader method load.
public Graph load(StageIdentifier stageIdentifier) {
if (stageStorage.isStageStored(stageIdentifier)) {
return stageStorage.load(stageIdentifier);
}
Graph graph;
try {
graph = importer.load(stageIdentifier, new InMemoryTempGraphFactory(), transformerRegistry);
} catch (Exception e) {
throw bomb(e);
}
stageStorage.save(graph);
return graph;
}
use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.
the class GRDDLTransformerTest method checkXMLBecomesRDF.
@Test
public void checkXMLBecomesRDF() throws Exception {
String inputXML = "<foo>bar</foo>";
String xsl = "" + "<?xml version='1.0' encoding='UTF-8'?>" + "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' " + "xmlns:ex='http://www.example.com/ontology.owl#' " + "xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' version='1.0'>" + "<xsl:template match='/'>" + "<rdf:RDF>" + "<xsl:apply-templates />" + "</rdf:RDF>" + "</xsl:template>" + "<xsl:template match='foo'>" + "<ex:Foo>" + "<ex:hasBar rdf:datatype='http://www.w3.org/2001/XMLSchema#string'><xsl:value-of select='.'/></ex:hasBar>" + "</ex:Foo>" + "</xsl:template>" + "</xsl:stylesheet>";
String ask = "prefix ex: <http://www.example.com/ontology.owl#> " + "prefix xsd: <http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE { " + "?foo a ex:Foo ; " + "ex:hasBar 'bar'^^xsd:string . " + "}" + "";
InputStream xslAsStream = new ByteArrayInputStream(xsl.getBytes());
InputStream xmlAsStream = new ByteArrayInputStream(inputXML.getBytes());
GRDDLTransformer transformer = new GRDDLTransformer(transformerForXSLStream(xslAsStream, "foo.xml"), "foo.xml");
Graph graph = transformer.transform(xmlAsStream, new InMemoryTempGraphFactory());
assertAskIsTrue(graph, (ask));
}
use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.
the class GRDDLTransformerTest method checkPipelineTransformation.
@Test
public void checkPipelineTransformation() throws Exception {
InputStream xsl = getClass().getResourceAsStream("/cruise/pipeline-graph-grddl.xsl");
String rawPipelineXML = "<pipeline name='RPNCalculator' counter='1' label='foo-1'>" + " <link rel='self' href='http://localhost:8153/go/api/pipelines/RPNCalculator/1.xml'/>" + " <scheduleTime>2010-01-04T16:02:27-08:00</scheduleTime>" + " <materials>" + " <material>" + " <modifications>" + " <changeset changesetUri='http://cruise03:8153/go/api/materials/13/changeset/5c186460acca8e07972e7cf54935814005c38833.xml'>" + " <user><![CDATA[sjin <sjin@thoughtworks.com>]]></user>" + " <checkinTime>2010-01-04T16:01:21-08:00</checkinTime>" + " <revision>938ab08dc5bd43884a106fe253dbf072b4968b5b</revision>" + " <message><![CDATA[added a failing test]]></message>" + " <file name='test/calculator/RPNIntegerCalculatorTest.java' action='modified' />" + " </changeset>" + " </modifications>" + " </material>" + " </materials>" + " <stages>" + " <stage href='http://localhost:8153/go/api/stages/6.xml'/>" + " </stages>" + " <approvedBy><![CDATA[bigbird]]></approvedBy>" + "</pipeline>";
InputStream pipelineXML = new ByteArrayInputStream(rawPipelineXML.getBytes());
GRDDLTransformer transformer = new GRDDLTransformer(transformerForXSLStream(xsl, "foo.xsl"), "foo.xsl");
Graph transformedGraph = transformer.transform(pipelineXML, new InMemoryTempGraphFactory());
String askIfPipelineWasTransformedWell = "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE { " + "?pipeline a cruise:Pipeline ; " + "cruise:pipelineCounter \"1\"^^xsd:integer ; " + "cruise:pipelineName \"RPNCalculator\"^^xsd:string ; " + "}";
assertAskIsTrue(transformedGraph, askIfPipelineWasTransformedWell);
}
use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.
the class AntJUnitGRDDLTest method makeSureHavingExtraXMLNodesInDataFileDoesntBreakEVERYTHING.
@Test
public void makeSureHavingExtraXMLNodesInDataFileDoesntBreakEVERYTHING() throws Exception {
String xmlWithExtraStuff = "<?xml version='1.0' encoding='UTF-8' ?>" + "<testsuite>" + "<testcase name='anError'>" + "<error message='A message for an error' />" + "</testcase>" + "<testcase name='oneThatWorks'/>" + "<testcase name='aFailure'>" + "<failure message='A message for a failure.'><![CDATA[Aren't you glad you are not a failure?]]></failure>" + "</testcase>" + "<whatDoesNotBelong>This does not belong</whatDoesNotBelong>" + "</testsuite>";
InputStream xunitXMLStream = new ByteArrayInputStream(xmlWithExtraStuff.getBytes());
transformer.transform(xunitXMLStream, new InMemoryTempGraphFactory());
}
use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory in project gocd by gocd.
the class AntJUnitReportRDFizerForRailsTestsReportTest method canReadRailsTestWithPassingOutput.
@Test
public void canReadRailsTestWithPassingOutput() throws Exception {
AntJUnitReportRDFizer junitRDFizer = new AntJUnitReportRDFizer(new InMemoryTempGraphFactory(), XSLTTransformerRegistry);
Graph graph = junitRDFizer.importFile("http://job", document(FileUtils.readFileToString(new File("src/test-shared/resources/ruby_xunit/passing/TEST-PurchasesControllerTest.xml"), UTF_8)));
String ask = "prefix cruise: <" + GoOntology.URI + "> " + "PREFIX xunit: <" + XUnitOntology.URI + "> " + "prefix xsd: <http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE { " + "<http://job> xunit:hasTestCase _:testCase . " + "_:testCase a xunit:TestCase . " + "_:testCase xunit:testSuiteName 'PurchasesControllerTest'^^xsd:string . " + "_:testCase xunit:testCaseName 'test_should_get_index'^^xsd:string . " + "}";
assertAskIsTrue(graph, ask);
}
Aggregations