Skip to content

Commit

Permalink
Refactored QueryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
KMax committed May 14, 2014
1 parent 077ab64 commit e06579e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
31 changes: 19 additions & 12 deletions src/test/java/org/deri/cqels/QueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static com.jayway.awaitility.Awaitility.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand All @@ -23,7 +22,7 @@

public class QueryTest {

private static final String STREAM_ID = "http://example.org/simpletest/test";
private static final String STREAM_ID_PREFIX = "http://example.org/simpletest/test";
private static final String CQELS_HOME = "cqels_home";
private static ExecContext context;

Expand All @@ -37,7 +36,8 @@ public static void beforeClass() {
}

@Test(timeout = 5000)
public void simpleQuery() {
public void simple() {
final String STREAM_ID = STREAM_ID_PREFIX + "_1";
RDFStream stream = new DefaultRDFStream(context, STREAM_ID);

ContinuousSelect query = context.registerSelect(""
Expand All @@ -61,7 +61,8 @@ public void simpleQuery() {
}

@Test(timeout = 5000)
public void queryWithStaticData() {
public void streamURIAsVar() {
final String STREAM_ID = STREAM_ID_PREFIX + "_1";
RDFStream stream = new DefaultRDFStream(context, STREAM_ID);

context.loadDefaultDataset(
Expand Down Expand Up @@ -90,12 +91,14 @@ public void queryWithStaticData() {
}

@Test
public void queryTwoStreams() throws InterruptedException {
RDFStream stream_1 = new DefaultRDFStream(context, STREAM_ID + "_1");
RDFStream stream_2 = new DefaultRDFStream(context, STREAM_ID + "_2");
public void severalStreamsAsVarsFromDataset() throws InterruptedException {
RDFStream stream_1 = new DefaultRDFStream(context,
STREAM_ID_PREFIX + "_1");
RDFStream stream_2 = new DefaultRDFStream(context,
STREAM_ID_PREFIX + "_2");

context.loadDefaultDataset(
"src/test/resources/org/deri/cqels/dataset_1.ttl");
"src/test/resources/org/deri/cqels/dataset.ttl");

ContinuousSelect query = context.registerSelect(""
+ "SELECT ?x ?y ?z WHERE {"
Expand All @@ -117,12 +120,16 @@ public void queryTwoStreams() throws InterruptedException {
List<Mapping> mappings = await().until(listener, hasSize(2));

List<Node> nodes = toNodeList(mappings.get(0));
assertEquals(3, nodes.size());
System.out.println(Arrays.toString(nodes.toArray()));
assertEquals("http://example.org/resource/1", nodes.get(0).getURI());
assertEquals("http://example.org/ontology#hasValue",
nodes.get(1).getURI());
assertEquals("123", nodes.get(2).getLiteralValue());

nodes = toNodeList(mappings.get(1));
assertEquals(3, nodes.size());
System.out.println(Arrays.toString(nodes.toArray()));
assertEquals("http://example.org/resource/2", nodes.get(0).getURI());
assertEquals("http://example.org/ontology#hasValue",
nodes.get(1).getURI());
assertEquals("321", nodes.get(2).getLiteralValue());
}

private List<Node> toNodeList(Mapping mapping) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/org/deri/cqels/dataset.ttl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@base <http://example.org/> .

</resource/1> </ontology#hasStream> </simpletest/test> .
</resource/1> </ontology#hasStream> </simpletest/test_1> .
</resource/2> </ontology#hasStream> </simpletest/test_2> .
4 changes: 0 additions & 4 deletions src/test/resources/org/deri/cqels/dataset_1.ttl

This file was deleted.

0 comments on commit e06579e

Please sign in to comment.