Skip to content

Commit

Permalink
Fix Test Failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed Apr 17, 2019
1 parent b656af1 commit 3d0853f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/apoc/periodic/Periodic.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static String slottedRuntime(String cypherIterate) {
if (RUNTIME_PATTERN.matcher(cypherIterate).find()) {
return cypherIterate;
}
Matcher matcher = CYPHER_PREFIX_PATTERN.matcher(cypherIterate.substring(0, 15));
Matcher matcher = CYPHER_PREFIX_PATTERN.matcher(cypherIterate.substring(0, Math.min(15, cypherIterate.length())));
return matcher.find() ? CYPHER_PREFIX_PATTERN.matcher(cypherIterate).replaceFirst(CYPHER_RUNTIME_SLOTTED) : CYPHER_RUNTIME_SLOTTED + cypherIterate;
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/apoc/periodic/PeriodicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testSlottedRuntime() throws Exception {
}
@Test
public void testTerminateCommit() throws Exception {
testTerminatePeriodicQuery("CALL apoc.periodic.commit('UNWIND range(0,1000) as id WITH id CREATE (:Foo {id: id}) limit 1000', {})");
testTerminatePeriodicQuery("CALL apoc.periodic.commit('UNWIND range(0,10000) as id WITH id LIMIT 10000 CREATE (:Foo {id: id})', {})");
}

@Test(expected = QueryExecutionException.class)
Expand Down Expand Up @@ -149,12 +149,12 @@ public void testTerminatePeriodicQuery(String periodicQuery) {
"return killedId";
public void killPeriodicQueryAsync() {
new Thread(() -> {
int retries = 10;
int retries = 100;
try {
while (retries-- > 0 && !db.execute(KILL_PERIODIC_QUERY).hasNext()) {
Thread.sleep(10);
Thread.sleep(1);
}
} catch (InterruptedException e) {
} catch (InterruptedException| DatabaseShutdownException e) {
// ignore
}
}).start();
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/apoc/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ public static <T> T assertDuration(Matcher<? super Long> matcher, Supplier<T> fu
}

public static void assumeTravis() {
assumeFalse("we're running on travis, so skipping","true".equals(System.getenv("TRAVIS")));
assumeFalse("we're running on travis, so skipping", isTravis());
}

public static boolean isTravis() {
return "true".equals(System.getenv("TRAVIS"));
}

public static GraphDatabaseBuilder apocGraphDatabaseBuilder() {
Expand Down

0 comments on commit 3d0853f

Please sign in to comment.