From d5e5c805951d7f6348a809a7c3b59038f2acd781 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Fri, 15 Feb 2019 17:09:51 +0100 Subject: [PATCH 1/2] Add additional convenience methods for Neo4j containers. --- docs/modules/databases/neo4j.md | 70 ++++++++++++++++ modules/neo4j/build.gradle | 26 ++++++ .../neo4j/demos/plugins/HelloWorld.java | 15 ++++ .../containers/Neo4jContainer.java | 67 +++++++++++++++ .../containers/Neo4jContainerTest.java | 79 +++++++++++++++++- .../src/test/resources/test-graph.db/neostore | Bin 0 -> 8192 bytes .../test-graph.db/neostore.counts.db.a | Bin 0 -> 96 bytes .../test-graph.db/neostore.counts.db.b | Bin 0 -> 160 bytes .../test/resources/test-graph.db/neostore.id | Bin 0 -> 9 bytes .../test-graph.db/neostore.labelscanstore.db | Bin 0 -> 49152 bytes .../test-graph.db/neostore.labeltokenstore.db | Bin 0 -> 8190 bytes .../neostore.labeltokenstore.db.id | Bin 0 -> 9 bytes .../neostore.labeltokenstore.db.names | Bin 0 -> 8192 bytes .../neostore.labeltokenstore.db.names.id | Bin 0 -> 9 bytes .../test-graph.db/neostore.nodestore.db | Bin 0 -> 8190 bytes .../test-graph.db/neostore.nodestore.db.id | Bin 0 -> 137 bytes .../neostore.nodestore.db.labels | Bin 0 -> 8192 bytes .../neostore.nodestore.db.labels.id | Bin 0 -> 9 bytes .../test-graph.db/neostore.propertystore.db | Bin 0 -> 8159 bytes .../neostore.propertystore.db.arrays | Bin 0 -> 8192 bytes .../neostore.propertystore.db.arrays.id | Bin 0 -> 161 bytes .../neostore.propertystore.db.id | Bin 0 -> 137 bytes .../neostore.propertystore.db.index | Bin 0 -> 8190 bytes .../neostore.propertystore.db.index.id | Bin 0 -> 9 bytes .../neostore.propertystore.db.index.keys | Bin 0 -> 8192 bytes .../neostore.propertystore.db.index.keys.id | Bin 0 -> 9 bytes .../neostore.propertystore.db.strings | Bin 0 -> 8192 bytes .../neostore.propertystore.db.strings.id | Bin 0 -> 9 bytes .../neostore.relationshipgroupstore.db | Bin 0 -> 8192 bytes .../neostore.relationshipgroupstore.db.id | Bin 0 -> 9 bytes .../neostore.relationshipstore.db | 0 .../neostore.relationshipstore.db.id | Bin 0 -> 9 bytes .../neostore.relationshiptypestore.db | 0 .../neostore.relationshiptypestore.db.id | Bin 0 -> 9 bytes .../neostore.relationshiptypestore.db.names | Bin 0 -> 8192 bytes ...neostore.relationshiptypestore.db.names.id | Bin 0 -> 9 bytes .../test-graph.db/neostore.schemastore.db | Bin 0 -> 8192 bytes .../test-graph.db/neostore.schemastore.db.id | Bin 0 -> 9 bytes .../test-graph.db/neostore.transaction.db.0 | Bin 0 -> 1150 bytes 39 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 modules/neo4j/src/custom-neo4j-plugin/java/ac/simons/neo4j/demos/plugins/HelloWorld.java create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.a create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.b create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.labelscanstore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db.names create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db.names.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.arrays create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.arrays.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.strings create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.strings.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db.id create mode 100644 modules/neo4j/src/test/resources/test-graph.db/neostore.transaction.db.0 diff --git a/docs/modules/databases/neo4j.md b/docs/modules/databases/neo4j.md index 6762d01a6a8..aaa18d225c9 100644 --- a/docs/modules/databases/neo4j.md +++ b/docs/modules/databases/neo4j.md @@ -68,6 +68,76 @@ public class ExampleTest { You are not limited to Unit tests and can of course use an instance of the Neo4j Testcontainer in vanilla Java code as well. +## Additional features + +### Disable authentication + +Authentication can be disabled: + +```java +@Testcontainers +public class ExampleTest { + + @Container + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withoutAuthentication(); +} +``` + +### Neo4j-Configuration + +Neo4j's Docker image needs Neo4j configuration options in a dedicated format. +The container takes care of that and you can configure the database with standard options like the following: + +```java +@Testcontainers +public class ExampleTest { + + @Container + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*"); +} +``` + +### Add custom plugins + +Custom plugins, like APOC, can be copied over to the container from any classpath or host resource like this: + +```java +@Testcontainers +public class ExampleTest { + + @Container + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withPlugins(MountableFile.forClasspathResource("/apoc-3.5.0.1-all.jar")); +} +``` + +Whole directories work as well: + +```java +@Testcontainers +public class ExampleTest { + + @Container + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withPlugins(MountableFile.forClasspathResource("/my-plugins")); +} +``` + +### Start the container with a predefined database + +If you have an existing database (`graph.db`) you want to work with, copy it over to the container like this: + +```java +@Testcontainers +public class ExampleTest { + + @Container + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); +} +``` ## Choose your Neo4j license diff --git a/modules/neo4j/build.gradle b/modules/neo4j/build.gradle index 74860e014a1..18f0ff0b718 100644 --- a/modules/neo4j/build.gradle +++ b/modules/neo4j/build.gradle @@ -1,6 +1,32 @@ description = "TestContainers :: Neo4j" +def generatedResourcesDir = new File(project.buildDir, "generated-resources") +def customNeo4jPluginDestinationDir = new File(generatedResourcesDir, "custom-plugins") + +sourceSets { + customNeo4jPlugin { + java { + srcDir 'src/custom-neo4j-plugin' + } + } + test { + resources { + srcDir generatedResourcesDir + } + } +} + +task customNeo4jPluginJar(type: Jar) { + from sourceSets.customNeo4jPlugin.output + archiveName = "hello-world.jar" + destinationDir = customNeo4jPluginDestinationDir +} + +test.dependsOn customNeo4jPluginJar + dependencies { + customNeo4jPluginCompileOnly "org.neo4j:neo4j:3.5.3" + compile project(":testcontainers") testCompile "org.neo4j.driver:neo4j-java-driver:1.7.2" diff --git a/modules/neo4j/src/custom-neo4j-plugin/java/ac/simons/neo4j/demos/plugins/HelloWorld.java b/modules/neo4j/src/custom-neo4j-plugin/java/ac/simons/neo4j/demos/plugins/HelloWorld.java new file mode 100644 index 00000000000..cbfcdc03a55 --- /dev/null +++ b/modules/neo4j/src/custom-neo4j-plugin/java/ac/simons/neo4j/demos/plugins/HelloWorld.java @@ -0,0 +1,15 @@ +package ac.simons.neo4j.demos.plugins; + +import org.neo4j.procedure.Description; +import org.neo4j.procedure.Name; +import org.neo4j.procedure.UserFunction; + +public class HelloWorld { + + @UserFunction("ac.simons.helloWorld") + @Description("Simple Hello World") + public String helloWorld(@Name("name") String name) { + + return "Hello, " + name; + } +} diff --git a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java index a8072d350ba..1aaaef0b55b 100644 --- a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java +++ b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java @@ -12,6 +12,7 @@ import org.testcontainers.containers.wait.strategy.WaitAllStrategy; import org.testcontainers.containers.wait.strategy.WaitStrategy; import org.testcontainers.utility.LicenseAcceptance; +import org.testcontainers.utility.MountableFile; /** * Testcontainer for Neo4j. @@ -164,10 +165,76 @@ public S withAdminPassword(final String adminPassword) { return self(); } + /** + * Disables authentication. + * + * @return This container. + */ + public S withoutAuthentication() { + return withAdminPassword(null); + } + + /** + * Copies an existing {@code graph.db} folder into the container. This can either be a classpath resource or a + * host resource. Please have a look at the factory methods in {@link MountableFile}. + *
+ * If you want to map your database into the container instead of copying them, please use {@code #withClasspathResourceMapping}, + * but this will only work when your test does not run in a container itself. + *
+ * Mapping would work like this: + *
+     *      @Container
+     *      private static final Neo4jContainer databaseServer = new Neo4jContainer<>()
+     *          .withClasspathResourceMapping("/test-graph.db", "/data/databases/graph.db", BindMode.READ_WRITE);
+     * 
+ * + * @param graphDb The graph.db folder to copy into the container + * @return This container. + */ + public S withDatabase(MountableFile graphDb) { + return withCopyFileToContainer(graphDb, "/data/databases/graph.db"); + } + + /** + * Adds plugins to the given directory to the container. If {@code plugins} denotes a directory, than all of that + * directory is mapped to Neo4j's plugins. Otherwise, single resources are copied over. + *
+ * If you want to map your plugins into the container instead of copying them, please use {@code #withClasspathResourceMapping}, + * but this will only work when your test does not run in a container itself. + * + * @param plugins + * @return This container. + */ + public S withPlugins(MountableFile plugins) { + return withCopyFileToContainer(plugins, "/var/lib/neo4j/plugins/"); + } + + /** + * Adds Neo4j configuration properties to the container. The properties can be added as in the official Neo4j + * configuration, the method automatically translate them into the format required by the Neo4j container. + * + * @param key The key to configure, i.e. {@code dbms.security.procedures.unrestricted} + * @param value The value to set + * @return This container. + */ + public S withNeo4jConfig(String key, String value) { + + addEnv(formatConfigurationKey(key), value); + return self(); + } + /** * @return The admin password for the neo4j account or literal null if auth is disabled. */ public String getAdminPassword() { return adminPassword; } + + static String formatConfigurationKey(String plainConfigKey) { + final String prefix = "NEO4J_"; + + return String.format("%s%s", prefix, plainConfigKey + .replaceAll("_", "__") + .replaceAll("\\.", "_")); + } } diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java index 5908ffbd80d..1e8d8acd479 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java @@ -10,7 +10,10 @@ import org.neo4j.driver.v1.AuthTokens; import org.neo4j.driver.v1.Driver; import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.testcontainers.utility.MountableFile; /** * Tests of functionality special to the Neo4jContainer. @@ -26,7 +29,7 @@ public class Neo4jContainerTest { public void shouldDisableAuthentication() { try ( - Neo4jContainer neo4jContainer = new Neo4jContainer().withAdminPassword(null); + Neo4jContainer neo4jContainer = new Neo4jContainer().withoutAuthentication(); ) { neo4jContainer.start(); try (Driver driver = getDriver(neo4jContainer); @@ -38,6 +41,63 @@ public void shouldDisableAuthentication() { } } + @Test + public void shouldCopyDatabase() { + try ( + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); + ) { + neo4jContainer.start(); + try ( + Driver driver = getDriver(neo4jContainer); + Session session = driver.session() + ) { + StatementResult result = session.run("MATCH (t:Thing) RETURN t"); + assertThat(result.list().stream().map(r -> r.get("t").get("name").asString())) + .containsExactlyInAnyOrder("Thing", "Thing 2", "Thing 3", "A box"); + } + } + } + + @Test + public void shouldCopyPlugins() { + try ( + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withPlugins(MountableFile.forClasspathResource("/custom-plugins")); + ) { + neo4jContainer.start(); + try ( + Driver driver = getDriver(neo4jContainer); + Session session = driver.session() + ) { + assertThatCustomPluginWasCopied(session); + } + } + } + + @Test + public void shouldCopyPlugin() { + try ( + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withPlugins(MountableFile.forClasspathResource("/custom-plugins/hello-world.jar")); + ) { + neo4jContainer.start(); + try ( + Driver driver = getDriver(neo4jContainer); + Session session = driver.session() + ) { + assertThatCustomPluginWasCopied(session); + } + } + } + + private static void assertThatCustomPluginWasCopied(Session session) { + StatementResult result = session.run("RETURN ac.simons.helloWorld('Testcontainers') AS greeting"); + Record singleRecord = result.single(); + assertThat(singleRecord).isNotNull(); + assertThat(singleRecord.get("greeting").asString()).isEqualTo("Hello, Testcontainers"); + } + @Test public void shouldCheckEnterpriseLicense() { assumeThat(Neo4jContainerTest.class.getResource(ACCEPTANCE_FILE_LOCATION)).isNull(); @@ -71,6 +131,23 @@ public void shouldRunEnterprise() { } } + @Test + public void shouldFormatPropertyKeys() { + + assertThat(Neo4jContainer.formatConfigurationKey("dbms.tx_log.rotation.size")) + .isEqualTo("NEO4J_dbms_tx__log_rotation_size"); + } + + @Test + public void shouldAddConfigToEnvironment() { + + Neo4jContainer neo4jContainer = new Neo4jContainer() + .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*"); + + assertThat(neo4jContainer.getEnvMap()) + .containsEntry("NEO4J_dbms_security_procedures_unrestricted", "apoc.*,algo.*"); + } + private static Driver getDriver(Neo4jContainer container) { AuthToken authToken = AuthTokens.none(); diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore b/modules/neo4j/src/test/resources/test-graph.db/neostore new file mode 100644 index 0000000000000000000000000000000000000000..cbd1bec5bd7d13e71951f0b0feadbfba88594e22 GIT binary patch literal 8192 zcmeIup$&vU5QX8H1So+rHdrJ@fIy%Tr>_LSp>XJ{fdZ}s6c#}ldnC8B1)%>i^OAYl zO+FRTz8$Yl*XI0sKWr*tETk%>t6cHU)Q7Q?SkOC!ckaqDf0o)#v11{5{mWCn$BzBU sMgRc>5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|00D%VrKgC5I9smFU literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.a b/modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.a new file mode 100644 index 0000000000000000000000000000000000000000..42f972e9874f08f0892f314608912e70ce393999 GIT binary patch literal 96 lcmZQzKm~rO`Of*Jc_qOm`9-M=Okt?9a2_L^g@f@Q3IMy=4T=B& literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.b b/modules/neo4j/src/test/resources/test-graph.db/neostore.counts.db.b new file mode 100644 index 0000000000000000000000000000000000000000..92ac40b0b5cd5d65d552f487b43782af1cf57704 GIT binary patch literal 160 zcmZQzKm~rO`Of*Jc_qOm`9-M=Okt?9a2_j+#Ry|yr&*BY{{sP|3;-3zrVDf{$|x%%}s5FkK+009C72oNAZ cfB*pk1PBlyK!5-N0t5&UAV7cs0RnFYemjl^G5`Po literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db.names.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.labeltokenstore.db.names.id new file mode 100644 index 0000000000000000000000000000000000000000..bdf13bc6a20a3e9db459fad0db82279367256087 GIT binary patch literal 9 LcmZQzfB+@{01E&E literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db new file mode 100644 index 0000000000000000000000000000000000000000..901a05100580e3bb88900c0132947c0c3c1565dc GIT binary patch literal 8190 zcmeIuu?YYm3`Ies3%LKXYETd-u(@9ZUdoHHR?d2flaZgB_06_3uMr?XfB*pk1PBly dK!5-N0t5&UAV7cs0RjXF5FkK+009EO1t!HQ5IX<> literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.id new file mode 100644 index 0000000000000000000000000000000000000000..9a0b5a4425b423bdb3b35b096cce4a75ec617632 GIT binary patch literal 137 tcmXZNw*i14001xsQ9+vE|F<%jED7QF`Ec~<%eRxW9~W0QcMrdwUK=ab0L=gZ literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels b/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels new file mode 100644 index 0000000000000000000000000000000000000000..df8ce2a58c7337a0be82febc80d3e0e21c414f96 GIT binary patch literal 8192 zcmeIu0Sy2E48x#GyMI;Ju>>SgT^KN6z<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK JfB^&30}mg#06_o% literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.nodestore.db.labels.id new file mode 100644 index 0000000000000000000000000000000000000000..102ef2455533af2377ffa5fb7481ab9dc0684c79 GIT binary patch literal 9 LcmZQzfB;4S015yC literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db new file mode 100644 index 0000000000000000000000000000000000000000..a2583744d0fc7704cc84b2d73f300f05832a49df GIT binary patch literal 8159 zcmeIuu?c`c3_P*aF#V3Im$DMVo>p60|yrtz) zY)WzaTHN1@QyWXU7{m3kkEqgTlK=q%1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 I2>e{&1U8{4&;S4c literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.arrays b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.arrays new file mode 100644 index 0000000000000000000000000000000000000000..5595acd18d12f2329c08828628c4e7bd42baec59 GIT binary patch literal 8192 zcmeIuu?c`s3NkP|*y$jy;WlorHfcWgg1l?O1p?tEIrCxWx6G-lo&Q9%;JAD-b1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ P009C72oNAZ;EBKhzrg?o literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.id new file mode 100644 index 0000000000000000000000000000000000000000..bdf13bc6a20a3e9db459fad0db82279367256087 GIT binary patch literal 9 LcmZQzfB+@{01E&E literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys new file mode 100644 index 0000000000000000000000000000000000000000..34c25065f4c2c1d6b76478898e266d7ab4ff5dcc GIT binary patch literal 8192 zcmeIup$&jA07TIf2qaUm7otHG5`tlRC<8PY t^SJt@hX4Tr1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oU&F-~poQ4OjpG literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.index.keys.id new file mode 100644 index 0000000000000000000000000000000000000000..df3610a3fa6bb3c111b158edfa7feddad03373d7 GIT binary patch literal 9 LcmZQzfBYwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK IfPv|O2On?%fdBvi literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.strings.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.propertystore.db.strings.id new file mode 100644 index 0000000000000000000000000000000000000000..102ef2455533af2377ffa5fb7481ab9dc0684c79 GIT binary patch literal 9 LcmZQzfB;4S015yC literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db new file mode 100644 index 0000000000000000000000000000000000000000..b72840ef50b6a432f92ecd6edaaf539fae606949 GIT binary patch literal 8192 zcmeIu0Sy2E48x#mx_@!ku>>SgT^KN6z<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK JfB^&30}o%s05bpp literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipgroupstore.db.id new file mode 100644 index 0000000000000000000000000000000000000000..102ef2455533af2377ffa5fb7481ab9dc0684c79 GIT binary patch literal 9 LcmZQzfB;4S015yC literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db new file mode 100644 index 00000000000..e69de29bb2d diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshipstore.db.id new file mode 100644 index 0000000000000000000000000000000000000000..bc8840b22b1bcf5594717cc39cf105953e00c24d GIT binary patch literal 9 KcmZQzfC2yj2><~A literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db new file mode 100644 index 00000000000..e69de29bb2d diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.id new file mode 100644 index 0000000000000000000000000000000000000000..bc8840b22b1bcf5594717cc39cf105953e00c24d GIT binary patch literal 9 KcmZQzfC2yj2><~A literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names new file mode 100644 index 0000000000000000000000000000000000000000..ce6529796feeb9afb9f2b4f981f75295e5542784 GIT binary patch literal 8192 zcmeIu0Sy2E48x$Rxqpe*u>>SgT^KN6z<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK JfB^&30}tQI04D$d literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.relationshiptypestore.db.names.id new file mode 100644 index 0000000000000000000000000000000000000000..102ef2455533af2377ffa5fb7481ab9dc0684c79 GIT binary patch literal 9 LcmZQzfB;4S015yC literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db b/modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db new file mode 100644 index 0000000000000000000000000000000000000000..df8ce2a58c7337a0be82febc80d3e0e21c414f96 GIT binary patch literal 8192 zcmeIu0Sy2E48x#GyMI;Ju>>SgT^KN6z<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK JfB^&30}mg#06_o% literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db.id b/modules/neo4j/src/test/resources/test-graph.db/neostore.schemastore.db.id new file mode 100644 index 0000000000000000000000000000000000000000..102ef2455533af2377ffa5fb7481ab9dc0684c79 GIT binary patch literal 9 LcmZQzfB;4S015yC literal 0 HcmV?d00001 diff --git a/modules/neo4j/src/test/resources/test-graph.db/neostore.transaction.db.0 b/modules/neo4j/src/test/resources/test-graph.db/neostore.transaction.db.0 new file mode 100644 index 0000000000000000000000000000000000000000..c7e1d7a4f9c66d16935f63ce4e87cd67ad57d621 GIT binary patch literal 1150 zcmZ`&Jxc>Y5Z#YUTmuOg1O<(VsAcdkogmg) zs;yj=IHvnt-khGtTsLk zC;}Au?rbcszkZ(RU(%4WiRgbbfZ3C0@(exBXx>_{oSd{pP&)$zySyt1|rDtJSXfD8v$nDYx`@$(`^qh88R1 zmY%zja{m-?t1@m{tc+XDb59Gnbs0C_z};kaqs&%Xg}qSRr*n%I;Qj$t=>hmf;cH+! zWUjhYsSpG;gXG8W{=5Ef_ih(5aCDsf1DLo#yZ`_I literal 0 HcmV?d00001 From a6228d0ba54650646d51e9536a14f0c0b7d7416d Mon Sep 17 00:00:00 2001 From: "Michael J. Simons" Date: Sat, 16 Feb 2019 21:41:09 +0100 Subject: [PATCH 2/2] Make format method private, adapt test. --- .../testcontainers/containers/Neo4jContainer.java | 2 +- .../containers/Neo4jContainerTest.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java index 1aaaef0b55b..fc545122219 100644 --- a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java +++ b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java @@ -230,7 +230,7 @@ public String getAdminPassword() { return adminPassword; } - static String formatConfigurationKey(String plainConfigKey) { + private static String formatConfigurationKey(String plainConfigKey) { final String prefix = "NEO4J_"; return String.format("%s%s", prefix, plainConfigKey diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java index 1e8d8acd479..cbbe5cb5729 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java @@ -131,21 +131,17 @@ public void shouldRunEnterprise() { } } - @Test - public void shouldFormatPropertyKeys() { - - assertThat(Neo4jContainer.formatConfigurationKey("dbms.tx_log.rotation.size")) - .isEqualTo("NEO4J_dbms_tx__log_rotation_size"); - } - @Test public void shouldAddConfigToEnvironment() { Neo4jContainer neo4jContainer = new Neo4jContainer() - .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*"); + .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*") + .withNeo4jConfig("dbms.tx_log.rotation.size", "42M"); assertThat(neo4jContainer.getEnvMap()) .containsEntry("NEO4J_dbms_security_procedures_unrestricted", "apoc.*,algo.*"); + assertThat(neo4jContainer.getEnvMap()) + .containsEntry("NEO4J_dbms_tx__log_rotation_size", "42M"); } private static Driver getDriver(Neo4jContainer container) {