Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixing queries used in waitForTriples calls to be the same as other c…
  • Loading branch information
escowles committed Nov 25, 2013
1 parent 136b46b commit 2886ab3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Expand Up @@ -109,7 +109,8 @@ public void indexerGroupUpdateTest() throws Exception {

private void doIndexerGroupUpdateTest(final String pid) throws Exception {
// create dummy object
final HttpPost method = new HttpPost(serverAddress + pid);
final String uri = serverAddress + pid;
final HttpPost method = new HttpPost(uri);
final HttpResponse response = client.execute(method);
assertEquals(201, response.getStatusLine().getStatusCode());

Expand All @@ -126,24 +127,25 @@ private void doIndexerGroupUpdateTest(final String pid) throws Exception {
f.getName().startsWith(pid));
assertTrue("File size too small: " + f.length(), f.length() > 500);

final int expectedTriples = 4;
waitForTriples(expectedTriples, pid);
final int expectedTriples = 6;
waitForTriples(expectedTriples, uri);

// triples should exist in the triplestore
assertTrue("Triples should exist",
sparqlIndexer.countTriples(serverAddress + pid) == expectedTriples);
sparqlIndexer.countTriples(uri) == expectedTriples);
}

@Test
public void indexerGroupDeleteTest() throws Exception {
// create and verify dummy object
final String pid = "test_pid_5";
final String uri = serverAddress + pid;
doIndexerGroupUpdateTest(pid);

Thread.sleep(1200); // Let the creation event persist

// delete dummy object
final HttpDelete method = new HttpDelete(serverAddress + pid);
final HttpDelete method = new HttpDelete(uri);
final HttpResponse response = client.execute(method);
assertEquals(204, response.getStatusLine().getStatusCode());

Expand Down Expand Up @@ -171,21 +173,21 @@ public void indexerGroupDeleteTest() throws Exception {
assertTrue("File size should be 0: " + f2.length(), f2.length() == 0);

final int expectedTriples = 0;
waitForTriples(expectedTriples, pid);
waitForTriples(expectedTriples, uri);

// triples should not exist in the triplestore
assertTrue("Triples should not exist",
sparqlIndexer.countTriples(serverAddress + pid) == expectedTriples);
sparqlIndexer.countTriples(uri) == expectedTriples);
}

@Test
public void indexerGroupUpdateTestingFullPath() throws Exception {
// create update message and send to indexer group
final String pid = "test_pid_10";
final String SUFFIX = "a/b/c/";
final String pid = "test_pid_10";
final String uri = serverAddress + "a/b/c/" + pid;

// create dummy object
final HttpPost method = new HttpPost(serverAddress + SUFFIX + pid);
final HttpPost method = new HttpPost(uri);
final HttpResponse response = client.execute(method);
assertEquals(201, response.getStatusLine().getStatusCode());

Expand All @@ -202,12 +204,12 @@ public void indexerGroupUpdateTestingFullPath() throws Exception {
f.getName().startsWith(pid));
assertTrue("File size too small: " + f.length(), f.length() > 500);

final int expectedTriples = 4;
waitForTriples(expectedTriples, SUFFIX + pid);
final int expectedTriples = 6;
waitForTriples(expectedTriples, uri);

// triples should exist in the triplestore
assertTrue("Triples should exist",
sparqlIndexer.countTriples(serverAddress + SUFFIX + pid) == expectedTriples);
sparqlIndexer.countTriples(uri) == expectedTriples);
}

private void waitForFiles(int expectedFiles, FilenameFilter filter) throws InterruptedException {
Expand Down
Expand Up @@ -90,10 +90,10 @@ private void waitForTriples(int expectTriples) throws InterruptedException {
long restingWait = 500;
long maxWait = 15000; // 15 seconds

int count = sparqlIndexer.countTriples("foo");
int count = sparqlIndexer.countTriples(serverAddress + "foo");
while ((count != expectTriples) && (elapsed < maxWait)) {
Thread.sleep(restingWait);
count = sparqlIndexer.countTriples("foo");
count = sparqlIndexer.countTriples(serverAddress + "foo");

elapsed += restingWait;
}
Expand Down

0 comments on commit 2886ab3

Please sign in to comment.