Search in sources :

Example 21 with InMemoryTempGraphFactory

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;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)

Example 22 with InMemoryTempGraphFactory

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));
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 23 with InMemoryTempGraphFactory

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);
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 24 with InMemoryTempGraphFactory

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 25 with 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);
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) File(java.io.File) 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