Skip to content

Commit

Permalink
JAMES-2286 switch JDBC mailrepository to new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaechler authored and chibenwa committed Jan 15, 2018
1 parent d849f18 commit d885ffc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1210,6 +1210,12 @@
<artifactId>james-server-mailrepository-api</artifactId> <artifactId>james-server-mailrepository-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>james-server-mailrepository-api</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>james-server-mailets</artifactId> <artifactId>james-server-mailets</artifactId>
Expand Down
21 changes: 16 additions & 5 deletions server/data/data-jdbc/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>james-server-lifecycle-api</artifactId> <artifactId>james-server-lifecycle-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>james-server-mailrepository-api</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>james-server-util</artifactId> <artifactId>james-server-util</artifactId>
Expand Down Expand Up @@ -109,11 +115,6 @@
<groupId>javax.inject</groupId> <groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>javax.inject</artifactId>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.derby</groupId> <groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId> <artifactId>derby</artifactId>
Expand All @@ -128,6 +129,16 @@
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </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> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
Expand Down

This file was deleted.

Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,36 +19,51 @@


package org.apache.james.mailrepository.jdbc; package org.apache.james.mailrepository.jdbc;


import java.sql.SQLException;

import javax.sql.DataSource; import javax.sql.DataSource;


import org.apache.commons.configuration.DefaultConfigurationBuilder; import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.dbcp.BasicDataSource;
import org.apache.derby.jdbc.EmbeddedDriver; import org.apache.derby.jdbc.EmbeddedDriver;
import org.apache.james.filesystem.api.mock.MockFileSystem; 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.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 private JDBCMailRepository mailRepository;
protected MailRepository getMailRepository() throws Exception {
@BeforeEach
void init() throws Exception {
MockFileSystem fs = new MockFileSystem(); MockFileSystem fs = new MockFileSystem();
DataSource datasource = getDataSource(); DataSource datasource = getDataSource();
JDBCMailRepository mr = new JDBCMailRepository(); mailRepository = new JDBCMailRepository();


DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder(); DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
defaultConfiguration.addProperty("[@destinationURL]", "db://maildb/mr/testrepo"); defaultConfiguration.addProperty("[@destinationURL]", "db://maildb/mr/testrepo");
defaultConfiguration.addProperty("sqlFile", "file://conf/sqlResources.xml"); defaultConfiguration.addProperty("sqlFile", "file://conf/sqlResources.xml");
defaultConfiguration.addProperty("[@type]", "MAIL"); defaultConfiguration.addProperty("[@type]", "MAIL");
mr.setFileSystem(fs); mailRepository.setFileSystem(fs);
mr.setDatasource(datasource); mailRepository.setDatasource(datasource);
mr.configure(defaultConfiguration); mailRepository.configure(defaultConfiguration);
mr.init(); mailRepository.init();
return mr; }

@AfterEach
void tearDown() throws SQLException {
mailRepository.getConnection().prepareStatement("DELETE from " + mailRepository.tableName).execute();
LifecycleUtil.dispose(mailRepository);
} }


protected String getType() { @Override
return "db"; public MailRepository retrieveRepository() {
return mailRepository;
} }


private BasicDataSource getDataSource() { private BasicDataSource getDataSource() {
Expand All @@ -60,4 +75,9 @@ private BasicDataSource getDataSource() {
return ds; return ds;
} }


@Test
@Disabled("JAMES-2304 JDBC doesn't update the message Content")
@Override
public void storingMessageWithSameKeyTwiceShouldUpdateMessageContent() {
}
} }

0 comments on commit d885ffc

Please sign in to comment.