Beispiel #1
0
        private void ProcessEntries(BaseGraph g)
        {
            var sparqlResults = g.ExecuteQuery(
                @"PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>
PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?testCase ?name ?comment ?query ?data ?result ?action WHERE {
?testCase a mf:QueryEvaluationTest .
?testCase mf:name ?name .
OPTIONAL { ?testCase rdfs:comment ?comment } .
?testCase mf:action ?action .
?action qt:query ?query .
?action qt:data  ?data .
?testCase mf:result ?result . }")
                                as SparqlResultSet;

            foreach (var result in sparqlResults.Results)
            {
                var qe =
                    new QueryEvaluationTestCase
                {
                    Definition = (result["testCase"] as UriNode).Uri,
                    Name       = result["name"].ToString(),
                    Comment    = result.HasValue("comment") ? result["comment"].ToString() : null,
                    Query      = (result["query"] as UriNode).Uri,
                    Data       = (result["data"] as UriNode).Uri,
                    Result     = (result["result"] as UriNode).Uri,
                    GraphData  = new List <Uri>()
                };
                if (String.IsNullOrEmpty(qe.Name))
                {
                    _unamedTestCount++;
                    qe.Name = "UnamedTest_" + _unamedTestCount;
                }
                var action = result["action"] as INode;
                foreach (var t in g.GetTriplesWithSubjectPredicate(action, g.CreateUriNode(GraphData)))
                {
                    qe.GraphData.Add((t.Object as UriNode).Uri);
                }
                _testCases.Add(qe);
            }

            var updateEvaluationTests =
                g.ExecuteQuery(
                    @"
PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>
PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ut:      <http://www.w3.org/2009/sparql/tests/test-update#>
SELECT ?test ?name ?comment ?action ?result ?request WHERE {
    ?test a ut:UpdateEvaluationTest .
    ?test mf:name ?name .
    OPTIONAL { ?test rdfs:comment ?comment }
    ?test mf:action ?action .
    ?test mf:result ?result .
    ?action ut:request ?request .
}")
                as SparqlResultSet;

            foreach (var updateEvaluationTest in updateEvaluationTests.Results)
            {
                var uet = new UpdateEvaluationTestCase
                {
                    Definition = (updateEvaluationTest["test"] as IUriNode).Uri,
                    Name       = updateEvaluationTest["name"].ToString(),
                    Comment    =
                        updateEvaluationTest.HasValue("comment")
                                          ? updateEvaluationTest["comment"].ToString()
                                          : null,
                    Request = (updateEvaluationTest["request"] as IUriNode).Uri
                };
                var actionNode = updateEvaluationTest["action"];
                var resultNode = updateEvaluationTest["result"];
                foreach (var t in g.GetTriplesWithSubjectPredicate(actionNode, g.CreateUriNode(UtData)))
                {
                    uet.PreData = (t.Object as IUriNode).Uri;
                }
                foreach (var t in g.GetTriplesWithSubjectPredicate(actionNode, g.CreateUriNode(UtGraphData)))
                {
                    uet.PreGraphData.Add(GetUpdateGraph(t.Object, g));
                }

                foreach (var t in g.GetTriplesWithSubjectPredicate(resultNode, g.CreateUriNode(UtData)))
                {
                    uet.PostData = (t.Object as IUriNode).Uri;
                }
                foreach (var t in g.GetTriplesWithSubjectPredicate(resultNode, g.CreateUriNode(UtGraphData)))
                {
                    uet.PostGraphData.Add(GetUpdateGraph(t.Object, g));
                }
                _testCases.Add(uet);
            }
        }
Beispiel #2
0
        private void ProcessEntries(BaseGraph g)
        {
            var sparqlResults = g.ExecuteQuery(
                @"PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>
PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?testCase ?name ?comment ?query ?data ?result ?action WHERE {
?testCase a mf:QueryEvaluationTest .
?testCase mf:name ?name .
OPTIONAL { ?testCase rdfs:comment ?comment } .
?testCase mf:action ?action .
?action qt:query ?query .
?action qt:data  ?data .
?testCase mf:result ?result . }")
                               as SparqlResultSet;
            foreach(var result in sparqlResults.Results)
            {
                var qe = 
                new QueryEvaluationTestCase
                                   {
                                       Definition = (result["testCase"] as UriNode).Uri,
                                       Name = result["name"].ToString(),
                                       Comment = result.HasValue("comment") ? result["comment"].ToString() : null,
                                       Query = (result["query"] as UriNode).Uri,
                                       Data = (result["data"] as UriNode).Uri,
                                       Result = (result["result"] as UriNode).Uri,
                                       GraphData = new List<Uri>()
                                   };
                if (String.IsNullOrEmpty(qe.Name))
                {
                    _unamedTestCount++;
                    qe.Name = "UnamedTest_" + _unamedTestCount;
                }
                var action = result["action"] as INode;
                foreach(var t in g.GetTriplesWithSubjectPredicate(action, g.CreateUriNode(GraphData)))
                {
                    qe.GraphData.Add((t.Object as UriNode).Uri);
                }
                _testCases.Add(qe);
            }

            var updateEvaluationTests =
                g.ExecuteQuery(
                    @"
PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>
PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ut:      <http://www.w3.org/2009/sparql/tests/test-update#>
SELECT ?test ?name ?comment ?action ?result ?request WHERE {
    ?test a ut:UpdateEvaluationTest .
    ?test mf:name ?name .
    OPTIONAL { ?test rdfs:comment ?comment }
    ?test mf:action ?action .
    ?test mf:result ?result .
    ?action ut:request ?request .
}")
                as SparqlResultSet;
            foreach(var updateEvaluationTest in updateEvaluationTests.Results)
            {
                var uet = new UpdateEvaluationTestCase
                              {
                                  Definition = (updateEvaluationTest["test"] as IUriNode).Uri,
                                  Name = updateEvaluationTest["name"].ToString(),
                                  Comment =
                                      updateEvaluationTest.HasValue("comment")
                                          ? updateEvaluationTest["comment"].ToString()
                                          : null,
                                  Request = (updateEvaluationTest["request"] as IUriNode).Uri
                              };
                var actionNode = updateEvaluationTest["action"];
                var resultNode = updateEvaluationTest["result"];
                foreach(var t in g.GetTriplesWithSubjectPredicate(actionNode, g.CreateUriNode(UtData)))
                {
                    uet.PreData = (t.Object as IUriNode).Uri;
                }
                foreach (var t in g.GetTriplesWithSubjectPredicate(actionNode, g.CreateUriNode(UtGraphData)))
                {
                    uet.PreGraphData.Add(GetUpdateGraph(t.Object, g));
                }
                
                foreach(var t in g.GetTriplesWithSubjectPredicate(resultNode, g.CreateUriNode(UtData)))
                {
                    uet.PostData = (t.Object as IUriNode).Uri;
                }
                foreach (var t in g.GetTriplesWithSubjectPredicate(resultNode, g.CreateUriNode(UtGraphData)))
                {
                    uet.PostGraphData.Add(GetUpdateGraph(t.Object, g));
                }
                _testCases.Add(uet);
            }
        }