JAMES-2441 Share common JPA guice modules
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/320f913d Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/320f913d Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/320f913d Branch: refs/heads/master Commit: 320f913db660a0d5d9eac57ab1e363f1fe13f23a Parents: e5bc7d6 Author: benwa <[email protected]> Authored: Wed Jun 27 13:23:29 2018 +0700 Committer: benwa <[email protected]> Committed: Mon Jul 2 11:48:52 2018 +0700 ---------------------------------------------------------------------- server/container/guice/jpa-common-guice/pom.xml | 5 ++ .../james/TestJPAConfigurationModule.java | 46 +++++++++++++++++ ...JPAConfigurationModuleWithSqlValidation.java | 50 ++++++++++++++++++ server/container/guice/jpa-guice/pom.xml | 6 +++ .../james/TestJPAConfigurationModule.java | 49 ------------------ ...JPAConfigurationModuleWithSqlValidation.java | 53 -------------------- server/container/guice/jpa-smtp/pom.xml | 6 +++ .../james/TestJPAConfigurationModule.java | 48 ------------------ server/container/guice/pom.xml | 6 +++ 9 files changed, 119 insertions(+), 150 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-common-guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-common-guice/pom.xml b/server/container/guice/jpa-common-guice/pom.xml index 393ee33..237b795 100644 --- a/server/container/guice/jpa-common-guice/pom.xml +++ b/server/container/guice/jpa-common-guice/pom.xml @@ -46,6 +46,11 @@ <groupId>${project.groupId}</groupId> <artifactId>james-server-guice-common</artifactId> </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java b/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java new file mode 100644 index 0000000..3ba1c7b --- /dev/null +++ b/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java @@ -0,0 +1,46 @@ +/**************************************************************** + * 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; + +import javax.inject.Singleton; + +import org.apache.james.modules.data.JPAConfiguration; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +public class TestJPAConfigurationModule extends AbstractModule { + + private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; + private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); + + @Override + protected void configure() { + } + + @Provides + @Singleton + JPAConfiguration provideConfiguration() { + return JPAConfiguration.builder() + .driverName(JDBC_EMBEDDED_DRIVER) + .driverURL(JDBC_EMBEDDED_URL) + .build(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java b/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java new file mode 100644 index 0000000..4fdb623 --- /dev/null +++ b/server/container/guice/jpa-common-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java @@ -0,0 +1,50 @@ +/**************************************************************** + * 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; + +import javax.inject.Singleton; + +import org.apache.james.modules.data.JPAConfiguration; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +public class TestJPAConfigurationModuleWithSqlValidation extends AbstractModule { + + private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; + private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); + private static final String VALIDATION_SQL_QUERY = "VALUES 1"; + + @Override + protected void configure() { + } + + @Provides + @Singleton + JPAConfiguration provideConfiguration() { + return JPAConfiguration.builder() + .driverName(JDBC_EMBEDDED_DRIVER) + .driverURL(JDBC_EMBEDDED_URL) + .testOnBorrow(true) + .validationQueryTimeoutSec(2) + .validationQuery(VALIDATION_SQL_QUERY) + .build(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/pom.xml b/server/container/guice/jpa-guice/pom.xml index c5ed697..1d36917 100644 --- a/server/container/guice/jpa-guice/pom.xml +++ b/server/container/guice/jpa-guice/pom.xml @@ -137,6 +137,12 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>james-server-jpa-common-guice</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>james-server-testing</artifactId> <scope>test</scope> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java deleted file mode 100644 index e6694ab..0000000 --- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java +++ /dev/null @@ -1,49 +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; - -import java.io.FileNotFoundException; - -import javax.inject.Singleton; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.james.modules.data.JPAConfiguration; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class TestJPAConfigurationModule extends AbstractModule { - - private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; - private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); - - @Override - protected void configure() { - } - - @Provides - @Singleton - JPAConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException { - return JPAConfiguration.builder() - .driverName(JDBC_EMBEDDED_DRIVER) - .driverURL(JDBC_EMBEDDED_URL) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java deleted file mode 100644 index b562c4a..0000000 --- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java +++ /dev/null @@ -1,53 +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; - -import java.io.FileNotFoundException; - -import javax.inject.Singleton; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.james.modules.data.JPAConfiguration; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class TestJPAConfigurationModuleWithSqlValidation extends AbstractModule { - - private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; - private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); - private static final String VALIDATION_SQL_QUERY = "VALUES 1"; - - @Override - protected void configure() { - } - - @Provides - @Singleton - JPAConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException { - return JPAConfiguration.builder() - .driverName(JDBC_EMBEDDED_DRIVER) - .driverURL(JDBC_EMBEDDED_URL) - .testOnBorrow(true) - .validationQueryTimeoutSec(2) - .validationQuery(VALIDATION_SQL_QUERY) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-smtp/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-smtp/pom.xml b/server/container/guice/jpa-smtp/pom.xml index 477f6b7..8f1b316 100644 --- a/server/container/guice/jpa-smtp/pom.xml +++ b/server/container/guice/jpa-smtp/pom.xml @@ -57,6 +57,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-jpa-common-guice</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/jpa-smtp/src/test/java/org/apache/james/TestJPAConfigurationModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/TestJPAConfigurationModule.java b/server/container/guice/jpa-smtp/src/test/java/org/apache/james/TestJPAConfigurationModule.java deleted file mode 100644 index 3fa53f6..0000000 --- a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/TestJPAConfigurationModule.java +++ /dev/null @@ -1,48 +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; - -import java.io.FileNotFoundException; - -import javax.inject.Singleton; - -import org.apache.commons.configuration.ConfigurationException; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class TestJPAConfigurationModule extends AbstractModule { - - private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; - private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); - - @Override - protected void configure() { - } - - @Provides - @Singleton - JPAConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException { - return JPAConfiguration.builder() - .driverName(JDBC_EMBEDDED_DRIVER) - .driverURL(JDBC_EMBEDDED_URL) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/320f913d/server/container/guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml index 10319a4..2e36186 100644 --- a/server/container/guice/pom.xml +++ b/server/container/guice/pom.xml @@ -177,6 +177,12 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>james-server-jpa-common-guice</artifactId> + <type>test-jar</type> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>james-server-jpa-smtp-common-guice</artifactId> <version>${project.version}</version> </dependency> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
