james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieu...@apache.org
Subject svn commit: r1299483 - in /james/server/trunk/data-jpa: ./ src/test/java/org/apache/james/domainlist/jpa/ src/test/java/org/apache/james/rrt/jpa/ src/test/java/org/apache/james/user/jpa/
Date Sun, 11 Mar 2012 23:14:24 GMT
Author: ieugen
Date: Sun Mar 11 23:14:24 2012
New Revision: 1299483

URL: http://svn.apache.org/viewvc?rev=1299483&view=rev
Log:
JAMES-1393

- updated tests to juni 4.x style
- added @Override and reformated code
Issue #JAMES-1393 - Upgrate all test suites to junit 4.10

Modified:
    james/server/trunk/data-jpa/pom.xml
    james/server/trunk/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
    james/server/trunk/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
    james/server/trunk/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java

Modified: james/server/trunk/data-jpa/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/data-jpa/pom.xml?rev=1299483&r1=1299482&r2=1299483&view=diff
==============================================================================
--- james/server/trunk/data-jpa/pom.xml (original)
+++ james/server/trunk/data-jpa/pom.xml Sun Mar 11 23:14:24 2012
@@ -21,10 +21,10 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <artifactId>james-server</artifactId>
-        <groupId>org.apache.james</groupId>
-        <version>3.0-beta5-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
+	<artifactId>james-server</artifactId>
+	<groupId>org.apache.james</groupId>
+	<version>3.0-beta5-SNAPSHOT</version>
+	<relativePath>../pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.james</groupId>
@@ -34,174 +34,174 @@
 
     <properties>
         <!-- OSGI stuff -->
-        <james.osgi.export>
-            org.apache.james.*,
-        </james.osgi.export>
-        <james.osgi.import>
-            *
-        </james.osgi.import>
+	<james.osgi.export>
+	    org.apache.james.*,
+	</james.osgi.export>
+	<james.osgi.import>
+	    *
+	</james.osgi.import>
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-lifecycle-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-dnsservice-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-library</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-configuration</groupId>
-            <artifactId>commons-configuration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jpa_2.0_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-annotation_1.1_spec</artifactId>
-        </dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-lifecycle-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-dnsservice-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-data-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-data-library</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>commons-configuration</groupId>
+	    <artifactId>commons-configuration</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.slf4j</groupId>
+	    <artifactId>slf4j-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.slf4j</groupId>
+	    <artifactId>slf4j-log4j12</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>commons-codec</groupId>
+	    <artifactId>commons-codec</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.geronimo.specs</groupId>
+	    <artifactId>geronimo-jpa_2.0_spec</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.geronimo.specs</groupId>
+	    <artifactId>geronimo-annotation_1.1_spec</artifactId>
+	</dependency>
 
         <!-- Test dependencies -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-library</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derby</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-dnsservice-api</artifactId>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>commons-dbcp</groupId>
-            <artifactId>commons-dbcp</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <scope>test</scope>
-        </dependency>
+	<dependency>
+	    <groupId>junit</groupId>
+	    <artifactId>junit</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-data-library</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.derby</groupId>
+	    <artifactId>derby</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-dnsservice-api</artifactId>
+	    <scope>test</scope>
+	    <type>test-jar</type>
+	</dependency>
+	<dependency>
+	    <groupId>commons-dbcp</groupId>
+	    <artifactId>commons-dbcp</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>com.h2database</groupId>
+	    <artifactId>h2</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.openjpa</groupId>
+	    <artifactId>openjpa</artifactId>
+	    <scope>test</scope>
+	</dependency>
     </dependencies>
 
     <build>
-        <plugins>
+	<plugins>
 
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
+	    <plugin>
+		<groupId>org.apache.maven.plugins</groupId>
+		<artifactId>maven-jar-plugin</artifactId>
                 <!--
                     Inherit configuration from parent pom.
                 -->
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>jar</goal>
+		<executions>
+		    <execution>
+			<goals>
+			    <goal>jar</goal>
                             <!--
                                 Allow tests to be used by other modules.
                                 Parent pom build failure prevents inheritance.
                             -->
-                            <goal>test-jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>openjpa-maven-plugin</artifactId>
-                <version>1.2</version>
-                <configuration>
-                    <includes>org/apache/james/user/jpa/model/JPAUser.class,org/apache/james/rrt/jpa/model/JPARecipientRewrite.class,org/apache/james/domainlist/jpa/model/JPADomain.class</includes>
-                    <addDefaultConstructor>true</addDefaultConstructor>
-                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
-                    <toolProperties>
-                        <property>
-                            <name>log</name>
-                            <value>TOOL=TRACE</value>
-                        </property>
-                        <property>
-                            <name>metaDataFactory</name>
-                            <value>jpa(Types=org.apache.james.user.jpa.model.JPAUser;org.apache.james.rrt.jpa.model.JPARecipientRewrite;org.apache.james.domainlist.jpa.model.JPADomain)</value>
-                        </property>
-                    </toolProperties>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>enhancer</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>enhance</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-                <executions>
-                    <execution>
-                        <id>bundle-manifest</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>manifest</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <excludeDependencies>${james.osgi.exclude.dependencies}</excludeDependencies>
-                    <instructions>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>${james.osgi.export}</Export-Package>
-                        <Import-Package>${james.osgi.import}</Import-Package>
-                        <DynamicImport-Package>${james.osgi.dynamic}</DynamicImport-Package>
-                        <Implementation-Title>Apache James Server</Implementation-Title>
-                        <Implementation-Version>${project.version}</Implementation-Version>
-                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
+			    <goal>test-jar</goal>
+			</goals>
+		    </execution>
+		</executions>
+	    </plugin>
+
+	    <plugin>
+		<groupId>org.codehaus.mojo</groupId>
+		<artifactId>openjpa-maven-plugin</artifactId>
+		<version>1.2</version>
+		<configuration>
+		    <includes>org/apache/james/user/jpa/model/JPAUser.class,org/apache/james/rrt/jpa/model/JPARecipientRewrite.class,org/apache/james/domainlist/jpa/model/JPADomain.class</includes>
+		    <addDefaultConstructor>true</addDefaultConstructor>
+		    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+		    <toolProperties>
+			<property>
+			    <name>log</name>
+			    <value>TOOL=TRACE</value>
+			</property>
+			<property>
+			    <name>metaDataFactory</name>
+			    <value>jpa(Types=org.apache.james.user.jpa.model.JPAUser;org.apache.james.rrt.jpa.model.JPARecipientRewrite;org.apache.james.domainlist.jpa.model.JPADomain)</value>
+			</property>
+		    </toolProperties>
+		</configuration>
+		<executions>
+		    <execution>
+			<id>enhancer</id>
+			<phase>process-classes</phase>
+			<goals>
+			    <goal>enhance</goal>
+			</goals>
+		    </execution>
+		</executions>
+	    </plugin>
+	    <plugin>
+		<groupId>org.apache.felix</groupId>
+		<artifactId>maven-bundle-plugin</artifactId>
+		<extensions>true</extensions>
+		<executions>
+		    <execution>
+			<id>bundle-manifest</id>
+			<phase>process-classes</phase>
+			<goals>
+			    <goal>manifest</goal>
+			</goals>
+		    </execution>
+		</executions>
+		<configuration>
+		    <excludeDependencies>${james.osgi.exclude.dependencies}</excludeDependencies>
+		    <instructions>
+			<Bundle-Name>${project.artifactId}</Bundle-Name>
+			<Export-Package>${james.osgi.export}</Export-Package>
+			<Import-Package>${james.osgi.import}</Import-Package>
+			<DynamicImport-Package>${james.osgi.dynamic}</DynamicImport-Package>
+			<Implementation-Title>Apache James Server</Implementation-Title>
+			<Implementation-Version>${project.version}</Implementation-Version>
+			<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+		    </instructions>
+		</configuration>
+	    </plugin>
+	</plugins>
     </build>
 </project>

Modified: james/server/trunk/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java?rev=1299483&r1=1299482&r2=1299483&view=diff
==============================================================================
--- james/server/trunk/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
(original)
+++ james/server/trunk/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
Sun Mar 11 23:14:24 2012
@@ -38,16 +38,6 @@ public class JPADomainListTest extends A
     private OpenJPAEntityManagerFactory factory;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    @Override
     protected DomainList createDomainList() {
         // Use a memory database.
         HashMap<String, String> properties = new HashMap<String, String>();

Modified: james/server/trunk/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java?rev=1299483&r1=1299482&r2=1299483&view=diff
==============================================================================
--- james/server/trunk/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
(original)
+++ james/server/trunk/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
Sun Mar 11 23:14:24 2012
@@ -19,15 +19,14 @@
 package org.apache.james.rrt.jpa;
 
 import java.util.HashMap;
-
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
-import org.apache.james.rrt.jpa.JPARecipientRewriteTable;
 import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.junit.Before;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -39,86 +38,89 @@ public class JPARecipientRewriteTableTes
      * The OpenJPA Entity Manager used for the tests.
      */
     private OpenJPAEntityManagerFactory factory;
-
     /**
      * The properties for the OpenJPA Entity Manager.
      */
     private HashMap<String, String> properties;
 
+    @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
 
-        // Use a memory database.
-        properties = new HashMap<String, String>();
-        properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
-        properties.put("openjpa.ConnectionURL", "jdbc:h2:target/users/db");
-        properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
-        properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72");
-        properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
-        properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPARecipientRewrite.class.getName()
+ ")");
+	// Use a memory database.
+	properties = new HashMap<String, String>();
+	properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
+	properties.put("openjpa.ConnectionURL", "jdbc:h2:target/users/db");
+	properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
+	properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72");
+	properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+	properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPARecipientRewrite.class.getName()
+ ")");
 
-        factory = OpenJPAPersistence.getEntityManagerFactory(properties);
-
-        super.setUp();
+	factory = OpenJPAPersistence.getEntityManagerFactory(properties);
 
+	super.setUp();
     }
 
     /**
      * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#getRecipientRewriteTable()
      */
+    @Override
     protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
-        JPARecipientRewriteTable virtualUserTable = new JPARecipientRewriteTable();
-        virtualUserTable.setLog(LoggerFactory.getLogger("MockLog"));
-        virtualUserTable.setEntityManagerFactory(factory);
-        DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
-        virtualUserTable.configure(defaultConfiguration);
-        return virtualUserTable;
+	JPARecipientRewriteTable localVirtualUserTable = new JPARecipientRewriteTable();
+	localVirtualUserTable.setLog(LoggerFactory.getLogger("MockLog"));
+	localVirtualUserTable.setEntityManagerFactory(factory);
+	DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
+	localVirtualUserTable.configure(defaultConfiguration);
+	return localVirtualUserTable;
     }
 
     /**
      * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#addMapping(java.lang.String,
      *      java.lang.String, java.lang.String, int)
      */
-    protected boolean addMapping(String user, String domain, String mapping, int type) throws
RecipientRewriteTableException {
-        try {
-            if (type == ERROR_TYPE) {
-                virtualUserTable.addErrorMapping(user, domain, mapping);
-            } else if (type == REGEX_TYPE) {
-                virtualUserTable.addRegexMapping(user, domain, mapping);
-            } else if (type == ADDRESS_TYPE) {
-                virtualUserTable.addAddressMapping(user, domain, mapping);
-            } else if (type == ALIASDOMAIN_TYPE) {
-                virtualUserTable.addAliasDomainMapping(domain, mapping);
-            } else {
-                return false;
-            }
-            return true;
-        } catch (RecipientRewriteTableException e) {
-            return false;
-        }
+    @Override
+    protected boolean addMapping(String user, String domain, String mapping, int type) throws
+	    RecipientRewriteTableException {
+	try {
+	    if (type == ERROR_TYPE) {
+		virtualUserTable.addErrorMapping(user, domain, mapping);
+	    } else if (type == REGEX_TYPE) {
+		virtualUserTable.addRegexMapping(user, domain, mapping);
+	    } else if (type == ADDRESS_TYPE) {
+		virtualUserTable.addAddressMapping(user, domain, mapping);
+	    } else if (type == ALIASDOMAIN_TYPE) {
+		virtualUserTable.addAliasDomainMapping(domain, mapping);
+	    } else {
+		return false;
+	    }
+	    return true;
+	} catch (RecipientRewriteTableException e) {
+	    return false;
+	}
     }
 
     /**
      * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#removeMapping(java.lang.String,
      *      java.lang.String, java.lang.String, int)
      */
-    protected boolean removeMapping(String user, String domain, String mapping, int type)
throws RecipientRewriteTableException {
-        try {
-            if (type == ERROR_TYPE) {
-                virtualUserTable.removeErrorMapping(user, domain, mapping);
-            } else if (type == REGEX_TYPE) {
-                virtualUserTable.removeRegexMapping(user, domain, mapping);
-            } else if (type == ADDRESS_TYPE) {
-                virtualUserTable.removeAddressMapping(user, domain, mapping);
-            } else if (type == ALIASDOMAIN_TYPE) {
-                virtualUserTable.removeAliasDomainMapping(domain, mapping);
-            } else {
-                return false;
-            }
-            return true;
-        } catch (RecipientRewriteTableException e) {
-            return false;
-        }
+    @Override
+    protected boolean removeMapping(String user, String domain, String mapping, int type)
throws
+	    RecipientRewriteTableException {
+	try {
+	    if (type == ERROR_TYPE) {
+		virtualUserTable.removeErrorMapping(user, domain, mapping);
+	    } else if (type == REGEX_TYPE) {
+		virtualUserTable.removeRegexMapping(user, domain, mapping);
+	    } else if (type == ADDRESS_TYPE) {
+		virtualUserTable.removeAddressMapping(user, domain, mapping);
+	    } else if (type == ALIASDOMAIN_TYPE) {
+		virtualUserTable.removeAliasDomainMapping(domain, mapping);
+	    } else {
+		return false;
+	    }
+	    return true;
+	} catch (RecipientRewriteTableException e) {
+	    return false;
+	}
     }
-
 }

Modified: james/server/trunk/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java?rev=1299483&r1=1299482&r2=1299483&view=diff
==============================================================================
--- james/server/trunk/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
(original)
+++ james/server/trunk/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
Sun Mar 11 23:14:24 2012
@@ -16,20 +16,19 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.user.jpa;
 
 import java.util.HashMap;
-
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.james.user.jpa.JPAUsersRepository;
 import org.apache.james.user.jpa.model.JPAUser;
 import org.apache.james.user.lib.AbstractUsersRepositoryTest;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
 import org.apache.openjpa.persistence.OpenJPAEntityTransaction;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.junit.After;
+import org.junit.Before;
 import org.slf4j.LoggerFactory;
 
 public class JpaUsersRepositoryTest extends AbstractUsersRepositoryTest {
@@ -37,50 +36,52 @@ public class JpaUsersRepositoryTest exte
     private HashMap<String, String> properties;
     private OpenJPAEntityManagerFactory factory;
 
+    @Before
     @Override
-    protected void setUp() throws Exception {
-        properties = new HashMap<String, String>();
-        properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
-        properties.put("openjpa.ConnectionURL", "jdbc:h2:target/users/db");
-        properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
-        properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72");
-        properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
-        properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPAUser.class.getName()
+ ")");
-        super.setUp();
-        deleteAll();
+    public void setUp() throws Exception {
+	properties = new HashMap<String, String>();
+	properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
+	properties.put("openjpa.ConnectionURL", "jdbc:h2:target/users/db");
+	properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
+	properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72");
+	properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+	properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPAUser.class.getName() + ")");
+	super.setUp();
+	deleteAll();
     }
 
+    @After
     @Override
-    protected void tearDown() throws Exception {
-        deleteAll();
-        super.tearDown();
+    public void tearDown() throws Exception {
+	deleteAll();
+	super.tearDown();
 
     }
 
     private void deleteAll() {
-        OpenJPAEntityManager manager = factory.createEntityManager();
-        final OpenJPAEntityTransaction transaction = manager.getTransaction();
-        try {
-            transaction.begin();
-            manager.createQuery("DELETE FROM JamesUser user").executeUpdate();
-            transaction.commit();
-        } catch (Exception e) {
-            e.printStackTrace();
-            if (transaction.isActive()) {
-                transaction.rollback();
-            }
-        } finally {
-            manager.close();
-        }
+	OpenJPAEntityManager manager = factory.createEntityManager();
+	final OpenJPAEntityTransaction transaction = manager.getTransaction();
+	try {
+	    transaction.begin();
+	    manager.createQuery("DELETE FROM JamesUser user").executeUpdate();
+	    transaction.commit();
+	} catch (Exception e) {
+	    e.printStackTrace();
+	    if (transaction.isActive()) {
+		transaction.rollback();
+	    }
+	} finally {
+	    manager.close();
+	}
     }
 
     @Override
     protected UsersRepository getUsersRepository() throws Exception {
-        factory = OpenJPAPersistence.getEntityManagerFactory(properties);
-        JPAUsersRepository repos = new JPAUsersRepository();
-        repos.setLog(LoggerFactory.getLogger("JPA"));
-        repos.setEntityManagerFactory(factory);
-        repos.configure(new DefaultConfigurationBuilder());
-        return repos;
+	factory = OpenJPAPersistence.getEntityManagerFactory(properties);
+	JPAUsersRepository repos = new JPAUsersRepository();
+	repos.setLog(LoggerFactory.getLogger("JPA"));
+	repos.setEntityManagerFactory(factory);
+	repos.configure(new DefaultConfigurationBuilder());
+	return repos;
     }
 }



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


Mime
View raw message