From ef5ca0e7e27f831d919b2fcab98b13a45cca524f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Cord=C3=B3n?= Date: Thu, 14 Sep 2023 16:31:16 +0100 Subject: [PATCH] [NOID] Cleans up resources after the tests --- core/src/test/java/apoc/export/BigGraphTest.java | 6 ++++++ .../java/apoc/export/ExportCoreSecurityTest.java | 6 ++++++ .../apoc/export/ImportAndLoadCoreSecurityTest.java | 7 ++++++- core/src/test/java/apoc/export/arrow/ArrowTest.java | 6 ++++++ .../apoc/export/arrow/ExportArrowSecurityTest.java | 6 ++++++ .../apoc/export/csv/ExportCsvNeo4jAdminTest.java | 6 ++++++ .../test/java/apoc/export/csv/ExportCsvTest.java | 6 ++++++ .../java/apoc/export/csv/ImportCsvLdbcTest.java | 6 ++++++ .../test/java/apoc/export/csv/ImportCsvTest.java | 6 ++++++ .../export/cypher/ExportCypherMultiRelTest.java | 8 +++++++- .../java/apoc/export/cypher/ExportCypherTest.java | 6 ++++++ .../java/apoc/export/graphml/ExportGraphMLTest.java | 6 ++++++ .../test/java/apoc/export/json/ExportJsonTest.java | 6 ++++++ .../test/java/apoc/export/json/ImportJsonTest.java | 8 +++++++- core/src/test/java/apoc/graph/GraphsTest.java | 6 ++++++ .../test/java/apoc/hashing/FingerprintingTest.java | 6 ++++++ core/src/test/java/apoc/help/HelpTest.java | 6 ++++++ core/src/test/java/apoc/index/SchemaIndexTest.java | 6 ++++++ core/src/test/java/apoc/label/LabelTest.java | 6 ++++++ core/src/test/java/apoc/load/LoadJsonTest.java | 1 + core/src/test/java/apoc/load/XmlTest.java | 1 + .../apoc/load/relative/LoadRelativePathTest.java | 6 ++++++ core/src/test/java/apoc/lock/LockTest.java | 6 ++++++ core/src/test/java/apoc/log/Neo4jLogStreamTest.java | 13 ++++++++++--- core/src/test/java/apoc/map/MapsTest.java | 6 ++++++ core/src/test/java/apoc/math/MathsTest.java | 6 ++++++ core/src/test/java/apoc/math/RegressionTest.java | 6 ++++++ core/src/test/java/apoc/merge/MergeTest.java | 6 ++++++ core/src/test/java/apoc/meta/MetaTest.java | 6 ++++++ .../src/test/java/apoc/neighbors/NeighborsTest.java | 6 ++++++ core/src/test/java/apoc/nodes/GroupingTest.java | 6 ++++++ core/src/test/java/apoc/nodes/NodesTest.java | 6 ++++++ core/src/test/java/apoc/number/ArabicRomanTest.java | 6 ++++++ core/src/test/java/apoc/number/NumbersTest.java | 6 ++++++ core/src/test/java/apoc/number/exact/ExactTest.java | 6 ++++++ core/src/test/java/apoc/path/ExpandPathTest.java | 8 +++++++- core/src/test/java/apoc/path/LabelSequenceTest.java | 6 ++++++ core/src/test/java/apoc/path/NodeFilterTest.java | 6 ++++++ core/src/test/java/apoc/path/PathsTest.java | 6 ++++++ core/src/test/java/apoc/path/RelSequenceTest.java | 6 ++++++ core/src/test/java/apoc/path/SequenceTest.java | 6 ++++++ core/src/test/java/apoc/path/SubgraphTest.java | 6 ++++++ core/src/test/java/apoc/periodic/PeriodicTest.java | 6 ++++++ .../apoc/refactor/util/PropertiesManagerTest.java | 6 ++++++ it/src/test/java/apoc/it/core/ApocSplitTest.java | 1 + it/src/test/java/apoc/it/core/ExportCsvIT.java | 1 + it/src/test/java/apoc/it/core/ExportCsvS3Test.java | 6 ++++++ .../test/java/apoc/it/core/ExportCypherS3Test.java | 6 ++++++ .../test/java/apoc/it/core/ExportGraphMLS3Test.java | 6 ++++++ it/src/test/java/apoc/it/core/ExportJsonS3Test.java | 6 ++++++ it/src/test/java/apoc/it/core/StartupTest.java | 1 + 51 files changed, 288 insertions(+), 7 deletions(-) diff --git a/core/src/test/java/apoc/export/BigGraphTest.java b/core/src/test/java/apoc/export/BigGraphTest.java index d1f2e714d..c7ec22384 100644 --- a/core/src/test/java/apoc/export/BigGraphTest.java +++ b/core/src/test/java/apoc/export/BigGraphTest.java @@ -30,6 +30,7 @@ import apoc.refactor.rename.Rename; import apoc.util.TestUtil; import apoc.util.Util; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -75,6 +76,11 @@ public static void setUp() { IntStream.range(0, 10000).forEach(__-> db.executeTransactionally(query)); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testTerminateExportCsv() { checkTerminationGuard(db, "CALL apoc.export.csv.all('testTerminate.csv',{bulkImport: true})"); diff --git a/core/src/test/java/apoc/export/ExportCoreSecurityTest.java b/core/src/test/java/apoc/export/ExportCoreSecurityTest.java index 25eb7bd94..be1fd99a1 100644 --- a/core/src/test/java/apoc/export/ExportCoreSecurityTest.java +++ b/core/src/test/java/apoc/export/ExportCoreSecurityTest.java @@ -27,6 +27,7 @@ import apoc.util.TestUtil; import apoc.util.Util; import com.nimbusds.jose.util.Pair; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -91,6 +92,11 @@ public static void setUp() { TestUtil.registerProcedure(db, ExportCSV.class, ExportJson.class, ExportGraphML.class, ExportCypher.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + public static void setFileExport(boolean allowed) { ApocConfig.apocConfig().setProperty(ApocConfig.APOC_EXPORT_FILE_ENABLED, allowed); } diff --git a/core/src/test/java/apoc/export/ImportAndLoadCoreSecurityTest.java b/core/src/test/java/apoc/export/ImportAndLoadCoreSecurityTest.java index 2e18f8242..e13f4dbab 100644 --- a/core/src/test/java/apoc/export/ImportAndLoadCoreSecurityTest.java +++ b/core/src/test/java/apoc/export/ImportAndLoadCoreSecurityTest.java @@ -31,6 +31,7 @@ import inet.ipaddr.IPAddressString; import org.apache.commons.lang3.exception.ExceptionUtils; import org.assertj.core.api.Assertions; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -149,7 +150,11 @@ public static void setUp() { // load procedures (Xml contains both `apoc.load.xml` and `apoc.import.xml` procedures) LoadJson.class, LoadArrow.class); } - + + @AfterClass + public static void teardown() { + db.shutdown(); + } @Test public void testIllegalFSAccessWithDifferentApocConfs() { diff --git a/core/src/test/java/apoc/export/arrow/ArrowTest.java b/core/src/test/java/apoc/export/arrow/ArrowTest.java index 68fc176ef..d329d5e47 100644 --- a/core/src/test/java/apoc/export/arrow/ArrowTest.java +++ b/core/src/test/java/apoc/export/arrow/ArrowTest.java @@ -24,6 +24,7 @@ import apoc.util.JsonUtil; import apoc.util.TestUtil; import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -116,6 +117,11 @@ public static void beforeClass() { TestUtil.registerProcedure(db, ExportArrow.class, LoadArrow.class, Graphs.class, Meta.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Before public void before() { apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true); diff --git a/core/src/test/java/apoc/export/arrow/ExportArrowSecurityTest.java b/core/src/test/java/apoc/export/arrow/ExportArrowSecurityTest.java index f6db461a0..e4adee13a 100644 --- a/core/src/test/java/apoc/export/arrow/ExportArrowSecurityTest.java +++ b/core/src/test/java/apoc/export/arrow/ExportArrowSecurityTest.java @@ -24,6 +24,7 @@ import apoc.util.TestUtil; import apoc.util.Util; import com.nimbusds.jose.util.Pair; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -93,6 +94,11 @@ public static void setUp() { TestUtil.registerProcedure(db, ExportArrow.class, Meta.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + private static Collection getParameterData(List>> fileAndErrors) { return ExportCoreSecurityTest.getParameterData(fileAndErrors, EXPORT_PROCEDURES, APOC_EXPORT_PROCEDURE_NAME); } diff --git a/core/src/test/java/apoc/export/csv/ExportCsvNeo4jAdminTest.java b/core/src/test/java/apoc/export/csv/ExportCsvNeo4jAdminTest.java index ab1c54e0d..f84b4b38a 100644 --- a/core/src/test/java/apoc/export/csv/ExportCsvNeo4jAdminTest.java +++ b/core/src/test/java/apoc/export/csv/ExportCsvNeo4jAdminTest.java @@ -25,6 +25,7 @@ import apoc.util.Util; import apoc.util.collection.Iterators; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -115,6 +116,11 @@ public void before() { db.executeTransactionally("CREATE (a:Types {date: date('2018-10-30'), localDateTime: localdatetime('20181030T19:32:24'), dateTime: datetime('2018-10-30T12:50:35.556+0100'), localtime: localtime('12:50:35.556'), duration: duration('P5M1DT12H'), time: time('125035.556+0100'), born_2D: point({ x: 2.3, y: 4.5 }), born_3D:point({ longitude: 56.7, latitude: 12.78, height: 100 })})"); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testCypherExportCsvForAdminNeo4jImportWithCompressionNone() { String fileBaseName = "query_nodes_no_compress_and_Ext"; diff --git a/core/src/test/java/apoc/export/csv/ExportCsvTest.java b/core/src/test/java/apoc/export/csv/ExportCsvTest.java index 2cb814419..60a2a7791 100644 --- a/core/src/test/java/apoc/export/csv/ExportCsvTest.java +++ b/core/src/test/java/apoc/export/csv/ExportCsvTest.java @@ -27,6 +27,7 @@ import apoc.util.TestUtil; import apoc.util.Util; import apoc.util.collection.Iterators; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -158,6 +159,11 @@ public static void setUp() { db.executeTransactionally("CREATE (f:Address1:Address {name:'Andrea', city: 'Milano', street:'Via Garibaldi, 7'})-[:NEXT_DELIVERY]->(a:Address {name: 'Bar Sport'}), (b:Address {street: 'via Benni'})"); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + private String readFile(String fileName) { return readFile(fileName, UTF_8, CompressionAlgo.NONE); } diff --git a/core/src/test/java/apoc/export/csv/ImportCsvLdbcTest.java b/core/src/test/java/apoc/export/csv/ImportCsvLdbcTest.java index b43dd6bb2..e4c48fd1b 100644 --- a/core/src/test/java/apoc/export/csv/ImportCsvLdbcTest.java +++ b/core/src/test/java/apoc/export/csv/ImportCsvLdbcTest.java @@ -20,6 +20,7 @@ import apoc.csv.CsvTestUtil; import apoc.util.TestUtil; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -146,6 +147,11 @@ public void setUp() throws Exception { apocConfig().setProperty(APOC_EXPORT_FILE_ENABLED, true); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testLdbc() { final List> nodes = new ArrayList<>(); diff --git a/core/src/test/java/apoc/export/csv/ImportCsvTest.java b/core/src/test/java/apoc/export/csv/ImportCsvTest.java index 678806999..2df6c696f 100644 --- a/core/src/test/java/apoc/export/csv/ImportCsvTest.java +++ b/core/src/test/java/apoc/export/csv/ImportCsvTest.java @@ -22,6 +22,7 @@ import apoc.util.CompressionAlgo; import apoc.util.TestUtil; import org.apache.commons.io.FileUtils; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -254,6 +255,11 @@ public void setUp() throws IOException { apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true); apocConfig().setProperty(APOC_EXPORT_FILE_ENABLED, true); } + + @After + public void teardown() { + db.shutdown(); + } @Test public void testImportCsvLargeFile() { diff --git a/core/src/test/java/apoc/export/cypher/ExportCypherMultiRelTest.java b/core/src/test/java/apoc/export/cypher/ExportCypherMultiRelTest.java index 2eeccfd97..3a5e02a7a 100644 --- a/core/src/test/java/apoc/export/cypher/ExportCypherMultiRelTest.java +++ b/core/src/test/java/apoc/export/cypher/ExportCypherMultiRelTest.java @@ -21,6 +21,7 @@ import apoc.cypher.Cypher; import apoc.util.TestUtil; import apoc.util.collection.Iterators; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -80,7 +81,12 @@ public void setUp() { "(pers)-[:IS_TEAM_MEMBER_OF {name: 'eee'}]->(:Team {name: 'two'})"); } - + + @After + public void teardown() { + db.shutdown(); + } + @Test public void updateAllOptimizationNone() { String expectedCypherStatement = NODES_MULTI_RELS + SCHEMA_WITH_UNIQUE_IMPORT_ID + RELS_MULTI_RELS + CLEANUP_SMALL_BATCH; diff --git a/core/src/test/java/apoc/export/cypher/ExportCypherTest.java b/core/src/test/java/apoc/export/cypher/ExportCypherTest.java index 5f60603e8..0ad6b64cd 100644 --- a/core/src/test/java/apoc/export/cypher/ExportCypherTest.java +++ b/core/src/test/java/apoc/export/cypher/ExportCypherTest.java @@ -24,6 +24,7 @@ import apoc.util.MapUtil; import apoc.util.TestUtil; import apoc.util.Util; +import org.junit.After; import org.junit.Assert; import java.util.ArrayList; @@ -105,6 +106,11 @@ public void setUp() { ExportCypherTestUtils.setUp(db, testName); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testRoundTripCypherExportAll() { final String cypherStatements = Util.readResourceFile("exportAll.cypher"); diff --git a/core/src/test/java/apoc/export/graphml/ExportGraphMLTest.java b/core/src/test/java/apoc/export/graphml/ExportGraphMLTest.java index 883ce4719..07a41d9a9 100644 --- a/core/src/test/java/apoc/export/graphml/ExportGraphMLTest.java +++ b/core/src/test/java/apoc/export/graphml/ExportGraphMLTest.java @@ -27,6 +27,7 @@ import junit.framework.TestCase; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.StringUtils; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -109,6 +110,11 @@ public void setUp() { setUpGraphMl(db, testName); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testImportGraphML() throws Exception { db.executeTransactionally("MATCH (n) DETACH DELETE n"); diff --git a/core/src/test/java/apoc/export/json/ExportJsonTest.java b/core/src/test/java/apoc/export/json/ExportJsonTest.java index 7e90f916c..8024fae70 100644 --- a/core/src/test/java/apoc/export/json/ExportJsonTest.java +++ b/core/src/test/java/apoc/export/json/ExportJsonTest.java @@ -24,6 +24,7 @@ import apoc.util.FileTestUtil; import apoc.util.TestUtil; import apoc.util.Util; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -99,6 +100,11 @@ public void setup() { """); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testExportAllJson() { String filename = "all.json"; diff --git a/core/src/test/java/apoc/export/json/ImportJsonTest.java b/core/src/test/java/apoc/export/json/ImportJsonTest.java index 76ee5007e..559ec9dcc 100644 --- a/core/src/test/java/apoc/export/json/ImportJsonTest.java +++ b/core/src/test/java/apoc/export/json/ImportJsonTest.java @@ -28,6 +28,7 @@ import junit.framework.TestCase; import org.apache.commons.lang3.exception.ExceptionUtils; import apoc.util.Utils; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -88,7 +89,12 @@ public void setUp() { TestUtil.registerProcedure(db, ImportJson.class, Schemas.class, Utils.class); apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true); } - + + @After + public void teardown() { + db.shutdown(); + } + @Test public void shouldImportAllJsonWithoutImportId() { shouldImportAllCommon(map("cleanup", true), 8, 0L); diff --git a/core/src/test/java/apoc/graph/GraphsTest.java b/core/src/test/java/apoc/graph/GraphsTest.java index 0b7827ad5..5a03086ea 100644 --- a/core/src/test/java/apoc/graph/GraphsTest.java +++ b/core/src/test/java/apoc/graph/GraphsTest.java @@ -25,6 +25,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.math.NumberUtils; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -93,6 +94,11 @@ public void setUp() { }); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testFromData() { TestUtil.testCall(db,"MATCH (n)-[r]->(m) CALL apoc.graph.fromData([n,m],[r],'test',{answer:42}) YIELD graph RETURN *", diff --git a/core/src/test/java/apoc/hashing/FingerprintingTest.java b/core/src/test/java/apoc/hashing/FingerprintingTest.java index ac25f971d..ef1ec4eca 100644 --- a/core/src/test/java/apoc/hashing/FingerprintingTest.java +++ b/core/src/test/java/apoc/hashing/FingerprintingTest.java @@ -23,6 +23,7 @@ import apoc.util.TestUtil; import apoc.util.Util; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -55,6 +56,11 @@ public void setup() { TestUtil.registerProcedure(db, Fingerprinting.class, Graphs.class, Coll.class); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void fingerprintScalars() { diff --git a/core/src/test/java/apoc/help/HelpTest.java b/core/src/test/java/apoc/help/HelpTest.java index f0a506f8f..a10d26774 100644 --- a/core/src/test/java/apoc/help/HelpTest.java +++ b/core/src/test/java/apoc/help/HelpTest.java @@ -23,6 +23,7 @@ import apoc.create.Create; import apoc.diff.Diff; import apoc.util.TestUtil; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -48,6 +49,11 @@ public void setUp() { TestUtil.registerProcedure(db, Help.class, BitwiseOperations.class, Coll.class, Diff.class, Create.class); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void info() { TestUtil.testCall(db,"CALL apoc.help($text)",map("text","bitwise"), (row) -> { diff --git a/core/src/test/java/apoc/index/SchemaIndexTest.java b/core/src/test/java/apoc/index/SchemaIndexTest.java index cee7f7e7e..8e0e99094 100644 --- a/core/src/test/java/apoc/index/SchemaIndexTest.java +++ b/core/src/test/java/apoc/index/SchemaIndexTest.java @@ -19,6 +19,7 @@ package apoc.index; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -108,6 +109,11 @@ public static void setUp() { } } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testDistinctPropertiesOnFirstIndex() { testCall(db,"CALL apoc.schema.properties.distinct($label, $key)", diff --git a/core/src/test/java/apoc/label/LabelTest.java b/core/src/test/java/apoc/label/LabelTest.java index 36be49311..ec6d7487c 100644 --- a/core/src/test/java/apoc/label/LabelTest.java +++ b/core/src/test/java/apoc/label/LabelTest.java @@ -19,6 +19,7 @@ package apoc.label; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -38,6 +39,11 @@ public static void setUp() { TestUtil.registerProcedure(db, Label.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testVerifyNodeLabelExistence() { diff --git a/core/src/test/java/apoc/load/LoadJsonTest.java b/core/src/test/java/apoc/load/LoadJsonTest.java index bf50cd4ec..40283d6fe 100644 --- a/core/src/test/java/apoc/load/LoadJsonTest.java +++ b/core/src/test/java/apoc/load/LoadJsonTest.java @@ -105,6 +105,7 @@ public static void stopServer() { @After public void cleanup() { server.stop(0); + db.shutdown(); } @Test public void testLoadJson() { diff --git a/core/src/test/java/apoc/load/XmlTest.java b/core/src/test/java/apoc/load/XmlTest.java index 614b01ef3..a668f6185 100644 --- a/core/src/test/java/apoc/load/XmlTest.java +++ b/core/src/test/java/apoc/load/XmlTest.java @@ -84,6 +84,7 @@ public void setUp() throws IOException { @After public void cleanup() { server.stop(0); + db.shutdown(); } @Test diff --git a/core/src/test/java/apoc/load/relative/LoadRelativePathTest.java b/core/src/test/java/apoc/load/relative/LoadRelativePathTest.java index 4d7452143..75cb5e84a 100644 --- a/core/src/test/java/apoc/load/relative/LoadRelativePathTest.java +++ b/core/src/test/java/apoc/load/relative/LoadRelativePathTest.java @@ -21,6 +21,7 @@ import apoc.load.LoadJson; import apoc.load.Xml; import apoc.util.TestUtil; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -58,6 +59,11 @@ public void setUp() { apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true); } + @After + public void teardown() { + db.shutdown(); + } + //JSON @Test public void testLoadRelativePathJson() { String url = "file:/map.json"; diff --git a/core/src/test/java/apoc/lock/LockTest.java b/core/src/test/java/apoc/lock/LockTest.java index 23845d9c6..9cafa288c 100644 --- a/core/src/test/java/apoc/lock/LockTest.java +++ b/core/src/test/java/apoc/lock/LockTest.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import apoc.util.collection.Iterators; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -48,6 +49,11 @@ public static void setUp() { TestUtil.registerProcedure(db, Lock.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void shouldReadLockBlockAWrite() throws Exception { diff --git a/core/src/test/java/apoc/log/Neo4jLogStreamTest.java b/core/src/test/java/apoc/log/Neo4jLogStreamTest.java index 9ad4b6153..de16e7c1e 100644 --- a/core/src/test/java/apoc/log/Neo4jLogStreamTest.java +++ b/core/src/test/java/apoc/log/Neo4jLogStreamTest.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import apoc.util.collection.Iterators; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.neo4j.configuration.GraphDatabaseSettings; @@ -36,18 +37,24 @@ import static org.junit.Assert.assertTrue; public class Neo4jLogStreamTest { - + private GraphDatabaseService db; + private DatabaseManagementService dbManagementService; @Before public void setUp() { - DatabaseManagementService dbManagementService = new TestDatabaseManagementServiceBuilder( + dbManagementService = new TestDatabaseManagementServiceBuilder( Paths.get("target", UUID.randomUUID().toString()).toAbsolutePath()).build(); apocConfig().setProperty("server.directories.logs", ""); db = dbManagementService.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME); TestUtil.registerProcedure(db, Neo4jLogStream.class); } - + + @After + public void teardown() { + dbManagementService.shutdown(); + } + @Test public void testLogStream() { testResult(db, "CALL apoc.log.stream('debug.log')", res -> { diff --git a/core/src/test/java/apoc/map/MapsTest.java b/core/src/test/java/apoc/map/MapsTest.java index a6928e637..45b1914ee 100644 --- a/core/src/test/java/apoc/map/MapsTest.java +++ b/core/src/test/java/apoc/map/MapsTest.java @@ -19,6 +19,7 @@ package apoc.map; import apoc.util.TestUtil; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -50,6 +51,11 @@ public void setUp() { TestUtil.registerProcedure(db,Maps.class); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testFromNodes() { db.executeTransactionally("UNWIND range(1,3) as id create (:Person {name:'name'+id})"); diff --git a/core/src/test/java/apoc/math/MathsTest.java b/core/src/test/java/apoc/math/MathsTest.java index deed5672e..d9c3a7855 100644 --- a/core/src/test/java/apoc/math/MathsTest.java +++ b/core/src/test/java/apoc/math/MathsTest.java @@ -19,6 +19,7 @@ package apoc.math; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -39,6 +40,11 @@ public class MathsTest { TestUtil.registerProcedure(db,Maths.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testMaxLong(){ testCall(db, "RETURN apoc.math.maxLong() as max",(row) -> assertEquals(Long.MAX_VALUE,row.get("max"))); } diff --git a/core/src/test/java/apoc/math/RegressionTest.java b/core/src/test/java/apoc/math/RegressionTest.java index 55bf6e4f6..f823e1d7a 100644 --- a/core/src/test/java/apoc/math/RegressionTest.java +++ b/core/src/test/java/apoc/math/RegressionTest.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import org.apache.commons.math3.stat.regression.SimpleRegression; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -41,6 +42,11 @@ public static void setUp() { TestUtil.registerProcedure(db, Regression.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testCalculateRegr() { db.executeTransactionally("CREATE " + diff --git a/core/src/test/java/apoc/merge/MergeTest.java b/core/src/test/java/apoc/merge/MergeTest.java index e6290d2b8..dadee9376 100644 --- a/core/src/test/java/apoc/merge/MergeTest.java +++ b/core/src/test/java/apoc/merge/MergeTest.java @@ -21,6 +21,7 @@ import apoc.util.MapUtil; import apoc.util.TestUtil; import apoc.util.collection.Iterators; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -45,6 +46,11 @@ public void setUp() { TestUtil.registerProcedure(db, Merge.class); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testMergeNode() { testMergeNodeCommon(false); diff --git a/core/src/test/java/apoc/meta/MetaTest.java b/core/src/test/java/apoc/meta/MetaTest.java index f7b315b0e..9dc24b435 100644 --- a/core/src/test/java/apoc/meta/MetaTest.java +++ b/core/src/test/java/apoc/meta/MetaTest.java @@ -25,6 +25,7 @@ import apoc.util.collection.Iterables; import org.apache.commons.io.IOUtils; import org.assertj.core.api.Assertions; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -82,6 +83,11 @@ public void setUp() { TestUtil.registerProcedure(db, Meta.class, Graphs.class); } + @After + public void teardown() { + db.shutdown(); + } + public static boolean hasRecordMatching(List> records, Map record) { return hasRecordMatching(records, row -> { boolean okSoFar = true; diff --git a/core/src/test/java/apoc/neighbors/NeighborsTest.java b/core/src/test/java/apoc/neighbors/NeighborsTest.java index 9216c99f5..515899d60 100644 --- a/core/src/test/java/apoc/neighbors/NeighborsTest.java +++ b/core/src/test/java/apoc/neighbors/NeighborsTest.java @@ -19,6 +19,7 @@ package apoc.neighbors; import apoc.util.TestUtil; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -50,6 +51,11 @@ public void setUp() { "(c)-[:KNOWS]->(d) "); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void getNeighbors2Hops() { TestUtil.testCall(db, "MATCH (n:First) WITH n " + diff --git a/core/src/test/java/apoc/nodes/GroupingTest.java b/core/src/test/java/apoc/nodes/GroupingTest.java index b66cf43a9..26fc2878f 100644 --- a/core/src/test/java/apoc/nodes/GroupingTest.java +++ b/core/src/test/java/apoc/nodes/GroupingTest.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import apoc.util.collection.Iterators; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -50,6 +51,11 @@ public void setUp() { TestUtil.registerProcedure(db, Grouping.class); } + @After + public void teardown() { + db.shutdown(); + } + public void createGraph() { db.executeTransactionally("CREATE " + "(alice:Person {name:'Alice', gender:'female', age:32, kids:1})," + diff --git a/core/src/test/java/apoc/nodes/NodesTest.java b/core/src/test/java/apoc/nodes/NodesTest.java index 1267cb09d..24d4177f5 100644 --- a/core/src/test/java/apoc/nodes/NodesTest.java +++ b/core/src/test/java/apoc/nodes/NodesTest.java @@ -25,6 +25,7 @@ import apoc.util.Util; import apoc.util.collection.Iterables; import apoc.util.collection.Iterators; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -79,6 +80,11 @@ public void setUp() { TestUtil.registerProcedure(db, Nodes.class, Create.class); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void isDense() { db.executeTransactionally("CREATE (f:Foo) CREATE (b:Bar) WITH f UNWIND range(1,100) as id CREATE (f)-[:SELF]->(f)"); diff --git a/core/src/test/java/apoc/number/ArabicRomanTest.java b/core/src/test/java/apoc/number/ArabicRomanTest.java index 9c033b1a9..524ace944 100644 --- a/core/src/test/java/apoc/number/ArabicRomanTest.java +++ b/core/src/test/java/apoc/number/ArabicRomanTest.java @@ -19,6 +19,7 @@ package apoc.number; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -40,6 +41,11 @@ public static void setUp() { TestUtil.registerProcedure(db, ArabicRoman.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testToArabic() { testCall(db, "RETURN apoc.number.romanToArabic('MCMXXXII') AS value", row -> assertEquals(1932, row.get("value"))); diff --git a/core/src/test/java/apoc/number/NumbersTest.java b/core/src/test/java/apoc/number/NumbersTest.java index 1693a59be..c9db5fe84 100644 --- a/core/src/test/java/apoc/number/NumbersTest.java +++ b/core/src/test/java/apoc/number/NumbersTest.java @@ -19,6 +19,7 @@ package apoc.number; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -48,6 +49,11 @@ public static void sUp() { TestUtil.registerProcedure(db, Numbers.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testFormat() { testCall(db, "RETURN apoc.number.format(12345) AS value", row -> assertEquals("12,345", row.get("value"))); diff --git a/core/src/test/java/apoc/number/exact/ExactTest.java b/core/src/test/java/apoc/number/exact/ExactTest.java index 02ff52bc3..83141ffa2 100644 --- a/core/src/test/java/apoc/number/exact/ExactTest.java +++ b/core/src/test/java/apoc/number/exact/ExactTest.java @@ -19,6 +19,7 @@ package apoc.number.exact; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -48,6 +49,11 @@ public class ExactTest { TestUtil.registerProcedure(db, Exact.class); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testAdd(){ testCall(db,"return apoc.number.exact.add('1213669989','1238126387') as value", row -> assertEquals("2451796376", row.get("value"))); diff --git a/core/src/test/java/apoc/path/ExpandPathTest.java b/core/src/test/java/apoc/path/ExpandPathTest.java index f6b18f896..3f7d3d5a2 100644 --- a/core/src/test/java/apoc/path/ExpandPathTest.java +++ b/core/src/test/java/apoc/path/ExpandPathTest.java @@ -25,6 +25,7 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.After; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -63,7 +64,12 @@ public static void setUp() { } } - @After + @AfterClass + public static void teardown() { + db.shutdown(); + } + + @After public void removeOtherLabels() { db.executeTransactionally("OPTIONAL MATCH (c:Western) REMOVE c:Western WITH DISTINCT 1 as ignore OPTIONAL MATCH (c:Denylist) REMOVE c:Denylist"); } diff --git a/core/src/test/java/apoc/path/LabelSequenceTest.java b/core/src/test/java/apoc/path/LabelSequenceTest.java index 932f0f1d0..d6e4da734 100644 --- a/core/src/test/java/apoc/path/LabelSequenceTest.java +++ b/core/src/test/java/apoc/path/LabelSequenceTest.java @@ -19,6 +19,7 @@ package apoc.path; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -46,6 +47,11 @@ public static void setUp() { db.executeTransactionally("create (s:Start{name:'start'})-[:REL]->(:A{name:'a'})-[:REL]->(:B{name:'b'})-[:REL]->(:A:C{name:'ac'})-[:REL]->(:B:A{name:'ba'})-[:REL]->(:D:A{name:'da'})"); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testBasicSequence() { String query = "MATCH (s:Start {name: 'start'}) CALL apoc.path.subgraphNodes(s,{labelFilter:'A,B', beginSequenceAtStart:false}) yield node return collect(distinct node.name) as nodes"; diff --git a/core/src/test/java/apoc/path/NodeFilterTest.java b/core/src/test/java/apoc/path/NodeFilterTest.java index bb269e8b5..7f63e9090 100644 --- a/core/src/test/java/apoc/path/NodeFilterTest.java +++ b/core/src/test/java/apoc/path/NodeFilterTest.java @@ -22,6 +22,7 @@ import apoc.util.Util; import apoc.util.collection.Iterators; import org.junit.After; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -53,6 +54,11 @@ public static void setUp() { } } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @After public void removeOtherLabels() { db.executeTransactionally("OPTIONAL MATCH (c:Western) REMOVE c:Western WITH DISTINCT 1 as ignore OPTIONAL MATCH (c:Denylist) REMOVE c:Denylist"); diff --git a/core/src/test/java/apoc/path/PathsTest.java b/core/src/test/java/apoc/path/PathsTest.java index f2a8d10a8..46d80e982 100644 --- a/core/src/test/java/apoc/path/PathsTest.java +++ b/core/src/test/java/apoc/path/PathsTest.java @@ -19,6 +19,7 @@ package apoc.path; import apoc.util.TestUtil; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -46,6 +47,11 @@ public static void setUp() { db.executeTransactionally("CREATE (a:A)-[:NEXT]->(b:B)-[:NEXT]->(c:C)-[:NEXT]->(d:D)"); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void createFull() { TestUtil.testCall(db, "MATCH path = (a:A)-[:NEXT*]->(d:D) RETURN apoc.path.create(a, relationships(path)) as p",(row) -> assertPath(row, 3, "A", "D")); diff --git a/core/src/test/java/apoc/path/RelSequenceTest.java b/core/src/test/java/apoc/path/RelSequenceTest.java index 7113b01c9..79e92b295 100644 --- a/core/src/test/java/apoc/path/RelSequenceTest.java +++ b/core/src/test/java/apoc/path/RelSequenceTest.java @@ -21,6 +21,7 @@ import apoc.util.TestUtil; import apoc.util.Util; import apoc.util.collection.Iterators; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -54,6 +55,11 @@ public static void setUp() { } } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testBasicRelSequence() { String query = "MATCH (t:Person {name: 'Tom Hanks'}) CALL apoc.path.expandConfig(t,{relationshipFilter:'ACTED_IN>,Person,Movie'}) yield path with distinct last(nodes(path)) as node return collect(node.name) as names"; diff --git a/core/src/test/java/apoc/path/SequenceTest.java b/core/src/test/java/apoc/path/SequenceTest.java index ef1ff48d2..bccd8f2a8 100644 --- a/core/src/test/java/apoc/path/SequenceTest.java +++ b/core/src/test/java/apoc/path/SequenceTest.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import apoc.util.Util; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -51,6 +52,11 @@ public static void setUp() { } } + @AfterClass + public static void teardown() { + db.shutdown(); + } + @Test public void testBasicSequence() { String query = "MATCH (t:Person {name: 'Tom Hanks'}) CALL apoc.path.expandConfig(t,{sequence:'>Person, ACTED_IN>, Movie, (p)\n" diff --git a/it/src/test/java/apoc/it/core/ApocSplitTest.java b/it/src/test/java/apoc/it/core/ApocSplitTest.java index f29e9662a..c9196584a 100644 --- a/it/src/test/java/apoc/it/core/ApocSplitTest.java +++ b/it/src/test/java/apoc/it/core/ApocSplitTest.java @@ -486,6 +486,7 @@ public void test() { Assert.assertEquals(CORE_PROCEDURES, procedureNames); Assert.assertEquals(CORE_FUNCTIONS, functionNames); + session.close(); neo4jContainer.close(); } } diff --git a/it/src/test/java/apoc/it/core/ExportCsvIT.java b/it/src/test/java/apoc/it/core/ExportCsvIT.java index e04ebcaf0..f7a0b6a1a 100644 --- a/it/src/test/java/apoc/it/core/ExportCsvIT.java +++ b/it/src/test/java/apoc/it/core/ExportCsvIT.java @@ -51,6 +51,7 @@ public static void beforeAll() { @AfterClass public static void afterAll() { + session.close(); neo4jContainer.close(); } diff --git a/it/src/test/java/apoc/it/core/ExportCsvS3Test.java b/it/src/test/java/apoc/it/core/ExportCsvS3Test.java index 5aa55b8ef..05e509f26 100644 --- a/it/src/test/java/apoc/it/core/ExportCsvS3Test.java +++ b/it/src/test/java/apoc/it/core/ExportCsvS3Test.java @@ -22,6 +22,7 @@ import apoc.graph.Graphs; import apoc.util.TestUtil; import apoc.util.s3.S3BaseTest; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -52,6 +53,11 @@ public static void setUp() { db.executeTransactionally("CREATE (f:Address1:Address {name:'Andrea', city: 'Milano', street:'Via Garibaldi, 7'})-[:NEXT_DELIVERY]->(a:Address {name: 'Bar Sport'}), (b:Address {street: 'via Benni'})"); } + @AfterClass + public static void teardown() { + db.shutdown(); + } + private static final String EXPECTED_QUERY_NODES = String.format("\"u\"%n" + "\"{\"\"id\"\":0,\"\"labels\"\":[\"\"User\"\",\"\"User1\"\"],\"\"properties\"\":{\"\"name\"\":\"\"foo\"\",\"\"age\"\":42,\"\"male\"\":true,\"\"kids\"\":[\"\"a\"\",\"\"b\"\",\"\"c\"\"]}}\"%n" + "\"{\"\"id\"\":1,\"\"labels\"\":[\"\"User\"\"],\"\"properties\"\":{\"\"name\"\":\"\"bar\"\",\"\"age\"\":42}}\"%n" + diff --git a/it/src/test/java/apoc/it/core/ExportCypherS3Test.java b/it/src/test/java/apoc/it/core/ExportCypherS3Test.java index a445a1a6d..b1b19eaa7 100644 --- a/it/src/test/java/apoc/it/core/ExportCypherS3Test.java +++ b/it/src/test/java/apoc/it/core/ExportCypherS3Test.java @@ -22,6 +22,7 @@ import apoc.util.TestUtil; import apoc.util.s3.S3BaseTest; import apoc.util.s3.S3TestUtil; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -51,6 +52,11 @@ public void setUp() { ExportCypherTestUtils.setUp(db, testName); } + @After + public void teardown() { + db.shutdown(); + } + // -- Whole file test -- // @Test public void testExportAllCypherDefault() { diff --git a/it/src/test/java/apoc/it/core/ExportGraphMLS3Test.java b/it/src/test/java/apoc/it/core/ExportGraphMLS3Test.java index 90c752b1e..822bd9d9c 100644 --- a/it/src/test/java/apoc/it/core/ExportGraphMLS3Test.java +++ b/it/src/test/java/apoc/it/core/ExportGraphMLS3Test.java @@ -20,6 +20,7 @@ import apoc.util.TestUtil; import apoc.util.s3.S3BaseTest; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -54,6 +55,11 @@ public void setUp() { setUpGraphMl(db, testName); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testExportAllGraphML() { String fileName = "all.graphml"; diff --git a/it/src/test/java/apoc/it/core/ExportJsonS3Test.java b/it/src/test/java/apoc/it/core/ExportJsonS3Test.java index e2ff94163..110a50a27 100644 --- a/it/src/test/java/apoc/it/core/ExportJsonS3Test.java +++ b/it/src/test/java/apoc/it/core/ExportJsonS3Test.java @@ -22,6 +22,7 @@ import apoc.graph.Graphs; import apoc.util.TestUtil; import apoc.util.s3.S3BaseTest; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -55,6 +56,11 @@ public void setUp() { db.executeTransactionally("CREATE (f:User {name:'Adam',age:42,male:true,kids:['Sam','Anna','Grace'], born:localdatetime('2015185T19:32:24'), place:point({latitude: 13.1, longitude: 33.46789})})-[:KNOWS {since: 1993, bffSince: duration('P5M1.5D')}]->(b:User {name:'Jim',age:42}),(c:User {age:12})"); } + @After + public void teardown() { + db.shutdown(); + } + @Test public void testExportAllJson() { String filename = "all.json"; diff --git a/it/src/test/java/apoc/it/core/StartupTest.java b/it/src/test/java/apoc/it/core/StartupTest.java index 4282025c8..e114c8dfb 100644 --- a/it/src/test/java/apoc/it/core/StartupTest.java +++ b/it/src/test/java/apoc/it/core/StartupTest.java @@ -70,6 +70,7 @@ public void check_basic_deployment() { assertFalse(startupLog.contains("SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\"")); assertFalse(startupLog.contains("SLF4J: Class path contains multiple SLF4J providers")); + session.close(); neo4jContainer.close(); } catch (Exception ex) { // if Testcontainers wasn't able to retrieve the docker image we ignore the test