From d41748627d9abbc750bcd493a99313f0ed1264a7 Mon Sep 17 00:00:00 2001 From: Shashank Gowri Date: Fri, 1 Oct 2021 22:36:07 +0530 Subject: [PATCH] fix: updating database username to be in sync with the article (#11270) --- .../spring-data-arangodb/src/live-test/resources/Dockerfile | 4 ++++ .../src/live-test/resources/arangodb-setup.js | 4 ++++ .../src/live-test/resources/live-test-setup.sh | 2 ++ .../arangodb/configuration/ArangoDbConfiguration.java | 2 +- .../src/main/resources/arangodb.properties | 2 +- .../com/baeldung/arangodb/ArticleRepositoryLiveTest.java | 6 ++++++ 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 persistence-modules/spring-data-arangodb/src/live-test/resources/arangodb-setup.js diff --git a/persistence-modules/spring-data-arangodb/src/live-test/resources/Dockerfile b/persistence-modules/spring-data-arangodb/src/live-test/resources/Dockerfile index 8edb2bbbf6..6380d312a0 100644 --- a/persistence-modules/spring-data-arangodb/src/live-test/resources/Dockerfile +++ b/persistence-modules/spring-data-arangodb/src/live-test/resources/Dockerfile @@ -2,6 +2,10 @@ FROM arangodb:3.8.0 COPY init-session.js /docker-entrypoint-initdb.d/ +COPY arangodb-setup.js /setup/ + EXPOSE 8529 ENV ARANGO_ROOT_PASSWORD=password + +RUN chmod a+x /setup/arangodb-setup.js \ No newline at end of file diff --git a/persistence-modules/spring-data-arangodb/src/live-test/resources/arangodb-setup.js b/persistence-modules/spring-data-arangodb/src/live-test/resources/arangodb-setup.js new file mode 100644 index 0000000000..0c306ee5d5 --- /dev/null +++ b/persistence-modules/spring-data-arangodb/src/live-test/resources/arangodb-setup.js @@ -0,0 +1,4 @@ +#!/usr/bin/arangosh --javascript.execute + +print('creating database: baeldung-database & user: baeldung'); +db._createDatabase("baeldung-database", {}, [{ username: "baeldung", passwd: "password", active: true}]); \ No newline at end of file diff --git a/persistence-modules/spring-data-arangodb/src/live-test/resources/live-test-setup.sh b/persistence-modules/spring-data-arangodb/src/live-test/resources/live-test-setup.sh index b1a4cfb9d0..7f75fbd821 100644 --- a/persistence-modules/spring-data-arangodb/src/live-test/resources/live-test-setup.sh +++ b/persistence-modules/spring-data-arangodb/src/live-test/resources/live-test-setup.sh @@ -3,3 +3,5 @@ docker image build -t spring-data-arangodb:live-test . docker run -p 8529:8529 -e ARANGO_ROOT_PASSWORD=password --name spring-data-arangodb-live-test spring-data-arangodb:live-test + +docker exec spring-data-arangodb-live-test arangosh --server.password password --javascript.execute /setup/arangodb-setup.js \ No newline at end of file diff --git a/persistence-modules/spring-data-arangodb/src/main/java/com/baeldung/arangodb/configuration/ArangoDbConfiguration.java b/persistence-modules/spring-data-arangodb/src/main/java/com/baeldung/arangodb/configuration/ArangoDbConfiguration.java index 3aae10ce60..0042172ad6 100644 --- a/persistence-modules/spring-data-arangodb/src/main/java/com/baeldung/arangodb/configuration/ArangoDbConfiguration.java +++ b/persistence-modules/spring-data-arangodb/src/main/java/com/baeldung/arangodb/configuration/ArangoDbConfiguration.java @@ -13,7 +13,7 @@ public class ArangoDbConfiguration implements ArangoConfiguration { public ArangoDB.Builder arango() { return new ArangoDB.Builder() .host("127.0.0.1", 8529) - .user("root") + .user("baeldung") .password("password"); } diff --git a/persistence-modules/spring-data-arangodb/src/main/resources/arangodb.properties b/persistence-modules/spring-data-arangodb/src/main/resources/arangodb.properties index 7f8ded478c..2a6e667ecc 100644 --- a/persistence-modules/spring-data-arangodb/src/main/resources/arangodb.properties +++ b/persistence-modules/spring-data-arangodb/src/main/resources/arangodb.properties @@ -1,3 +1,3 @@ arangodb.hosts=127.0.0.1:8529 -arangodb.user=root +arangodb.user=baeldung arangodb.password=password \ No newline at end of file diff --git a/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java b/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java index 35232766ab..401e3393e8 100644 --- a/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java +++ b/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java @@ -2,6 +2,7 @@ package com.baeldung.arangodb; import com.baeldung.arangodb.model.Article; import com.baeldung.arangodb.repository.ArticleRepository; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -25,6 +26,11 @@ public class ArticleRepositoryLiveTest { @Autowired ArticleRepository articleRepository; + @AfterEach + public void tearDown(){ + articleRepository.deleteAll(); + } + @Test public void givenNewArticle_whenSaveInArangoDb_thenDataIsCorrect() { Article newArticle = new Article(