You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2018/01/15 09:56:04 UTC

[5/9] james-project git commit: JAMES-2286 switch JDBC mailrepository to new tests

JAMES-2286 switch JDBC mailrepository to new tests


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d885ffc9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d885ffc9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d885ffc9

Branch: refs/heads/master
Commit: d885ffc9b495d9e8e50d7e4fcdce1119d1b1bdb4
Parents: d849f18
Author: Matthieu Baechler <ma...@apache.org>
Authored: Wed Jan 10 18:07:47 2018 +0100
Committer: benwa <bt...@linagora.com>
Committed: Mon Jan 15 16:54:01 2018 +0700

----------------------------------------------------------------------
 pom.xml                                         |  6 +++
 server/data/data-jdbc/pom.xml                   | 21 +++++++---
 .../jdbc/JDBCDBFileMailRepositoryTest.java      | 29 -------------
 .../jdbc/JDBCMailRepositoryTest.java            | 44 ++++++++++++++------
 4 files changed, 54 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d885ffc9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7f4c8cc..8a125d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1212,6 +1212,12 @@
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
+                <artifactId>james-server-mailrepository-api</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
                 <artifactId>james-server-mailets</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/d885ffc9/server/data/data-jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/pom.xml b/server/data/data-jdbc/pom.xml
index e80b44d..6bd59e3 100644
--- a/server/data/data-jdbc/pom.xml
+++ b/server/data/data-jdbc/pom.xml
@@ -71,6 +71,12 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-mailrepository-api</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-util</artifactId>
         </dependency>
         <dependency>
@@ -110,11 +116,6 @@
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.derby</groupId>
             <artifactId>derby</artifactId>
             <scope>runtime</scope>
@@ -129,6 +130,16 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/d885ffc9/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java
deleted file mode 100644
index 84bc14a..0000000
--- a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailrepository.jdbc;
-
-public class JDBCDBFileMailRepositoryTest extends JDBCMailRepositoryTest {
-
-    @Override
-    protected String getType() {
-        return "dbfile";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/d885ffc9/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
index 13a42ce..adffb1e 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
@@ -19,36 +19,51 @@
 
 package org.apache.james.mailrepository.jdbc;
 
+import java.sql.SQLException;
+
 import javax.sql.DataSource;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.derby.jdbc.EmbeddedDriver;
 import org.apache.james.filesystem.api.mock.MockFileSystem;
-import org.apache.james.mailrepository.AbstractMailRepositoryTest;
+import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.james.mailrepository.MailRepositoryContract;
 import org.apache.james.mailrepository.api.MailRepository;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
-public class JDBCMailRepositoryTest extends AbstractMailRepositoryTest {
+public class JDBCMailRepositoryTest implements MailRepositoryContract {
 
-    @Override
-    protected MailRepository getMailRepository() throws Exception {
+    private JDBCMailRepository mailRepository;
+
+    @BeforeEach
+    void init() throws Exception {
         MockFileSystem fs = new MockFileSystem();
         DataSource datasource = getDataSource();
-        JDBCMailRepository mr = new JDBCMailRepository();
+        mailRepository = new JDBCMailRepository();
 
         DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
         defaultConfiguration.addProperty("[@destinationURL]", "db://maildb/mr/testrepo");
         defaultConfiguration.addProperty("sqlFile", "file://conf/sqlResources.xml");
         defaultConfiguration.addProperty("[@type]", "MAIL");
-        mr.setFileSystem(fs);
-        mr.setDatasource(datasource);
-        mr.configure(defaultConfiguration);
-        mr.init();
-        return mr;
+        mailRepository.setFileSystem(fs);
+        mailRepository.setDatasource(datasource);
+        mailRepository.configure(defaultConfiguration);
+        mailRepository.init();
+    }
+
+    @AfterEach
+    void tearDown() throws SQLException {
+        mailRepository.getConnection().prepareStatement("DELETE from " + mailRepository.tableName).execute();
+        LifecycleUtil.dispose(mailRepository);
     }
 
-    protected String getType() {
-        return "db";
+    @Override
+    public MailRepository retrieveRepository() {
+        return mailRepository;
     }
 
     private BasicDataSource getDataSource() {
@@ -60,4 +75,9 @@ public class JDBCMailRepositoryTest extends AbstractMailRepositoryTest {
         return ds;
     }
 
+    @Test
+    @Disabled("JAMES-2304 JDBC doesn't update the message Content")
+    @Override
+    public void storingMessageWithSameKeyTwiceShouldUpdateMessageContent() {
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org