public void ItThrowsAnExceptionIfOneEndpointFails() { var endpoint = new FederatedSparqlRemoteEndpoint(new [] { new SparqlRemoteEndpoint(new Uri(_fixture.Server1.Urls[0] + "/query")), new SparqlRemoteEndpoint(new Uri(_fixture.Server2.Urls[0] + "/fail")), }); Assert.Throws <RdfQueryException>(() => endpoint.QueryWithResultSet("SELECT * WHERE { ?s ?p ?o }")).InnerException.Should().BeOfType <RdfQueryException>(); }
public void ItCombinesResultsFromFederatedEndpoints() { var endpoint = new FederatedSparqlRemoteEndpoint( new[] { new SparqlRemoteEndpoint(new Uri(_fixture.Server1.Urls[0] + "/query")), new SparqlRemoteEndpoint(new Uri(_fixture.Server2.Urls[0] + "/query")), }); var results = endpoint.QueryWithResultSet("SELECT * WHERE {?s ?p ?o}"); results.Should().NotBeNull().And.HaveCount(2); }
public void ItThrowsAnExceptionIfOneEndpointTimesOut() { var endpoint = new FederatedSparqlRemoteEndpoint(new[] { new SparqlRemoteEndpoint(new Uri(_fixture.Server1.Urls[0] + "/query")), new SparqlRemoteEndpoint(new Uri(_fixture.Server2.Urls[0] + "/timeout")), }) { Timeout = 2000 }; Assert.Throws <RdfQueryTimeoutException>(() => endpoint.QueryWithResultSet("SELECT * WHERE { ?s ?p ?o }")); }
public void ItAllowsTimeoutsToBeIgnored() { var endpoint = new FederatedSparqlRemoteEndpoint(new[] { new SparqlRemoteEndpoint(new Uri(_fixture.Server1.Urls[0] + "/query")), new SparqlRemoteEndpoint(new Uri(_fixture.Server2.Urls[0] + "/timeout")), }) { Timeout = 2000, IgnoreFailedRequests = true }; var results = endpoint.QueryWithResultSet("SELECT * WHERE {?s ?p ?o}"); results.Should().NotBeNull().And.HaveCount(1); _fixture.Server1.FindLogEntries(new RequestMessagePathMatcher(MatchBehaviour.AcceptOnMatch, "/query")) .Should().HaveCount(1).And.Contain(x => x.RequestMessage.Method.Equals("get", StringComparison.InvariantCultureIgnoreCase)); }
private bool SetupSparqlEndpointData() { try { FederatedSparqlRemoteEndpoint federatedSparqlRemoteEndpoint = new FederatedSparqlRemoteEndpoint(_testSparqlEndpoints); var response = federatedSparqlRemoteEndpoint.QueryWithResultSet("select ?s where {?s ?p ?o} limit 1"); if (response.Count() == 3) { return(true); } return(false); } catch (Exception) { return(false); } }