Skip to content

Commit

Permalink
[NOID] Cleans up resources after the tests (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon committed Aug 8, 2023
1 parent 5467f95 commit 0646a23
Show file tree
Hide file tree
Showing 45 changed files with 798 additions and 1,036 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package apoc.util.kernel;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;

import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

import org.neo4j.test.rule.DbmsRule;
import org.neo4j.test.rule.ImpermanentDbmsRule;

import static apoc.util.kernel.MultiThreadedGlobalGraphOperations.BatchJobResult;
import static apoc.util.kernel.MultiThreadedGlobalGraphOperations.forAllNodes;
import static org.junit.Assert.assertEquals;

public class MultiThreadedGlobalGraphOperationsTest {

@ClassRule
public static DbmsRule db = new ImpermanentDbmsRule();

@BeforeClass
public static void beforeClass() {
createData();
}

@AfterClass
public static void teardown() {
db.shutdown();
}

private static void createData() {
db.executeTransactionally("UNWIND range(1,1000) as x MERGE (s{id:x}) MERGE (e{id:x+1}) merge (s)-[:REL{id:x}]->(e)");
}

@Test
public void shouldforAllNodesWork() {
AtomicInteger counter = new AtomicInteger();
BatchJobResult result = forAllNodes(db, Executors.newFixedThreadPool(4), 10,
(nodeCursor) -> counter.incrementAndGet() );
assertEquals(1001, counter.get());
assertEquals(1001, result.getSucceeded());
assertEquals(0, result.getFailures());
}
}
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/CollAggregationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -39,6 +40,11 @@ public static void setUp() {
TestUtil.registerProcedure(db, CollAggregation.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testNth() throws Exception {
testCall(db, "UNWIND RANGE(0,10) as value RETURN apoc.agg.nth(value, 0) as first, apoc.agg.nth(value, 3) as third,apoc.agg.nth(value, -1) as last",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/GraphAggregationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand Down Expand Up @@ -48,6 +49,11 @@ public class GraphAggregationTest {
db.executeTransactionally("CREATE (a:A {id:'a'})-[:AB {id:'ab'}]->(b:B {id:'b'})-[:BC {id:'bc'}]->(c:C {id:'c'}),(a)-[:AC {id:'ac'}]->(c)");
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testGraph() throws Exception {
Map<String, Entity> pcs = db.executeTransactionally("MATCH (n) RETURN n.id as id, n UNION ALL MATCH ()-[n]->() RETURN n.id as id, n", Collections.emptyMap(),
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/MedianTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -37,6 +38,11 @@ public class MedianTest {
TestUtil.registerProcedure(db, Median.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testMedian() throws Exception {
testCall(db, "UNWIND [] as value RETURN apoc.agg.median(value) as p",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/PercentilesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
Expand All @@ -41,6 +42,11 @@ public class PercentilesTest {
TestUtil.registerProcedure(db, Percentiles.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testPercentiles() throws Exception {
testCall(db, "UNWIND [] as value RETURN apoc.agg.percentiles(value) as p",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/ProductAggregationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -37,6 +38,11 @@ public class ProductAggregationTest {
TestUtil.registerProcedure(db, Product.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testProduct() throws Exception {
testCall(db, "UNWIND [] as value RETURN apoc.agg.product(value) as p",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/agg/StatisticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.agg;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -41,6 +42,11 @@ public static void setUp() throws Exception {
TestUtil.registerProcedure(db, Statistics.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testStatistics() throws Exception {
testCall(db, "UNWIND [] as value RETURN apoc.agg.statistics(value) as p",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/algo/CoverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.algo;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -42,6 +43,11 @@ public static void setUp() throws Exception {
db.executeTransactionally("CREATE (a)-[:X]->(b)-[:X]->(c)-[:X]->(d)");
}

@AfterClass
public static void teardown() {
db.shutdown();
}

@Test
public void testCover() throws Exception {
TestUtil.testCall(db,
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/algo/PathFindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.algo;

import apoc.util.TestUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -73,6 +74,11 @@ public void setUp() throws Exception {
TestUtil.registerProcedure(db, PathFinding.class);
}

@After
public void teardown() {
db.shutdown();
}

@Test
public void testAStar() {
db.executeTransactionally(SETUP_GEO);
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/atomic/AtomicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -54,6 +55,11 @@ public class AtomicTest {
TestUtil.registerProcedure(db, Atomic.class);
}

@After
public void teardown() {
db.shutdown();
}

@Test
public void testAddAndSubInteger(){
db.executeTransactionally("CREATE (p:Person {name:'Tom'})");
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/apoc/bitwise/BitwiseOperationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package apoc.bitwise;

import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -45,6 +46,11 @@ public static void setUp() throws Exception {
TestUtil.registerProcedure(db, BitwiseOperations.class);
}

@AfterClass
public static void teardown() {
db.shutdown();
}

public void testOperation(String op, long expected) {
Map<String, Object> params = map("a", a, "op", op, "b", b);
testCall(db, BITWISE_CALL, params,
Expand Down
129 changes: 0 additions & 129 deletions core/src/test/java/apoc/coll/ArrayListTest.java

This file was deleted.

Loading

0 comments on commit 0646a23

Please sign in to comment.