
Eigenschaftsänderungen: mailet/mailetcontainer-camel
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: mailet/mailets
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: mailet/mailetcontainer-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: app/pom.xml
===================================================================
--- app/pom.xml	(Revision 5815)
+++ app/pom.xml	(Revision 5834)
@@ -398,7 +398,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
-            <artifactId>apache-james-mailbox-jpa</artifactId>
+            <artifactId>apache-james-mailbox-openjpa</artifactId>
             <scope>runtime</scope>
             <exclusions>
                 <exclusion>
@@ -472,7 +472,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-jpa</artifactId>
+            <artifactId>james-server-data-openjpa</artifactId>
             <scope>runtime</scope>
         </dependency>
         <dependency>
@@ -530,6 +530,12 @@
             <artifactId>protocols-imap</artifactId>
             <scope>runtime</scope>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbytools</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -1009,6 +1015,78 @@
                 </dependency>
             </dependencies>
         </profile>
+        
+        <profile>
+            <id>derby-cmdline</id>
+            <build>
+                <defaultGoal>
+                    exec:java
+                </defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <mainClass>org.apache.derby.tools.ij</mainClass>
+                            
+                            <!-- connect 'jdbc:derby:../var/store/derby'; help; -->
+                            
+                            <includePluginDependencies>true</includePluginDependencies>
+                        </configuration>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.derby</groupId>
+                                <artifactId>derbytools</artifactId>
+                                <version>${derby.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>derby-dump-dbschema</id>
+            <build>
+                <defaultGoal>
+                    exec:exec
+                </defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>exec</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <executable>java</executable>
+                            <arguments>
+                                <argument>-cp</argument>
+                                <classpath/>
+                                <argument>org.apache.derby.tools.dblook</argument>
+                                <argument>-d</argument>
+                                <argument>jdbc:derby:${basedir}/target/var/store/derby</argument>
+                                <argument>-z</argument>
+                                <argument>APP</argument>
+                                <argument>-o</argument>
+                                <argument>schema.sql</argument>
+                            </arguments>
+                            <classpathScope>test</classpathScope>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 
 </project>
Index: app/src/test/resources/log4j.properties
===================================================================
--- app/src/test/resources/log4j.properties	(Revision 5815)
+++ app/src/test/resources/log4j.properties	(Revision 5834)
@@ -115,7 +115,7 @@
 log4j.logger.org.apache.activemq=WARN, CONS, FILE
 
 log4j.logger.org.apache.camel=WARN, CONS, FILE
-log4j.logger.org.springframework=WARN, CONS, FILE
+log4j.logger.org.springframework=INFO, CONS, FILE
 log4j.logger.org.apache.james=INFO, CONS, FILE
 
 log4j.logger.james=WARN, CONS, FILE
Index: app/src/main/resources/META-INF/persistence.xml
===================================================================
--- app/src/main/resources/META-INF/persistence.xml	(Revision 5815)
+++ app/src/main/resources/META-INF/persistence.xml	(Revision 5834)
@@ -27,8 +27,8 @@
         <!-- Mailbox stuff-->
         <class>org.apache.james.mailbox.jpa.mail.model.JPAMailbox</class>
         <class>org.apache.james.mailbox.jpa.mail.model.JPAUserFlag</class>
-        <class>org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMessage</class>
-        <class>org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMessage</class>
+        <class>org.apache.james.mailbox.jpa.mail.model.AbstractJPAMessage</class>
+        <class>org.apache.james.mailbox.jpa.mail.model.JPAMessage</class>
         <class>org.apache.james.mailbox.jpa.mail.model.JPAProperty</class>
         <class>org.apache.james.mailbox.jpa.user.model.JPASubscription</class>
         <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
Index: app/src/main/resources/META-INF/persistence-template.xml
===================================================================
--- app/src/main/resources/META-INF/persistence-template.xml	(Revision 5815)
+++ app/src/main/resources/META-INF/persistence-template.xml	(Revision 5834)
@@ -31,7 +31,7 @@
         <!-- Mailbox stuff-->
         <class>org.apache.james.mailbox.jpa.mail.model.JPAMailbox</class>
         <class>org.apache.james.mailbox.jpa.mail.model.JPAUserFlag</class>
-        <class>org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMessage</class>
+        <class>org.apache.james.mailbox.jpa.mail.model.AbstractJPAMessage</class>
 <!-- 
         <class>org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMessage</class>
 -->
@@ -42,7 +42,7 @@
         <class>org.apache.james.mailbox.jpa.mail.model.openjpa.JPAStreamingMessage</class>
         -->
         <!-- Comment if you want to use streaming -->
-        <class>org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMessage</class>
+        <class>org.apache.james.mailbox.jpa.mail.model.JPAMessage</class>
 
         <class>org.apache.james.mailbox.jpa.mail.model.JPAProperty</class>
         <class>org.apache.james.mailbox.jpa.user.model.JPASubscription</class>

Eigenschaftsänderungen: app
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: container/filesystem-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: container/util
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: container/spring/src/main/java/org/apache/james/container/spring/netty/NettyLogEnable.java
===================================================================
--- container/spring/src/main/java/org/apache/james/container/spring/netty/NettyLogEnable.java	(Revision 0)
+++ container/spring/src/main/java/org/apache/james/container/spring/netty/NettyLogEnable.java	(Revision 5834)
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.container.spring.netty;
+
+import org.apache.james.lifecycle.api.LogEnabled;
+import org.jboss.netty.logging.InternalLoggerFactory;
+import org.jboss.netty.logging.Slf4JLoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * Initialize Netty logging.
+ * @author MaSt
+ */
+public class NettyLogEnable implements LogEnabled {
+
+    @Override
+    public void setLog(Logger log) {
+        InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
+    }
+
+}
Index: container/spring/src/main/resources/META-INF/spring/loaders-context.xml
===================================================================
--- container/spring/src/main/resources/META-INF/spring/loaders-context.xml	(Revision 5815)
+++ container/spring/src/main/resources/META-INF/spring/loaders-context.xml	(Revision 5834)
@@ -20,7 +20,7 @@
 
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <!--
       Spring "Bean-Post-Processor" for LogEnabled interface.
Index: container/spring/src/main/resources/META-INF/spring/loaders-osgi.xml
===================================================================
--- container/spring/src/main/resources/META-INF/spring/loaders-osgi.xml	(Revision 5815)
+++ container/spring/src/main/resources/META-INF/spring/loaders-osgi.xml	(Revision 5834)
@@ -25,7 +25,7 @@
         xsi:schemaLocation="http://www.springframework.org/schema/osgi
        http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
        http://www.springframework.org/schema/beans   
-       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+       http://www.springframework.org/schema/beans/spring-beans.xsd">
 
 
     <beans:bean id="configurationprovider"
Index: container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
===================================================================
--- container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml	(Revision 5815)
+++ container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml	(Revision 5834)
@@ -21,10 +21,15 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
 
+    
+    <context:component-scan base-package="org.apache.james" scoped-proxy="interfaces"/>
+    
     <!-- 
     ===========================================================================
        Spring Wiring for James Server: Annotation, Bean Post-Processors...
@@ -80,24 +85,6 @@
 
     <!--
     ===========================================================================
-       Mail Protocol Servers
-    ===========================================================================
-    -->
-
-    <!-- SMTP Server -->
-    <import resource="classpath:META-INF/spring/smtpserver-context.xml"/>
-
-    <!-- LMTP Server -->
-    <import resource="classpath:META-INF/spring/lmtpserver-context.xml"/>
-
-    <!-- POP3 Server -->
-    <import resource="classpath:META-INF/spring/pop3server-context.xml"/>
-
-    <!-- IMAP4 Server -->
-    <import resource="classpath:META-INF/spring/imapserver-context.xml"/>
-
-    <!--
-    ===========================================================================
        Mailbox
     ===========================================================================
     -->
@@ -160,6 +147,24 @@
         <property name="showSql" value="false"/>
     </bean>
 
+    <!--
+    ===========================================================================
+       Mail Protocol Servers
+    ===========================================================================
+    -->
+
+    <!-- SMTP Server -->
+    <import resource="classpath:META-INF/spring/smtpserver-context.xml"/>
+
+    <!-- LMTP Server -->
+    <import resource="classpath:META-INF/spring/lmtpserver-context.xml"/>
+
+    <!-- POP3 Server -->
+    <import resource="classpath:META-INF/spring/pop3server-context.xml"/>
+
+    <!-- IMAP4 Server -->
+    <import resource="classpath:META-INF/spring/imapserver-context.xml"/>
+
     <!-- 
     ===========================================================================
        JMX
Index: container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-hbase.xml
===================================================================
--- container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-hbase.xml	(Revision 5815)
+++ container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-hbase.xml	(Revision 5834)
@@ -21,7 +21,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
-          http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd">
+          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <!-- 
       Mailbox HBase
Index: container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml
===================================================================
--- container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml	(Revision 5815)
+++ container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml	(Revision 5834)
@@ -21,7 +21,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
-          http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd">
+          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <!-- 
       Mailbox Authenticator

Eigenschaftsänderungen: container/spring
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: container/spring-integration-tests/src/test/resources/imapserver.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/imapserver.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/imapserver.xml	(Revision 5834)
@@ -0,0 +1,82 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<imapservers>
+
+	<!-- IMAP server is enabled by default -->
+	<!-- Disabling blocks will stop them from listening, -->
+	<!-- but does not free as many resources as removing them would -->
+	<imapserver enabled="true">
+	
+       <jmxName>imapserver</jmxName>
+       <!--<maxExecutorCount>1</maxExecutorCount>-->
+       <!--<ioWorkerCount>1</ioWorkerCount>-->
+
+	   <!-- Configure this if you want to bind to a specific inetaddress -->
+	   <!-- port 143 is the well-known/IANA registered port for IMAP -->
+	   <!-- port 993 is the well-known/IANA registered port for IMAPS  ie over SSL/TLS -->
+	   <!-- Please NOTE: you should add this IP also to your RemoteAddrNotInNetwork -->
+	   <!-- in order to avoid relay check for locally generated bounces -->    
+	   <bind>0.0.0.0:${sys:imaps.port}</bind>
+	    
+	   <connectionBacklog>200</connectionBacklog>
+	    
+	   <!-- Set to true to use TLS for the Socket.
+	         To use this you need to copy sunjce_provider.jar to /path/james/lib directory.
+	    -->
+	   <tls socketTLS="true" startTLS="false">
+	     <!-- To create a new keystore execute:
+	      keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+	       -->
+	     <keystore>file:${sys:keystore.location}</keystore>
+	     <secret>nosecret</secret>
+	     <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+         <algorithm>SunX509</algorithm>
+	   </tls>
+	      
+       <!-- This is the name used by the server to identify itself in the IMAP -->
+       <!-- protocol.  If autodetect is TRUE, the server will discover its -->
+       <!-- own host name and use that in the protocol.  If discovery fails, -->
+       <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
+       <!-- will use the specified value. -->
+       
+       <!--<helloName autodetect="true">helloName</helloName>-->
+        
+         
+       <!-- Connection timeout is 30 minutes and can not be changed - See rfc2060 5.4 for details -->
+            
+       <!-- Set the maximum simultaneous incoming connections for this service -->
+       <connectionLimit>200</connectionLimit>
+         
+       <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+       <connectionLimitPerIP>20</connectionLimitPerIP>
+
+       <serverName>brandedServerName</serverName>
+
+	</imapserver>
+
+</imapservers>
Index: container/spring-integration-tests/src/test/resources/mailetcontainer.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/mailetcontainer.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/mailetcontainer.xml	(Revision 5834)
@@ -0,0 +1,665 @@
+<?xml version="1.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.                                           
+ -->
+
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!-- This block is responsible for processing messages on the spool. -->
+
+<mailetcontainer enableJmx="true">
+ 
+    <!-- MailAddress used for PostMaster -->
+	<context>
+	    <postmaster>postmaster@${sys:mail.domain}</postmaster>
+	</context>
+
+    <!-- Number of spool threads -->
+    <spooler>
+	  <threads>5</threads>
+	</spooler>
+      
+  <processors>
+  
+    <!-- The root processor is a required processor - James routes all mail on the spool -->
+    <!-- through this processor first. -->
+    <!-- -->
+    <!-- This configuration is a sample configuration for the root processor. -->
+    <processor state="root" enableJmx="true">
+
+       <!-- This mailet redirects mail for the user 'postmaster' at any local domain to -->
+       <!-- the postmaster address specified for the server. The postmaster address -->
+       <!-- is required by rfc822. Do not remove this mailet unless you are meeting -->
+       <!-- this requirement through other means (e.g. a XML/JDBCRecipientRewriteTable defined in recipientrewritetable-store.xml) -->
+       <mailet match="All" class="PostmasterAlias"/>
+
+       <!-- Checks that the email Sender is associated with a valid domain. -->
+       <!-- Useful for detecting and eliminating spam. -->
+       <!-- For this block to function, the spam processor must be configured. -->
+       <!--
+       <mailet match="SenderInFakeDomain=64.55.105.9,64.94.110.11,194.205.62.122,194.205.62.62,195.7.77.20,206.253.214.102,212.181.91.6,219.88.106.80,194.205.62.42,216.35.187.246,203.119.4.6" class="ToProcessor">
+          <processor>spam</processor>
+       </mailet>
+         -->
+
+       <!-- Important check to avoid looping -->
+       <mailet match="RelayLimit=30" class="Null"/>
+
+       <!-- Check for viruses -->
+       <!-- -->
+       <!-- Does an antivirus scan check using a ClamAV daemon (CLAMD). -->
+       <!-- -->
+       <!-- Interacts directly with the daemon using the "stream" method, -->
+       <!-- which should have the lowest possible overhead. -->
+       <!-- The CLAMD daemon will typically reside on localhost, but could reside on a -->
+       <!-- different host. -->
+       <!-- It may also consist on a set of multiple daemons, each residing on a different -->
+       <!-- server and on different IP number. -->
+       <!-- In such case a DNS host name with multiple IP addresses (round-robin load sharing) -->
+       <!-- is supported by the mailet (but on the same port number). -->
+       <!-- -->
+       <!-- Handles the following init parameters: -->
+       <!--<debug>-->
+       <!--<host>: the host name of the server where CLAMD runs. It can either be -->
+       <!--     a machine name, such as -->
+       <!--     "java.sun.com", or a textual representation of its -->
+       <!--     IP address. If a literal IP address is supplied, only the -->
+       <!--     validity of the address format is checked. -->
+       <!--     If the machine name resolves to multiple IP addresses, round-robin load sharing will -->
+       <!--     be used. -->
+       <!--     The default is "localhost". -->
+       <!--<port>: the port on which CLAMD listens. The default is "3310". -->
+       <!--<maxPings>: the maximum number of connection retries during startup. -->
+       <!--     If the value is "0" no startup test will be done. -->
+       <!--     The default is "6". -->
+       <!--<pingIntervalMilli>: the interval (in milliseconds) -->
+       <!--     between each connection retry during startup. -->
+       <!--     The default is "30000" (30 seconds). -->
+       <!--<streamBufferSize>: the BufferedOutputStream buffer size to use  -->
+       <!--     writing to the stream connection. The default is "8192". -->
+       <!--
+       <mailet match="All" class="ClamAVScan" onMailetException="ignore">
+          <debug>true</debug>
+       </mailet>
+         -->
+
+       <!-- If infected go to virus processor -->
+       <mailet match="HasMailAttributeWithValue=org.apache.james.infected, true" class="ToProcessor">
+          <processor>virus</processor>
+       </mailet>
+
+       <!-- Check attachment extensions for possible viruses -->
+       <!-- The "-z" option requests the check to be non-recursively applied -->
+       <!-- to the contents of any attached '*.zip' file. -->
+       <!-- 
+       <mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="Bounce" onMatchException="error">
+          <inline>heads</inline>
+          <attachment>none</attachment>
+          <passThrough>false</passThrough>
+          <prefix>[REJECTED]</prefix>
+          <notice>
+The Security Policy of XXX does not allow to forward messages containing attachments having any of the extensions .exe, .com, .bat, .cmd, .pif, .scr, .vbs, .avi, .mp3, .mpeg, .shs, therefore your message has been rejected.
+
+Please don't reply to this e-mail as it has been automatically sent by the antivirus system.
+
+Regards, Postmaster XXX.YYY
+.....................................
+          </notice>
+       </mailet>
+         -->
+
+       <!-- Whitelist Management -->
+       <!-- Manages for each local user a "white list" of remote addresses whose messages -->
+       <!-- should never be blocked as spam. -->
+       <!-- -->
+       <!-- If<automaticInsert>is true, it will check, for a local sender, if a remote recipient -->
+       <!-- is already in the list: if not, it will be automatically inserted. -->
+       <!-- This is under the interpretation that if a local sender X sends a message to a -->
+       <!-- remote recipient Y, then later on if a message is sent by Y to X it should be -->
+       <!-- considered always valid and never blocked; hence Y should be in the white list -->
+       <!-- of X. -->
+       <!-- -->
+       <!-- Another mode of operations is when a local sender sends a message to<whitelistManagerAddress>-->
+       <!-- with one of three specific values in the subject, to -->
+       <!-- (i) send back a message displaying a list of the addresses in his own list (<displayFlag>); -->
+       <!-- (ii) insert some new addresses in his own list (<insertFlag>); -->
+       <!-- (iii) remove some addresses from his own list (<removeFlag>). -->
+       <!-- In all of the three above cases the message will be ghosted and the postmaster will reply -->
+       <!-- to the sender. -->
+       <!-- -->
+       <!-- The sender name is always converted to its primary name (handling aliases). -->
+       <!--
+       <mailet match="SMTPAuthSuccessful" class="WhiteListManager" onMailetException="ignore">
+          <repositoryPath>db://maildb</repositoryPath>
+          <automaticInsert>true</automaticInsert>
+          <whitelistManagerAddress>whitelist.manager@xxx.yyy</whitelistManagerAddress>
+          <displayFlag>display</displayFlag>
+          <insertFlag>insert</insertFlag>
+          <removeFlag>remove</removeFlag>
+       </mailet>
+         -->
+
+       <!-- "not spam" bayesian analysis feeder. -->
+       <!--
+       <mailet match="RecipientIs=not.spam@xxx.yyy" class="BayesianAnalysisFeeder">
+          <repositoryPath>db://maildb</repositoryPath>
+          <feedType>ham</feedType>
+          <maxSize>200000</maxSize>
+       </mailet>
+         -->
+     
+       <!-- "spam" bayesian analysis feeder. -->
+       <!--
+       <mailet match="RecipientIs=spam@xxx.yyy" class="BayesianAnalysisFeeder">
+          <repositoryPath>db://maildb</repositoryPath>
+          <feedType>spam</feedType>
+          <maxSize>200000</maxSize>
+       </mailet>
+         -->
+
+       <!-- sample SMIME mailets configuration -->
+       <!-- 
+       <mailet match="IsSMIMEEncrypted" class="SMIMEDecrypt">
+          <keyStoreType>pkcs12</keyStoreType>
+          <keyStoreFileName>c:/path.pfx</keyStoreFileName>
+          <keyStorePassword>myKeyStorePass</keyStorePassword>
+          <keyAlias>myKeyAlias</keyAlias>
+          <keyAliasPassword>myKeyPass</keyAliasPassword>
+       </mailet>
+         
+       <mailet match="IsSMIMESigned" class="SMIMECheckSignature">
+          <keyStoreType>pkcs12</keyStoreType>
+          <keyStoreFileName>c:/path.pfx</keyStoreFileName>
+          <keyStorePassword>myKeyStorePass</keyStorePassword>
+          <strip>false</strip>
+          <onlyTrusted>true</onlyTrusted>
+       </mailet>
+         -->
+
+       <!--
+         
+         XMLRecipientRewriteTable is deprecated - Use the definitions in recipientrewritetable-store.xml
+         
+       <mailet match="All" class="XMLRecipientRewriteTable">
+          <!- 1:1 mapping ->
+          <mapping>morgoth@middle-earth=sauron@mordor</mapping>
+          <!- 1:n mapping ->
+          <mapping>istari@middle-earth=saruman@isengard;radigast;gandalf</mapping>
+          <!- DSN mapping ->
+          <mapping>boromir@osgilliath=error:550 Requested action not taken: no such user here</mapping>
+          <!- regex based mapping ->
+          <mapping>*@osgilliath=regex:(.*)@osgilliath:${1}@minas-tirith</mapping>
+          <!- both standard and regex mapping ->
+          <mapping>ring@*=onering@mordor;regex:ring@(.*):ring@${1}</mapping>
+          <!- conditional regex mapping example ->
+          <mapping>*@listserver=regex:(.*)-on@listserver:${1}-subscribe@listserver;
+                                  regex:(.*)-off@listserver:${1}-unsubscribe@listserver
+          </mapping>
+       </mailet>
+         
+         -->
+
+       <!-- Anti-spam processing -->
+       <!-- The following two entries avoid double anti-spam analysis -->
+       <!-- for forwarded messages. -->
+       <!-- Has spam checking already been done? -->
+       <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+       <!-- Spam checking will not be done twice -->
+       <mailet match="All" class="SetMailAttribute">
+          <spamChecked>true</spamChecked>
+       </mailet>
+
+       <!-- White List:
+              If you use block lists, you will probably want to check
+              for known permitted senders.  This is particularly true
+              if you use more aggressive block lists, such as SPEWS,
+              that are prone to block entire subnets without regard
+              for non-spamming senders.
+         -->
+
+       <!-- Messages from authenticated senders never are spam -->
+       <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+
+       <!-- Messages signed by trusted users never are spam -->
+       <!-- Uncommenting the following entry, messages with valid signatures will never be considered spam. -->
+       <!-- This can be a valid policy *if* SMIMECheckSignature was invoked -->
+       <!-- with<onlyTrusted>true</onlyTrusted>set -->
+       <!--
+       <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+         -->
+
+       <!-- specific known senders -->
+       <!--
+       <mailet match="SenderIs=goodboy@goodhost"
+                 class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+         -->
+
+       <!-- People on this list agree to pay a penalty if they send spam -->
+       <mailet match="InSpammerBlacklist=query.bondedsender.org."
+                 class="ToProcessor">
+         <processor>transport</processor>
+       </mailet>
+
+       <!-- E-mail legally required not to be spam (see: http://www.habeas.com) -->
+       <!--
+       <mailet match="HasHabeasWarrantMark" class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+         -->
+
+       <!-- If the sender is in a recipient's whitelist, it is a valid sender, -->
+       <!-- and as such the message should not be considered spam for such recipient. -->
+       <!--
+       <mailet match="IsInWhiteList=db://maildb" class="ToProcessor" onMatchException="noMatch">
+          <processor>transport</processor>
+       </mailet>
+         -->
+
+       <!-- End of White List -->
+
+       <!-- Check for delivery from a known spam server -->
+       <!-- This set of matchers/mailets redirect all emails from known -->
+       <!-- black holes, open relays, and spam servers to the spam processor -->
+       <!-- For this set to function properly, the spam processor must be configured. -->
+       <mailet match="InSpammerBlacklist=dnsbl.njabl.org."
+                 class="ToProcessor">
+         <processor>spam</processor>
+         <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
+       </mailet>
+         
+       <!-- Sample matching to kill a message (send to Null) -->
+       <!--
+       <mailet match="RecipientIs=badboy@badhost" class="Null"/>
+         -->
+
+       <!-- Anti spam bayesian analysis -->
+       <!--
+       <mailet match="All" class="BayesianAnalysis" onMailetException="ignore">
+          <repositoryPath>db://maildb</repositoryPath>
+          <maxSize>200000</maxSize>
+          <headerName>X-MessageIsSpamProbability</headerName>
+          <ignoreLocalSender>true</ignoreLocalSender>
+       </mailet>
+
+       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.90" class="SetMailAttribute" onMatchException="noMatch">
+          <isSpam>true</isSpam>
+       </mailet>
+
+       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.90" class="SetMimeHeader" onMatchException="noMatch">
+          <name>X-MessageIsSpam</name>
+          <value>true</value>
+       </mailet>
+
+       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.99" class="ToProcessor" onMatchException="noMatch">
+          <processor>spam</processor>
+          <notice>Spam not accepted</notice>
+       </mailet>
+         -->
+
+<!-- disabled by mast -->
+<!--       <mailet notmatch="SenderHostIsLocal" class="SpamAssassin">
+          <spamdHost>localhost</spamdHost>
+          <spamdPort>783</spamdPort>
+       </mailet>-->
+
+       <!-- Send remaining mails to the transport processor for either local or remote delivery -->
+       <mailet match="All" class="ToProcessor">
+          <processor>transport</processor>
+       </mailet>
+
+    </processor>
+
+    <!-- The error processor is required.  James may internally set emails to the -->
+    <!-- error state.  The error processor is generally invoked when there is an -->
+    <!-- unexpected error either in the mailet chain or internal to James. -->
+    <!-- -->
+    <!-- By default configuration all email that generates an error in placed in -->
+    <!-- an error repository. -->
+    <processor state="error" enableJmx="true">
+       <!-- If you want to notify the sender their message generated an error, uncomment this       -->
+       <!--
+       <mailet match="All" class="Bounce"/>
+         -->
+       <!-- If you want to notify the postmaster that a message generated an error, uncomment this  -->
+       <!--
+       <mailet match="All" class="NotifyPostmaster"/>
+         -->
+
+       <!-- Logs any messages to the repository specified -->
+       <mailet match="All" class="ToRepository">
+          <repositoryPath>file://${sys:mail.dir}/error/</repositoryPath>
+       </mailet>
+    </processor>
+
+    <!-- Processor CONFIGURATION SAMPLE: transport is a sample custom processor for local or -->
+    <!-- remote delivery -->
+    <processor state="transport" enableJmx="true">
+
+      <!-- This is an example configuration including configuration for a list server. -->
+      <!-- CHECKME: before uncommenting this, edit the configuration file's contents   -->
+      <!--
+          &listserverConfig;
+        -->
+
+       <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+          <name>X-UserIsAuth</name>
+          <value>true</value>
+       </mailet>
+    
+       <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+          <name>X-WasSigned</name>
+          <value>true</value>
+       </mailet>
+
+       <!-- Add a server-side signature -->
+       <!--
+       <mailet match="All" class="SMIMESign" onMailetException="ignore">
+          <keyStoreType>jks</keyStoreType>
+          <keyStoreFileName>path.keystore</keyStoreFileName>
+          <keyStorePassword>myKeyStorePass</keyStorePassword>
+          <keyAlias>myKeyAlias</keyAlias>
+          <keyAliasPassword>myKeyPass</keyAliasPassword>
+          <signerName>XXX Trusted Server</signerName>
+          <rebuildFrom>true</rebuildFrom>
+          <postmasterSigns>true</postmasterSigns>
+          <debug>true</debug>
+       </mailet>
+         -->
+
+       <!-- Experimental quota Matcher -->
+       <!-- This matcher need to calculate the mailbox size everytime it is called. This can slow down things if there are many mails in -->
+       <!-- the mailbox. Some users also report big problems with the matcher if a JDBC based mailrepository is used. -->
+       <!-- Check if over quota -->
+       <!-- 
+       <mailet match="RecipientIsOverFixedQuota=20M" class="Resend">
+          <sender>postmaster</sender>
+          <replyTo>postmaster</replyTo>
+          <reversePath>null</reversePath>
+          <inline>none</inline>
+          <attachment>message</attachment>
+          <prefix>[OVER QUOTA WARNING]</prefix>
+          <message>
+When receiving the attached message, your mailbox is larger than 20 MB, which is the maximum allowed quota. The mailbox will not be blocked, but we ask you to empty it ASAP.
+
+It is likely that you have set, in your mail client account, the option "leave a copy of messages on server". For any help ask your administrators.
+
+Regards, Postmaster XXX.YYY
+.....................................
+          </message>
+       </mailet>
+         -->
+
+       <!--  The RecipientRewriteTable will use the definitions found in recipientrewritetablexml -->
+	     <mailet match="All" class="RecipientRewriteTable" />
+	    
+	     <!-- Place a copy in the user Sent folder -->
+	     <mailet match="SenderIsLocal" class="ToSenderFolder">
+	       <folder>Sent</folder>
+	       <consume>false</consume>
+	     </mailet>
+	
+       <!-- Is the recipient is for a local account, deliver it locally -->
+       <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+
+       <!-- If the host is handled by this server and it did not get -->
+       <!-- locally delivered, this is an invalid recipient -->
+       <mailet match="HostIsLocal" class="ToProcessor">
+          <processor>local-address-error</processor>
+          <notice>550 - Requested action not taken: no such user here</notice>
+       </mailet>
+
+<!-- CHECKME! -->
+       <!-- This is an anti-relay matcher/mailet combination -->
+       <!-- -->
+       <!-- Emails sent from servers not in the network list are  -->
+       <!-- rejected as spam.  This is one method of preventing your -->
+       <!-- server from being used as an open relay.  Make sure you understand -->
+       <!-- how to prevent your server from becoming an open relay before -->
+       <!-- changing this configuration. See also<authorizedAddresses>in SMTP Server -->
+       <!-- -->
+       <!-- This matcher/mailet combination must come after local delivery has -->
+       <!-- been performed.  Otherwise local users will not be able to receive -->
+       <!-- email from senders not in this remote address list. -->
+       <!-- -->
+       <!-- If you are using this matcher/mailet you will probably want to -->
+       <!-- update the configuration to include your own network/addresses.  The -->
+       <!-- matcher can be configured with a comma separated list of IP addresses  -->
+       <!-- wildcarded IP subnets, and wildcarded hostname subnets. -->
+       <!-- e.g. "RemoteAddrNotInNetwork=127.0.0.1, abc.de.*, 192.168.0.*" -->
+       <!-- -->
+       <!-- If you are using SMTP authentication then you can (and generally -->
+       <!-- should) disable this matcher/mailet pair. -->
+       <mailet match="RemoteAddrNotInNetwork=127.0.0.1" class="ToProcessor">
+          <processor>relay-denied</processor>
+          <notice>550 - Requested action not taken: relaying denied</notice>
+       </mailet>
+
+       <!-- Attempt remote delivery using the specified repository for the spool, -->
+       <!-- using delay time to retry delivery and the maximum number of retries -->
+       <mailet match="All" class="RemoteDelivery">
+          <outgoingQueue>outgoing</outgoingQueue>
+
+          <!-- Delivery Schedule based upon RFC 2821, 4.5.4.1 -->
+          <!-- 5 day retry period, with 4 attempts in the first
+                 hour, two more within the first 6 hours, and then
+                 every 6 hours for the rest of the period.
+                 This format is not yet supported, instead, use a unique
+                 tag with the list of delays in milliseconds separated by commas.
+          <delayTime>5 minutes</delayTime>
+          <delayTime>10 minutes</delayTime>
+          <delayTime>45 minutes</delayTime>
+          <delayTime>2 hours</delayTime>
+          <delayTime>3 hours</delayTime>
+          <delayTime>6 hours</delayTime>
+          -->
+          <delayTime>5000, 100000, 500000</delayTime>
+          <maxRetries>25</maxRetries>
+            
+          <!-- The max reties which will used if no A or MX record for the domain was found. -->
+          <!-- If 0 it will fail on first time -->
+          <maxDnsProblemRetries>0</maxDnsProblemRetries>
+
+          <!-- The number of threads that should be trying to deliver outgoing messages -->
+          <deliveryThreads>5</deliveryThreads>
+
+          <!-- If false the message will not be sent to given server if any recipients fail -->
+          <sendpartial>true</sendpartial>
+            
+          <!-- By default we send bounces to the "bounce" processor -->
+          <!-- By removing this configuration James will fallback to hardcoded bounce -->
+          <!-- notifications -->
+          <bounceProcessor>bounces</bounceProcessor>
+
+          <!-- A single mail server to deliver all outgoing messages. -->
+          <!-- This is useful if this server is a backup or failover machine, -->
+          <!-- or if you want all messages to be routed through a particular mail server, -->
+          <!-- regardless of the email addresses specified in the message -->
+          <!-- -->
+          <!-- The gateway element specifies the gateway SMTP server name. -->
+          <!-- If your gateway mail server is listening on a port other than 25, -->
+          <!-- you can set James to connect to it on that port using the gatewayPort -->
+          <!-- element. -->
+          <!-- Although normally multiple addresses are implemented through proper -->
+          <!-- DNS configuration, the RemoteDelivery mail does allow specifying -->
+          <!-- multiple gateway elements, each of which may also have a port -->
+          <!-- e.g., mygateway:2525 -->
+          <!-- the gatewayPort element is used as a default -->
+          <!--
+          <gateway>otherserver.mydomain.com</gateway>
+          <gatewayPort>25</gatewayPort>
+            -->
+          <!-- If the gateway requires smtp authentication the following directives -->
+          <!-- (gatewayUsername/gatewayPassword) can be used. -->
+          <!--
+          <gatewayUsername>login</gatewayUsername>
+          <gatewayPassword>pass</gatewayPassword>
+            -->
+            
+          <!-- Set the HELO/EHLO name to use when connectiong to remote SMTP-Server -->
+          <!--
+          <mail.smtp.localhost>myMailServer</mail.smtp.localhost>
+            -->
+       </mailet>
+
+    </processor>
+
+    <!-- Processor CONFIGURATION SAMPLE: spam is a sample custom processor for handling -->
+    <!-- spam. -->
+    <!-- You can either log these, bounce these, or just ignore them. -->
+    <processor state="spam" enableJmx="true">
+     
+       <!-- To place the spam messages in the user junk folder, uncomment this matcher/mailet configuration -->
+       <!--
+	   <mailet match="RecipientIsLocal" class="ToRecipientFolder">
+	       <folder>Junk</folder>
+	       <consume>false</consume>
+	   </mailet>
+	    -->
+
+       <!-- To destroy all messages, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="All" class="Null"/>
+         -->
+
+       <!-- To notify the sender their message was marked as spam, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="All" class="Bounce"/>
+         -->
+
+       <!-- To notify the postmaster that a message was marked as spam, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="All" class="NotifyPostmaster"/>
+         -->
+
+       <!-- To log the message to a repository, this matcher/mailet configuration should be uncommented. -->
+       <!-- This is the default configuration. -->
+       <mailet match="All" class="ToRepository">
+          <repositoryPath>file://${sys:mail.dir}/spam/</repositoryPath>
+       </mailet>
+    </processor>
+
+    <!-- messages containing viruses. -->
+    <processor state="virus" enableJmx="true">
+      
+       <!-- To avoid a loop while bouncing -->
+       <mailet match="All" class="SetMailAttribute">
+          <org.apache.james.infected>true, bouncing</org.apache.james.infected>
+       </mailet>
+
+       <!-- If the sender is authenticated, notify the infection -->
+       <mailet match="SMTPAuthSuccessful" class="Bounce">
+          <inline>heads</inline>
+          <attachment>none</attachment>
+          <notice>Warning: We were unable to deliver the message below because it was found infected by virus(es).</notice>
+       </mailet>
+
+       <!-- In any other situation ghost it, -->
+       <!-- as viruses almost always spoof the sender's address -->
+       <mailet match="All" class="Null" />
+    </processor>
+
+    <!-- This processor handles messages that are for local domains, where the user is unknown -->
+    <processor state="local-address-error" enableJmx="true">
+       <!-- To avoid bouncing/archiving spam, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="HasMailAttribute=isSpam" class="Null" onMatchException="noMatch"/>
+         -->
+
+       <!-- To notify the sender the address was invalid, uncomment this matcher/mailet configuration -->
+       <!-- The original message is not attached to keep the bounce processor from deliverying spam -->
+       <!--
+       <mailet match="All" class="Bounce">
+          <attachment>none</attachment>
+       </mailet>
+         -->
+
+       <!-- To notify the postmaster that a message had an invalid address, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="All" class="NotifyPostmaster"/>
+         -->
+
+       <mailet match="All" class="ToRepository">
+          <repositoryPath>file://${sys:mail.dir}/address-error/</repositoryPath>
+       </mailet>
+    </processor>
+
+    <!-- This processor handles messages that are for foreign domains, where relaying is denied -->
+    <!-- As of James v2.2, this processor can be deprecated by using the<authorizedAddresses>tag
+           in the SMTP Server, and rejecting the message in the protocol transaction.  -->
+    <processor state="relay-denied" enableJmx="true">
+       <!-- To notify the sender the address was invalid, uncomment this matcher/mailet configuration -->
+       <!-- The original message is not attached to keep the bounce processor from deliverying spam -->
+       <!--
+       <mailet match="All" class="Bounce">
+          <attachment>none</attachment>
+       </mailet>
+         -->
+
+       <!-- To notify the postmaster that a relay request was denied, uncomment this matcher/mailet configuration -->
+       <!--
+       <mailet match="All" class="NotifyPostmaster"/>
+         -->
+
+       <mailet match="All" class="ToRepository">
+          <repositoryPath>file://${sys:mail.dir}/relay-denied/</repositoryPath>
+       </mailet>
+    </processor>
+
+    <!-- This processor handle the bounces from RemoteDelivery: As of James v2.3, this is the new -->
+    <!-- Default. -->
+    <!-- -->
+    <!-- DSNBounce properly create a DSN compliant bounce -->
+    <processor state="bounces" enableJmx="true">
+       <mailet match="All" class="DSNBounce">
+          <passThrough>false</passThrough>
+
+          <!-- optional subject prefix prepended to the original message -->
+          <!--
+          <prefix>[bounce]</prefix>
+            -->
+            
+          <!-- message, heads or none, default=message -->
+          <!--
+          <attachment>heads</attachment>
+            -->
+            
+          <!-- the message sent in the bounce, the first occurrence of the pattern [machine] is -->
+          <!-- replaced with the name of the executing machine -->
+          <!-- Default: Hi. This is the James mail server at [machine] ... -->
+          <!--
+          <messageString>Here is [machine]. I'm not able to deliver this message.</messageString>
+            -->
+        </mailet>
+    </processor>
+
+  </processors>
+
+</mailetcontainer>
Index: container/spring-integration-tests/src/test/resources/log4j.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/log4j.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/log4j.xml	(Revision 5834)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.                                           
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
+<log4j:configuration>
+    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{ISO8601} %-5p [%-11t] [%-50c{4}] %L %m%n" />
+        </layout>
+    </appender>
+
+    <logger name="org.springframework" additivity="false">  
+        <level value="info"></level>
+        <appender-ref ref="stdout" />  
+    </logger>
+
+    <logger name="org.apache.camel" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+    <logger name="james" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+    <logger name="org.apache.james" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+
+    <logger name="org.jboss.netty" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+
+    <logger name="org.hibernate" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+
+    <!-- log sql stmts -->
+    <logger name="org.hibernate.SQL" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+    <!-- log sql params -->
+    <logger name="org.hibernate.type" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+    <!-- log DDLs -->
+    <logger name="org.hibernate.tool.hbm2ddl" additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="stdout" />
+    </logger>
+    
+    <root>
+        <priority value="info" />
+        <appender-ref ref="stdout" />
+    </root>
+</log4j:configuration>
Index: container/spring-integration-tests/src/test/resources/META-INF/spring/jdbc-activemq-queue-context.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/META-INF/spring/jdbc-activemq-queue-context.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/META-INF/spring/jdbc-activemq-queue-context.xml	(Revision 5834)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.                                           
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:beans="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:amq="http://activemq.apache.org/schema/core"
+       xsi:schemaLocation="
+        http://cxf.apache.org/configuration/security
+            http://cxf.apache.org/schemas/configuration/security.xsd
+        http://www.springframework.org/schema/beans
+            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-4.0.xsd
+        http://www.springframework.org/schema/aop
+            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
+        http://www.springframework.org/schema/tx
+            http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+        http://camel.apache.org/schema/spring
+            http://camel.apache.org/schema/spring/camel-spring.xsd
+        http://activemq.apache.org/schema/core
+            http://activemq.apache.org/schema/core/activemq-core.xsd
+             ">
+
+    <!-- James Mail Queue Factory -->
+    <bean id="mailqueuefactory" class="org.apache.james.queue.activemq.ActiveMQMailQueueFactory"
+          depends-on="broker">
+        <property name="useBlobMessages" value="false"/>
+    </bean>
+
+    <!--
+     ActiveMQ Broker, Connections, Blob
+    -->
+    <amq:broker useJmx="true" persistent="true" brokerName="james" dataDirectory="var/store/activemq/brokers"
+                useShutdownHook="false" schedulerSupport="false" id="broker">
+        <amq:destinationPolicy>
+            <amq:policyMap>
+                <amq:policyEntries>
+                    <!-- Support priority handling of messages -->
+                    <!-- http://activemq.apache.org/how-can-i-support-priority-queues.html -->
+                    <amq:policyEntry queue=">" prioritizedMessages="true"/>
+                </amq:policyEntries>
+            </amq:policyMap>
+        </amq:destinationPolicy>
+        <amq:managementContext>
+            <amq:managementContext createConnector="false"/>
+        </amq:managementContext>
+        <amq:persistenceAdapter>
+            <amq:jdbcPersistenceAdapter dataSource="#myDataSource"/>
+        </amq:persistenceAdapter>
+        <amq:plugins>
+            <amq:statisticsBrokerPlugin/>
+        </amq:plugins>
+        <amq:transportConnectors>
+            <amq:transportConnector uri="tcp://localhost:0"/>
+        </amq:transportConnectors>
+    </amq:broker>
+
+    <amq:connectionFactory id="amqConnectionFactory" brokerURL="vm://james?create=false">
+        <amq:prefetchPolicy>
+            <!-- Disable prefetch so slow consuming can not block other threads -->
+            <!-- See JAMES-1253 -->
+            <amq:prefetchPolicy queuePrefetch="0" topicPrefetch="0"/>
+        </amq:prefetchPolicy>
+    </amq:connectionFactory>
+
+    <bean id="jmsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
+        <property name="targetConnectionFactory" ref="amqConnectionFactory"/>
+        <property name="sessionCacheSize" value="10"/>
+        <property name="cacheConsumers" value="false"/>
+        <property name="cacheProducers" value="true"/>
+    </bean>
+
+    <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
+        <property name="connectionFactory" ref="jmsConnectionFactory"/>
+    </bean>
+
+</beans>
Index: container/spring-integration-tests/src/test/resources/usersrepository.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/usersrepository.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/usersrepository.xml	(Revision 5834)
@@ -0,0 +1,81 @@
+<?xml version="1.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.                                           
+ -->
+
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!-- Configure User Repositories here. -->
+
+<!-- -->
+<!-- User repositories are required for the following purposes: -->
+<!--    - storing James user information and authentication data. -->
+<!-- -->
+ 
+<!-- JPA based backend. Support password algorithm are:
+  MD5, SHA-256, SHA-512, NONE
+-->
+<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
+    <algorithm>PBKDF2</algorithm>
+    <enableVirtualHosting>true</enableVirtualHosting>    
+</usersrepository>
+
+<!-- Read-Only LDAP based UsersRepository -->
+<!--
+<repository name="LocalUsers" class="org.apache.james.user.ldap.ReadOnlyUsersLDAPRepository" ldapHost="ldap://myldapserver:389" 
+    principal="uid=ldapUser,ou=system" credentials="password" userBase="ou=People,o=myorg.com,ou=system" userIdAttribute="uid"/>;
+-->
+
+<!-- The UsersRepository implementations below are DEPRECATED and will get removed in the next release -->
+<!-- They are just listed here for backward-compatibility-->
+
+<!-- File-based user repositories  Use these configurations to store user info in the filesystem  -->
+<!-- The LocalUsers repository, for storing James' User info. -->
+<!-- DEPRECATED: This implementation will get removed in the next release -->
+<!--
+<usersrepository name="LocalUsers" class="org.apache.james.user.file.UsersFileRepository">
+    <destination URL="file://var/users/"/>
+    <ignoreCase>true</ignoreCase>
+    <enableAliases>true</enableAliases>
+    <enableForwarding>true</enableForwarding>
+    <enableVirtualHosting>false</enableVirtualHosting>    
+</usersrepository>
+-->
+
+<!-- Database backed user repositories -->
+<!-- -->
+<!-- Use these configurations to store user info in a database. -->
+<!-- Note: The<data-source>element must refer to a connection configured -->
+<!--       in the<database-connections>configuration section. -->
+<!-- The LocalUsers repository, for storing James' User info. -->
+<!-- DEPRECATED: This implementation will get removed in the next release -->
+<!--             Use JPAUsersRepository if you want to store the Users in a database -->
+<!-- 
+<usersrepository name="LocalUsers" class="org.apache.james.user.jdbc.JamesUsersJdbcRepository" destinationURL="db://maildb/users">
+    <sqlFile>file://conf/sqlResources.xml</sqlFile>
+    <ignoreCase>true</ignoreCase>
+    <enableAliases>true</enableAliases>
+    <enableForwarding>true</enableForwarding>
+    <enableVirtualHosting>false</enableVirtualHosting>    
+</usersrepository>
+-->
Index: container/spring-integration-tests/src/test/resources/james-integration-context.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/james-integration-context.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/james-integration-context.xml	(Revision 5834)
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.                                           
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:beans="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:amq="http://activemq.apache.org/schema/core"
+       xsi:schemaLocation="
+        http://cxf.apache.org/configuration/security
+            http://cxf.apache.org/schemas/configuration/security.xsd
+        http://www.springframework.org/schema/beans
+            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-4.0.xsd
+        http://www.springframework.org/schema/aop
+            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
+        http://www.springframework.org/schema/tx
+            http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+        http://camel.apache.org/schema/spring
+            http://camel.apache.org/schema/spring/camel-spring.xsd
+        http://activemq.apache.org/schema/core
+            http://activemq.apache.org/schema/core/activemq-core.xsd
+             ">
+
+
+    <alias alias="James" name="myEmf"/>
+    <alias alias="entityManagerFactory" name="myEmf"/>
+    <alias alias="transactionManager" name="myTxManager"/>
+
+
+
+    <import resource="classpath:META-INF/spring/loaders-context.xml"/>
+
+    <!--<bean class="org.apache.james.container.spring.netty.NettyLogEnable"/>-->
+
+    <!--
+    ===========================================================================
+       Authenticator
+    ===========================================================================
+    -->
+
+    <import resource="classpath:META-INF/org/apache/james/spring-mailbox-authenticator.xml"/>
+
+    <!--
+    ===========================================================================
+       Queues
+    ===========================================================================
+    -->
+
+
+    <!--
+      Default Mail Queue Factory is the ActiveMQMailQueueFactory.
+      Alternative queue is FileMailQueueFactory - Can be used instead of the default one.
+      To use FileMailQueueFactory, replace the import of activemq-queue-context.xml with:
+      <import resource="classpath:META-INF/spring/file-queue-context.xml"/>
+     -->
+    <import resource="classpath:META-INF/spring/jdbc-activemq-queue-context.xml"/>
+
+    <!-- Mailet Container -->
+    <import resource="classpath:META-INF/spring/mailetcontainer-context.xml"/>
+
+    <!-- DNS Service -->
+    <import resource="classpath:META-INF/spring/dns-context.xml"/>
+
+    <!--
+    ===========================================================================
+       Mailbox
+    ===========================================================================
+    -->
+
+    <!-- Mailbox Managers -->
+    <bean class="org.apache.james.container.spring.bean.factorypostprocessor.MailboxConfigurationBeanFactoryPostProcessor"/>
+
+    <bean id="locker" class="org.apache.james.mailbox.store.JVMMailboxPathLocker"/>
+
+    <import resource="classpath:META-INF/spring/spring-mailbox.xml"/>
+
+    <!-- Mailbox Importer -->
+    <!--
+       <bean id="james23importer" class="org.apache.james.container.spring.tool.James23Importer"/>
+    -->
+
+
+    <!-- Camel Context -->
+    <camel:camelContext id="jamesCamelContext" trace="false">
+        <camel:jmxAgent id="agent" disabled="false" createConnector="false" serviceUrlPath="/jmxrmi/jamescamel"/>
+    </camel:camelContext>
+    
+    <!-- FetchMail -->
+    <import resource="classpath:META-INF/spring/fetchmail-context.xml"/>
+
+    <!--
+    ===========================================================================
+       Mail Protocol Servers
+    ===========================================================================
+    -->
+
+    <!-- SMTP Server -->
+    <import resource="classpath:META-INF/spring/smtpserver-context.xml"/>
+
+    <!-- LMTP Server -->
+    <import resource="classpath:META-INF/spring/lmtpserver-context.xml"/>
+
+    <!-- POP3 Server -->
+    <import resource="classpath:META-INF/spring/pop3server-context.xml"/>
+
+    <!-- IMAP4 Server -->
+    <import resource="classpath:META-INF/spring/imapserver-context.xml"/>
+
+
+    <!--
+    ===========================================================================
+       JMX
+    ===========================================================================
+    -->
+
+    <!-- JMX Server  -->
+<!--    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+        <property name="ignoreUnresolvablePlaceholders" value="true"/>
+        <property name="location" value="classpath:jmx.properties"/>
+    </bean>-->
+
+    <bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServerFactoryBean">
+        <property name="locateExistingServerIfPossible" value="true"/>
+        <property name="registerWithFactory" value="true"/>
+    </bean>
+
+    <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="registry">
+        <property name="objectName" value="connector:name=rmi"/>
+        <property name="serviceUrl"
+                  value="service:jmx:rmi://#{systemProperties['jmx.address']}/jndi/rmi://#{systemProperties['jmx.address']}:#{systemProperties['jmx.port']}/jmxrmi"/>
+    </bean>
+
+    <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
+        <property name="port" value="#{systemProperties['jmx.port']}"/>
+        <property name="serverSocketFactory" ref="restrictedRmiSocketFactory"/>
+        <property name="clientSocketFactory" ref="restrictedRmiSocketFactory"/>
+    </bean>
+
+    <bean id="restrictedRmiSocketFactory" class="org.apache.james.util.RestrictingRMISocketFactory">
+        <constructor-arg value="#{systemProperties['jmx.address']}"/>
+    </bean>
+
+    <!-- JMX Export -->
+    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
+        <property name="beans">
+            <map>
+                <entry key="org.apache.james:type=component,name=domainlist" value-ref="domainlistmanagement"/>
+                <entry key="org.apache.james:type=component,name=dnsservice" value-ref="dnsservice"/>
+                <entry key="org.apache.james:type=component,name=recipientrewritetable"
+                       value-ref="recipientrewritetablemanagement"/>
+                <entry key="org.apache.james:type=component,name=usersrepository"
+                       value-ref="usersrepositorymanagement"/>
+                <entry key="org.apache.james:type=component,name=fetchmail" value-ref="fetchmail"/>
+                <entry key="org.apache.james:type=component,name=mailboxmanagement"
+                       value-ref="mailboxmanagermanagement"/>
+                <entry key="org.apache.james:type=component,component=mailetcontainer,name=mailspooler"
+                       value-ref="mailspooler"/>
+                <entry key="org.apache.james:type=component,name=mailboxcopier" value-ref="mailboxcopiermanagement"/>
+                <!--
+                          <entry key="org.apache.james:type=component,name=james23importer" value-ref="james23importermanagement"/>
+                -->
+                <entry key="org.apache.james:type=container,name=logprovider" value-ref="logprovider"/>
+            </map>
+        </property>
+        <property name="assembler">
+            <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
+                <property name="managedInterfaces"
+                          value="org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.rrt.api.RecipientRewriteTableManagementMBean,org.apache.james.user.api.UsersRepositoryManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.container.spring.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean,org.apache.james.container.spring.lifecycle.LogProviderManagementMBean"/>
+            </bean>
+        </property>
+    </bean>
+
+    <bean id="usersrepositorymanagement" class="org.apache.james.user.lib.UsersRepositoryManagement"/>
+    <bean id="recipientrewritetablemanagement" class="org.apache.james.rrt.lib.RecipientRewriteTableManagement"/>
+    <bean id="domainlistmanagement" class="org.apache.james.domainlist.lib.DomainListManagement"/>
+    <bean id="mailboxmanagermanagement" class="org.apache.james.adapter.mailbox.MailboxManagerManagement"/>
+    <bean id="mailboxcopiermanagement" class="org.apache.james.container.spring.mailbox.MailboxCopierManagement"/>
+    <!--
+        <bean id="james23importermanagement" class="org.apache.james.container.spring.tool.James23ImporterManagement" />
+    -->
+
+    <!-- uncomment the folowing line to enable JETM monitoring -->
+    <!--
+        <import resource="classpath:jetm-monitoring.conf" />
+    -->
+
+
+
+</beans>
Index: container/spring-integration-tests/src/test/resources/domainlist.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/domainlist.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/domainlist.xml	(Revision 5834)
@@ -0,0 +1,63 @@
+<?xml version="1.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.                                           
+ -->
+
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!-- Domainnames identifies the DNS namespace served by this instance of James. -->
+<!-- These domainnames are used for both matcher/mailet processing and SMTP auth -->
+<!-- to determine when a mail is intended for local delivery. -->
+<!-- -->
+<!-- If autodetect is TRUE, James wil attempt to discover its own host name AND -->
+<!-- use any explicitly specified servernames. -->
+<!-- If autodetect is FALSE, James will use only the specified domainnames. -->
+<!-- -->
+<!-- If autodetectIP is not FALSE, James will also allow add the IP address for each servername. -->
+<!-- The automatic IP detection is to support RFC 2821, Sec 4.1.3, address literals. -->
+<!-- -->
+<!-- To override autodetected domainames names simply add explicit domainname elements. -->
+<!-- In most cases this will be necessary. -->
+<!-- By default, the domainname 'localhost' is specified. This can be removed, if required. -->
+<!-- -->
+<!-- Warning: If you are using fetchmail it is important to include the -->
+<!-- fetched domains in the server name list to prevent looping.       -->   
+
+<!-- JPA implementation for DomainList -->
+<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
+   <autodetect>true</autodetect>
+   <autodetectIP>true</autodetectIP>
+   <defaultDomain>localhost</defaultDomain>
+</domainlist>
+
+<!-- XML based implementation for DomainList -->
+<!-- 
+<domainlist class="org.apache.james.domainlist.xml.XMLDomainList">
+   <domainnames>
+       <domainname>localhost</domainname>
+   </domainnames>
+   <autodetect>true</autodetect>
+   <autodetectIP>true</autodetectIP>
+   <defaultDomain>localhost</defaultDomain>
+</domainlist>  
+-->
Index: container/spring-integration-tests/src/test/resources/application-context.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/application-context.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/application-context.xml	(Revision 5834)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.                                           
+ -->
+
+<beans default-lazy-init="true"
+       xmlns="http://www.springframework.org/schema/beans"
+       xmlns:beans="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:amq="http://activemq.apache.org/schema/core"
+       xsi:schemaLocation="
+        http://cxf.apache.org/configuration/security
+            http://cxf.apache.org/schemas/configuration/security.xsd
+        http://www.springframework.org/schema/beans
+            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-4.0.xsd
+        http://www.springframework.org/schema/aop
+            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
+        http://www.springframework.org/schema/tx
+            http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+        http://camel.apache.org/schema/spring
+            http://camel.apache.org/schema/spring/camel-spring.xsd
+        http://activemq.apache.org/schema/core
+            http://activemq.apache.org/schema/core/activemq-core.xsd
+             ">
+
+    <context:annotation-config/>
+    <context:component-scan base-package="org.apache.james" scoped-proxy="interfaces"/>
+    <aop:aspectj-autoproxy proxy-target-class="true" />
+
+
+
+
+    <import resource="classpath:datasource.xml" />
+
+
+
+    <import resource="classpath:james-integration-context.xml"/>
+</beans>
Index: container/spring-integration-tests/src/test/resources/dnsservice.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/dnsservice.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/dnsservice.xml	(Revision 5834)
@@ -0,0 +1,65 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!-- DNS Service Block -->
+<!-- -->
+<!-- Specifies DNS Server information for use by various components inside -->
+<!-- James. -->
+<!-- -->
+<!-- If autodiscover is true, James will attempt to autodiscover the DNS servers configured on your underlying system.-->
+<!-- Currently, this works if the OS has a unix-like /etc/resolv.conf,-->
+<!-- or the system is Windows based with ipconfig or winipcfg.-->
+<!-- -->
+<!-- If no DNS servers are found and you have not specified any below, 127.0.0.1 will be used-->
+<!-- If you use autodiscover and add DNS servers manually a combination of all the dns servers will be used  -->
+<!--  -->
+<!-- Information includes a list of DNS Servers to be used by James.  These are -->
+<!-- specified by the server elements, each of which is a child element of the -->
+<!-- servers element.  Each server element is the IP address of a single DNS server. -->
+<!-- The servers element can have multiple server children. -->
+<dnsservice>
+   <servers>
+       <!--Enter ip address of your DNS server, one IP address per server -->
+       <!-- element. -->
+       <!--
+       <server>127.0.0.1</server>
+        -->
+   </servers>
+   <!-- Change autodiscover to false if you would like to turn off autodiscovery -->
+   <!-- and set the DNS servers manually in the<servers>section -->
+   <autodiscover>true</autodiscover>
+   <authoritative>false</authoritative>
+
+   <!-- Maximum number of entries to maintain in the DNS cache -->
+   <maxcachesize>500</maxcachesize>
+      
+   <!-- Uncomment this if you want James to try a single server for each -->
+   <!-- multihomed mx host. -->
+   <!--
+   <singleIPperMX>true</singleIPperMX>
+    -->
+</dnsservice>
Index: container/spring-integration-tests/src/test/resources/pop3server.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/pop3server.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/pop3server.xml	(Revision 5834)
@@ -0,0 +1,81 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<pop3servers>
+
+	<!-- The POP3 server is enabled by default -->
+	<!-- Disabling blocks will stop them from listening, -->
+	<!-- but does not free as many resources as removing them would -->
+	<pop3server enabled="false">
+	
+	   <jmxName>pop3server</jmxName>
+	
+	   <!-- Configure this to bind to a specific inetaddress -->
+	   <!-- port 995 is the well-known/IANA registered port for POP3S  ie over SSL/TLS -->
+	   <!-- port 110 is the well-known/IANA registered port for Standard POP3 -->
+	   <bind>0.0.0.0:110</bind>
+	
+	   <connectionBacklog>200</connectionBacklog>
+	
+	   <!-- Set to true to support STARTTLS or SSL for the Socket.
+	         To use this you need to copy sunjce_provider.jar to /path/james/lib directory.
+	    -->
+	   <tls socketTLS="false" startTLS="false">
+	       <!-- To create a new keystore execute:
+	             keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+	        -->
+	       <keystore>file://conf/keystore</keystore>
+	       <secret>yoursecret</secret>
+	       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+	   </tls>
+	      
+       <!-- This is the name used by the server to identify itself in the POP3 -->
+       <!-- protocol.  If autodetect is TRUE, the server will discover its -->
+       <!-- own host name and use that in the protocol.  If discovery fails, -->
+       <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
+       <!-- will use the specified value. -->
+       <!--
+       <helloName autodetect="true">myMailServer</helloName>
+        -->
+       <!-- connection timeout in secconds -->
+       <connectiontimeout>1200</connectiontimeout>
+      
+       <!-- Set the maximum simultaneous incoming connections for this service -->
+       <connectionLimit>0</connectionLimit>
+         
+       <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+       <connectionLimitPerIP>0</connectionLimitPerIP>
+         
+       <handlerchain>
+           <!-- This loads the core CommandHandlers. Only remove this if you really -->
+           <!-- know what you are doing -->
+           <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+       </handlerchain>
+	    
+	</pop3server>
+	
+</pop3servers>
Index: container/spring-integration-tests/src/test/resources/datasource.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/datasource.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/datasource.xml	(Revision 5834)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.                                           
+ -->
+
+<beans
+    xmlns="http://www.springframework.org/schema/beans"
+    xmlns:beans="http://www.springframework.org/schema/beans"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-4.0.xsd
+        http://www.springframework.org/schema/aop
+            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
+        http://www.springframework.org/schema/tx
+            http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+             ">
+
+    <tx:annotation-driven transaction-manager="myTxManager" order="100" />
+
+    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+        <property name="url" value="jdbc:hsqldb:mem:hibernatetest;shutdown=false"/>
+        <property name="username" value="SA"/>
+        <property name="password" value=""/>
+        <property name="maxActive" value="100"/>
+        <property name="maxWait" value="1000"/>
+        <property name="poolPreparedStatements" value="true"/>
+    </bean>
+
+    <bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+        <property name="packagesToScan" value="org.apache.james.mailbox.jpa.*.model,org.apache.james.*.jpa.model"/>
+        <property name="jpaVendorAdapter">
+            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
+        </property>
+        <property name="jpaProperties">
+            <props>
+                <!-- create-drop , create , update -->
+                <prop key="hibernate.hbm2ddl.auto">update</prop>
+                <prop key="hibernate.show_sql">false</prop>
+                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
+            </props>
+        </property>
+        <property name="dataSource" ref="myDataSource"/>
+    </bean>
+    
+    <bean id="myTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+        <property name="entityManagerFactory" ref="myEmf"/>
+    </bean>
+</beans>
Index: container/spring-integration-tests/src/test/resources/smtpserver.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/smtpserver.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/smtpserver.xml	(Revision 5834)
@@ -0,0 +1,350 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<smtpservers>
+
+    <smtpserver enabled="true">
+        <jmxName>smtpserver-ssl</jmxName>
+        <bind>0.0.0.0:${sys:smtps.port}</bind>
+        <connectionBacklog>200</connectionBacklog>
+        <!-- Set to true to support STARTTLS or TLS for the Socket.
+              To use this you need to copy sunjce_provider.jar to /path/james/lib directory.
+         -->
+        <tls socketTLS="true" startTLS="false">
+          <!-- To create a new keystore execute:
+           keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+            -->
+          <keystore>file:${sys:keystore.location}</keystore>
+          <secret>nosecret</secret>
+          <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+          <!-- The algorithm is optional and only needs to be specified when using something other
+           than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+          <algorithm>SunX509</algorithm>
+        </tls>
+        <connectiontimeout>360</connectiontimeout>
+        <connectionLimit>200</connectionLimit>
+        <connectionLimitPerIP>20</connectionLimitPerIP>
+        <authRequired>true</authRequired>
+        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>
+        <maxmessagesize>20480</maxmessagesize>
+        <addressBracketsEnforcement>false</addressBracketsEnforcement>
+        <smtpGreeting>brandedServerName SMTP Server</smtpGreeting>
+        <!-- The configuration handler chain -->
+        <handlerchain>
+            <!-- With ValidRcptHandler, all email will get rejected which has no valid user -->
+            <!-- You need to add the recipient to the validRecipient list if you want -->
+            <!-- to accept email for a recipient which not exist on the server -->
+            <!-- If you want James to act as a spamtrap or honeypot, you may comment ValidRcptHandler -->
+            <!-- and implement the needed processors in spoolmanager.xml -->
+            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+            <!-- Load the core command handlers -->
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
+   <!-- The SMTP server is enabled by default -->
+   <!-- Disabling blocks will stop them from listening, -->
+   <!-- but does not free as many resources as removing them would -->
+   <smtpserver enabled="true">
+
+     <jmxName>smtpserver</jmxName>
+
+     <!-- Configure this to bind to a specific inetaddress -->
+     <!-- Please NOTE: you should add this IP also to your RemoteAddrNotInNetwork -->
+     <!-- in order to avoid relay check for locallly generated bounces -->
+     <!-- 
+            Port 25 is the well-known/IANA registered port for SMTP. 
+            Port 465 is the well-known/IANA registered port for SMTP over TLS.
+            -->
+     <bind>0.0.0.0:${sys:smtp.port}</bind>
+
+     <connectionBacklog>200</connectionBacklog>
+
+      
+        <!-- This is the name used by the server to identify itself in the SMTP -->
+        <!-- protocol.  If autodetect is TRUE, the server will discover its -->
+        <!-- own host name and use that in the protocol.  If discovery fails, -->
+        <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
+        <!-- will use the specified value. -->
+        <!--
+        <helloName autodetect="true">myMailServer</helloName>
+         -->
+         
+        <!-- connection timeout in secconds -->
+        <connectiontimeout>360</connectiontimeout>
+
+        <!-- Set the maximum simultaneous incoming connections for this service -->
+        <connectionLimit>200</connectionLimit>
+         
+        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+        <connectionLimitPerIP>20</connectionLimitPerIP>
+         
+        <!--  Uncomment this if you want to require SMTP authentication.
+
+               supported values:
+               true: required but announced only to not authorizedAddresses
+               false: don't use AUTH
+               announce: like true, but always announce AUTH capability to clients
+
+               The correct behaviour per RFC value would be false or announce
+               but we still support true for backward compatibility and because
+               some webmail client fails when AUTH is announced but no authentication
+               information has been provided
+          -->
+        
+        <!--<authRequired>true</authRequired>-->
+         
+
+<!-- CHECKME! -->
+        <!--  Uncomment this if you want to authorize specific addresses/networks.
+               If you use SMTP AUTH, addresses that match those specified here will
+               be permitted to relay without SMTP AUTH.  If you do not use SMTP
+               AUTH, and you specify addreses here, then only addresses that match
+               those specified will be permitted to relay.
+
+               Addresses may be specified as a an IP address or domain name, with an
+               optional netmask, e.g.,
+
+               127.*, 127.0.0.0/8, 127.0.0.0/255.0.0.0, and localhost/8 are all the same
+
+               See also the RemoteAddrNotInNetwork matcher in the transport processor.
+               You would generally use one OR the other approach.
+         -->
+        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>
+
+        <!--  Uncomment this if you want to verify sender addresses, ensuring that -->
+        <!--  the sender address matches the user who has authenticated. -->
+        <!--  This prevents a user of your mail server from acting as someone else -->
+        <!--  If unspecified, default value is true -->
+        <!--
+        <verifyIdentity>true</verifyIdentity>
+         -->
+
+        <!--  This sets the maximum allowed message size (in kilobytes) for this -->
+        <!--  SMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+        <maxmessagesize>20480</maxmessagesize>
+         
+        <!--  This sets wether to enforce the use of HELO/EHLO salutation before a -->
+        <!--  MAIL command is accepted. If unspecified, the value defaults to true -->
+        <!-- 
+        <heloEhloEnforcement>true</heloEhloEnforcement>
+         -->
+         
+        <!-- WARNING: This is Non-RFC compliant (default value: true) -->
+        <!-- See: http://wiki.apache.org/james/StandardsComplianceStatement -->
+        <!-- TODO: CHANGE TO OFFICIAL URL LATER -->
+        <addressBracketsEnforcement>false</addressBracketsEnforcement>
+         
+        <!-- This sets the SMTPGreeting which will be used when connect to the smtpserver -->
+        <!-- If none is specified a default is generated -->
+        
+        <smtpGreeting>brandedServerName SMTP Server</smtpGreeting>
+         
+         
+        <!-- The configuration handler chain -->
+        <handlerchain>
+
+            <!-- This connect handler can be used to enable POP3 before SMTP support -->
+            <!-- Plz note that only the ip get stored to indentify an authenticated client -->
+            <!-- The expireTime is the time after which an ipAddress is handled as expired -->
+            <!--
+            <handler class="org.apache.james.smtpserver.POP3BeforeSMTPHandler">
+                <expireTime>1 hour</expireTime>
+            </handler>
+             -->
+            
+            <!-- This command handler check against RBL-Lists -->
+            <!-- If getDetail is set to true it try to retrieve information from TXT Record -->
+            <!-- why the ip was blocked. Default to false -->           
+            <!-- STOP - before you uncomment out the DNS RBL handler,
+                  please take a moment to review each block list.  We
+                  have included some that various JAMES committers use,
+                  but you must decide which, if any, are appropriate
+                  for your environment.  The mail servers hosting
+                  @apache.org mailing lists, for example, use a
+                  slightly different list than we have included below.
+                  And it is likely that most JAMES committes also have
+                  slightly different sets of lists.  The SpamAssassin
+                  user's list would be one good place to discuss the
+                  measured quality of various block lists.
+
+                NOTA BENE: the domain names, below, are terminated
+                with '.' to ensure that they are absolute names in
+                DNS lookups.  Under some circumstances, names that
+                are not explicitly absolute could be treated as
+                relative names, leading to incorrect results.  This
+                has been observed on *nix and MS-Windows platforms
+                by users of multiple mail servers, and is not JAMES
+                specific.  If you are unsure what this means for you,
+                please speak with your local system/network admins.
+            -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.DNSRBLHandler">
+               <getDetail>false</getDetail>
+               <rblservers>
+                   <whitelist>query.bondedsender.org.</whitelist>
+                   <blacklist>sbl-xbl.spamhaus.org.</blacklist>
+                   <blacklist>dul.dnsbl.sorbs.net.</blacklist>
+                   <blacklist>list.dsbl.org.</blacklist>
+               </rblservers>
+           </handler>
+            -->
+     
+            <!-- This command handler can be used to reject emails with not match the SPF record of the sender domain -->
+            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
+            <!-- are allowed to relay. Default is false. --> 
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.SPFHandler">
+               <blockSoftFail>false</blockSoftFail>
+               <blockPermError>true</blockPermError>
+           </handler>
+            -->
+                 
+            <!-- checks for resolvable HELO/EHLO before accept the HELO/EHLO -->
+            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
+            <!-- are allowed to relay. Default is false. -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.ResolvableEhloHeloHandler"/>
+            -->
+            
+            <!-- Checks HELO/EHLO is equal the reverse of the connecting client before accept it -->
+            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
+            <!-- are allowed to relay. Default is false. -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.ReverseEqualsEhloHeloHandler"/>
+            -->
+            
+            <!-- If activated mail is only accepted if the sender contains -->
+            <!-- a resolvable domain having a valid MX Record or A Record associated! -->
+            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
+            <!-- are allowed to relay. Default is false. -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.ValidSenderDomainHandler"/>
+            -->
+         
+            <!-- With ValidRcptHandler, all email will get rejected which has no valid user -->
+            <!-- You need to add the recipient to the validRecipient list if you want -->
+            <!-- to accept email for a recipient which not exist on the server -->
+            <!-- If you want James to act as a spamtrap or honeypot, you may comment ValidRcptHandler -->
+            <!-- and implement the needed processors in spoolmanager.xml -->
+            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+            
+            <!-- If activated you can limit the maximal recipients -->
+            <!-- 
+           <handler class="org.apache.james.smtpserver.fastfail.MaxRcptHandler">
+               <maxRcpt>10</maxRcpt>
+           </handler>
+            -->
+            
+            <!-- If uncomment this block you can enable greylisting. For more infos-->
+            <!-- how greylisting work see: http://projects.puremagic.com/greylisting/whitepaper.html -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.JDBCGreylistHandler">
+               <repositoryPath>db://maildb</repositoryPath>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <tempBlockTime>1 hour</tempBlockTime>
+               <unseenLifeTime>4 hours</unseenLifeTime>
+               <autoWhiteListLifeTime>36 days</autoWhiteListLifeTime>
+               <whitelistedNetworks>127.0.0.0/8</whitelistedNetworks>
+           </handler>
+            -->
+            
+            <!-- Tarpitting is a method to insert a small sleep after each rcpt. For more -->
+            <!-- infos read this: http://www.palomine.net/qmail/tarpit.html . -->
+            <!-- Default is set to 0 (disabled). -->
+            <!-- You can also configure the time to sleep in milliseconds -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.TarpitHandler">
+               <tarpitRcptCount>5</tarpitRcptCount>
+               <tarpitSleepTime>5000</tarpitSleepTime>
+           </handler>
+            -->
+         
+            <!-- This handler ignore duplicated recipients per session. So the email will get only send on time even -->
+            <!-- if the recipient is specified more then once -->
+            <!--
+           <handler class="org.apache.james.smtpserver.protocol.core.fastfail.SuppressDuplicateRcptHandler"/>
+            -->
+     
+            <!-- Load the core command handlers -->
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>       
+           
+            <!-- This handler can add a hint to the mail which tells the MailQueue which email should get processed first -->
+            <!-- Normally the MailQueue will just handles Mails in FIFO manner -->
+            <!-- Valid priority values are 1,5,9 where 9 is the highest-->
+            <!-- 
+           <handler class="org.apache.james.smtpserver.MailPriortyHandler">
+               <priorityEntries>
+                   <priorityEntry>
+                       <domain>yourdomain1</domain>
+                       <priority>1</priority>
+                   </priorityEntry>
+                   <priorityEntry>
+                       <domain>yourdomain2</domain>
+                       <priority>9</priority>
+                   </priorityEntry>
+               <priorityEntries>
+           </handler>
+            -->
+             
+            <!-- This MessageHandler could be used to check message against spamd before -->
+            <!-- accept the email. So its possible to reject a message on smtplevel if a -->
+            <!-- configured hits amount is reached. -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.SpamAssassinHandler">
+               <spamdHost>127.0.0.1</spamdHost>
+               <spamdPort>783</spamdPort>
+               <spamdRejectionHits>10</spamdRejectionHits>
+           </handler>
+            -->
+     
+            <!-- This MessageHandler could be used to extract domain out of the message and check -->
+            <!-- this domains against uriRbllists. See http://www.surbl.org for more informations. -->
+            <!-- The message get rejected if a domain matched . -->
+            <!--
+           <handler class="org.apache.james.smtpserver.fastfail.URIRBLHandler">
+               <action>reject</action>
+               <getDetail>true</getDetail>
+               <uriRblServers>
+                   <server>multi.surbl.org</server>
+               </uriRblServers>
+           </handler>
+            -->
+            <!-- 
+           <handler class="org.apache.james.smtpserver.SetMimeHeaderHandler">
+               <headername>SPF-test</headername>
+               <headervalue>passed</headervalue>
+           </handler>
+            -->
+        </handlerchain>           
+  
+    </smtpserver>
+
+</smtpservers>
+
+
Index: container/spring-integration-tests/src/test/resources/mailbox.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/mailbox.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/mailbox.xml	(Revision 5834)
@@ -0,0 +1,34 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+ 
+<mailbox>
+   <!-- supported providers are: -->
+   <!-- jpa, jcr, maildir, hbase, memory -->
+   <!--  -->
+   <!-- Be aware that maildir will only work on unix like operation systems! -->
+   <provider>jpa</provider>
+</mailbox>
Index: container/spring-integration-tests/src/test/resources/recipientrewritetable.xml
===================================================================
--- container/spring-integration-tests/src/test/resources/recipientrewritetable.xml	(Revision 0)
+++ container/spring-integration-tests/src/test/resources/recipientrewritetable.xml	(Revision 5834)
@@ -0,0 +1,57 @@
+<?xml version="1.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.                                           
+ -->
+    
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!-- If set recursiveMapping false only the first mapping will get processed. -->
+<!-- Default true. -->
+<!-- By setting the mappingLimit you can specify how much mapping will get processed -->
+<!-- before a bounce will send. This avoid infinity loops. Default 10.  -->
+<!--
+<recipientrewritetable  class="org.apache.james.rrt.xml.XMLRecipientRewriteTable">
+   <recursiveMapping>true</recursiveMapping>
+   <mappingLimit>10</mappingLimit>
+    
+   <mapping>some@domain=someuser</mapping>
+</recipientrewritetable>
+-->
+
+<!-- Database backed RecipientRewritetable -->
+<!-- -->
+<!-- Use these configurations to store the RecipientRewriteTable in a database. -->
+<!-- 
+<recipientrewritetable class="org.apache.james.rrt.jdbc.JDBCRecipientRewriteTable" destinationURL="db://maildb/RecipientRewriteTable">
+   <recursiveMapping>true</recursiveMapping>
+   <mappingLimit>10</mappingLimit>
+   <sqlFile>file://conf/sqlResources.xml</sqlFile>
+</recipientrewritetable>
+-->
+    
+<!-- The default table for storing James' RecipientRewriteTable mappings. -->
+<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
+   <recursiveMapping>true</recursiveMapping>
+   <mappingLimit>10</mappingLimit>
+</recipientrewritetable>
+
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSingleThreadStressTestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSingleThreadStressTestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSingleThreadStressTestForked.java	(Revision 5834)
@@ -0,0 +1,148 @@
+/****************************************************************
+ * 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.container.spring;
+
+import com.sun.mail.imap.AppendUID;
+import com.sun.mail.imap.IMAPFolder;
+import java.io.IOException;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author MaSt
+ */
+public class IMAPServerJavaMailSingleThreadStressTestForked extends JavaMailTestBase {
+
+    private static final Logger log = Logger.getLogger(IMAPServerJavaMailSingleThreadStressTestForked.class.getName());
+
+    public static final long MESSAGE_CREATION_PHASE_DURATION_MILLIS = 12 * 1000L;
+
+    /**
+     * Randomly fails with Netty 3.3.1.
+     *
+     * @throws MessagingException
+     */
+    @Test
+    public void testAppendMessages() throws MessagingException {
+        log.debug("testAppendMessages()");
+        connectNewImapStore();
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        long msgCount = 0;
+
+        final IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+        inbox.open(Folder.READ_WRITE);
+        final long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+
+        while (System.currentTimeMillis() < plannedEndTime) {
+            log.trace("appending message to INBOX");
+            inbox.appendMessages(
+                    new Message[]{createSimpleMessage(tagPrefix + ++msgCount)});
+            inbox.close(false);
+            inbox.open(Folder.READ_WRITE);
+            Message[] msgs = inbox.getMessages();
+            assertEquals(msgCount, msgs.length);
+            for (Message m : msgs) {
+                m.getFlags();
+            }
+        }
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to same INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        disconnectImapStore();
+    }
+
+    /**
+     * Often fails with Netty 3.8.1+SSL.
+     * @throws MessagingException
+     */
+    @Test
+    public void testAppendMessagesAndReopenInbox() throws MessagingException {
+        log.debug("testAppendMessagesAndReopenInbox()");
+        connectNewImapStore();
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+
+        IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+        inbox.open(Folder.READ_WRITE);
+        while (System.currentTimeMillis() < plannedEndTime) {
+            log.trace("appending message to INBOX");
+            inbox.appendMessages(
+                    new Message[]{createSimpleMessage(tagPrefix + msgIdx.incrementAndGet())});
+            inbox.close(false);
+            inbox.open(Folder.READ_WRITE);
+        }
+
+        long duration = System.currentTimeMillis() - startTime;
+
+        log.info(String.format("%d messsages appended to same INBOX using 1 thread, %.1f msgs per second",
+                msgIdx.get(), 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        disconnectImapStore();
+    }
+
+    /**
+     *
+     * @throws MessagingException
+     */
+    @Test
+    public void testAppendUIDMessagesReopenInboxAndLoadViaUID() throws MessagingException, IOException {
+        log.debug("testAppendUIDMessagesReopenInboxAndLoadViaUID()");
+        connectNewImapStore();
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+
+        IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+        inbox.open(Folder.READ_WRITE);
+        while (System.currentTimeMillis() < plannedEndTime) {
+            log.trace("appending message to INBOX");
+            String tag = tagPrefix + msgIdx.incrementAndGet();
+            Message m1 = createSimpleMessage(tag);
+            AppendUID[] uids = inbox.appendUIDMessages(new Message[]{m1});
+            inbox.close(false);
+            inbox.open(Folder.READ_WRITE);
+            Message m2 = inbox.getMessageByUID(uids[0].uid);
+            assertTrue(IOUtils.toString(m2.getInputStream()).contains(tag));
+        }
+
+        long duration = System.currentTimeMillis() - startTime;
+
+        log.info(String.format("%d messsages appended to same INBOX using 1 thread, %.1f msgs per second",
+                msgIdx.get(), 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        disconnectImapStore();
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/JavaMailTestBase.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/JavaMailTestBase.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/JavaMailTestBase.java	(Revision 5834)
@@ -0,0 +1,253 @@
+/****************************************************************
+ * 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.container.spring;
+
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.smtp.SMTPTransport;
+import java.io.PrintStream;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.Date;
+import java.util.Properties;
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Flags;
+import javax.mail.Flags.Flag;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.NoSuchProviderException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import org.apache.commons.exec.LogOutputStream;
+import static org.apache.james.container.spring.MailServerTestBase.SMTPS_ADDRESS;
+import org.apache.log4j.Logger;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author MaSt
+ */
+public class JavaMailTestBase extends MailServerTestBase {
+
+    private static final Logger log = Logger.getLogger(JavaMailTestBase.class.getName());
+    protected ThreadLocal<Store> imapStores = new ThreadLocal<Store>();
+    protected ThreadLocal<Session> imapSessions = new ThreadLocal<Session>();
+
+    protected String sendJavaMailSmtpMessage(
+            String proto, String from, String to, boolean auth, boolean useLocalAddr, String body)
+            throws MessagingException, UnknownHostException {
+        log.debug("sendJavaMailSmtpMessage()");
+
+        if (body == null) {
+            body = "Med vennlig hilsennTov Are Jacobsen";
+        }
+
+        if (!proto.equals("smtp") && !proto.equals("smtps")) {
+            throw new RuntimeException("bad proto: " + proto);
+        }
+
+        Properties props = System.getProperties();
+        props.put("mail." + proto + ".host",
+                useLocalAddr ? "127.0.0.1" : AddressUtils.getNonLocalHostIPAddress().getHostAddress());
+        props.put("mail." + proto + ".port",
+                proto.equals("smtps") ? SMTPS_ADDRESS.getPort() : SMTP_ADDRESS.getPort());
+        props.put("mail." + proto + ".auth", auth);
+        props.put("mail." + proto + ".from", from);
+        if (proto.equals("smtps")) {
+            props.put("mail." + proto + ".ssl.enable", "true");
+            props.put("mail." + proto + ".ssl.checkserveridentity", "false");
+            props.put("mail." + proto + ".ssl.trust", "*");
+        }
+        if (log.isTraceEnabled()) {
+            props.put("mail.debug", "true");
+            props.put("mail.debug.auth", "true");
+        }
+        Session session = Session.getInstance(props, null);
+        if (log.isTraceEnabled()) {
+            session.setDebug(true);
+            session.setDebugOut(new PrintStream(new LogOutputStream() {
+                @Override
+                protected void processLine(String line, int level) {
+                    log.trace(line);
+                }
+            }));
+        }
+        Message msg = new MimeMessage(session);
+        msg.setFrom(new InternetAddress(from));
+        msg.setRecipients(Message.RecipientType.TO,
+                InternetAddress.parse(to, false));
+        msg.setSubject("Heisann " + System.currentTimeMillis());
+        msg.setText(body);
+        msg.setHeader("X-Mailer", "Tov Are's program");
+        msg.setSentDate(new Date());
+        SMTPTransport t = (SMTPTransport) session.getTransport(proto);
+        if (auth) {
+            t.connect(useLocalAddr ? "127.0.0.1" : AddressUtils.getNonLocalHostIPAddress().getHostAddress(),
+                    TEST_LOGIN_NAME_1, TEST_LOGIN_PASSWORD_1);
+        } else {
+            t.connect();
+        }
+        t.sendMessage(msg, msg.getAllRecipients());
+        log.debug("Response: " + t.getLastServerResponse());
+        t.close();
+        return t.getLastServerResponse();
+    }
+
+    public void connectNewImapStore() throws NoSuchProviderException, MessagingException {
+        assertNull(imapStores.get());
+        imapStores.set(getImapSSLStore());
+        log.debug("connect...");
+        imapStores.get().connect();
+        assertTrue(imapStores.get().isConnected());
+        log.debug("connected.");
+    }
+
+    public void disconnectImapStore() throws MessagingException {
+        assertNotNull(imapStores.get());
+        log.debug("closing store");
+        imapStores.get().close();
+        assertFalse(imapStores.get().isConnected());
+        imapStores.remove();
+    }
+
+    protected IMAPStore getImapSSLStore() throws NoSuchProviderException {
+        return getImapStore(IMAPS_ADDRESS, true);
+    }
+
+    protected IMAPStore getImapStore(InetSocketAddress address, boolean isSSL)
+            throws NoSuchProviderException {
+        Authenticator auth = new Authenticator() {
+            @Override
+            protected PasswordAuthentication getPasswordAuthentication() {
+                return new PasswordAuthentication(TEST_LOGIN_NAME_1, TEST_LOGIN_PASSWORD_1);
+            }
+        };
+
+        String proto = isSSL ? "imaps" : "imap";
+        String configPrefix = "mail." + proto + ".";
+
+        Properties props = new Properties();
+        props.put("mail.store.protocol", proto);
+        props.put("mail.host", address.getAddress().getHostAddress());
+        props.put(configPrefix + "auth", "true");
+        props.put(configPrefix + "host", address.getAddress().getHostAddress());
+        props.put(configPrefix + "port", Integer.toString(address.getPort()));
+//        props.put(configPrefix + "minidletime", 0);
+//        if (!isSSL) {
+//            props.put(configPrefix + "socketFactory.fallback", false);
+//            props.put(configPrefix + "socketFactory.class", IMAPSocketFactory.class.getName());
+//        }
+        if (isSSL) {
+            props.put(configPrefix + "ssl.checkserveridentity", "false");
+            props.put(configPrefix + "ssl.trust", "*");
+        }
+        props.put(configPrefix + "timeout", "60000");
+        props.put(configPrefix + "connectiontimeout", "60000");
+        props.put(configPrefix + "statuscachetimeout", "0");
+        if (log.isTraceEnabled()) {
+            log.trace(configPrefix + "connectiontimeout = " + props.get(configPrefix + "connectiontimeout"));
+            log.trace(configPrefix + "timeout = " + props.get(configPrefix + "timeout"));
+            props.put("mail.debug", "true");
+            props.put("mail.debug.auth", "true");
+        }
+
+        if (imapSessions.get() == null) {
+            imapSessions.set(Session.getInstance(props, auth));
+            if (log.isTraceEnabled()) {
+                log.trace("enable imap debugging");
+                imapSessions.get().setDebug(true);
+                imapSessions.get().setDebugOut(new PrintStream(new LogOutputStream() {
+                    @Override
+                    protected void processLine(String line, int level) {
+                        log.trace(line);
+                    }
+                }));
+            }
+        }
+
+        IMAPStore store = (IMAPStore) imapSessions.get().getStore(proto);
+        return store;
+    }
+
+    protected MimeMessage createSimpleMessage(String tag) throws MessagingException {
+        return createSimpleMessage(null, tag, tag);
+    }
+
+    protected MimeMessage createSimpleMessage(Session session, String subject, String body)
+            throws AddressException, MessagingException {
+        MimeMessage msg = new MimeMessage(session);
+        msg.setRecipient(Message.RecipientType.TO, new InternetAddress("me@localhost"));
+        msg.setSubject(subject);
+        Multipart mp = new MimeMultipart();
+        BodyPart bp = new MimeBodyPart();
+        bp.setText(body);
+        mp.addBodyPart(bp);
+        msg.setContent(mp);
+        msg.saveChanges();
+        return msg;
+    }
+
+    protected Message[] getMessages(IMAPFolder folder, Flags inclusionFlags, Flags exclusionFlags) throws MessagingException {
+        Message[] msgs = folder.getMessages();
+        int cnt = 0;
+        for (Message msg : msgs) {
+            boolean select = true;
+            for (Flag flag : inclusionFlags.getSystemFlags()) {
+                if (!msg.isSet(flag)) {
+                    select = false;
+                }
+            }
+            for (Flag flag : exclusionFlags.getSystemFlags()) {
+                if (msg.isSet(flag)) {
+                    select = false;
+                }
+            }
+            if (select) {
+                cnt++;
+            }
+        }
+        Message[] retMsgs = new Message[cnt];
+        cnt = 0;
+        for (Message msg : msgs) {
+            boolean select = true;
+            for (Flag flag : inclusionFlags.getSystemFlags()) {
+                if (!msg.isSet(flag)) {
+                    select = false;
+                }
+            }
+            for (Flag flag : exclusionFlags.getSystemFlags()) {
+                if (msg.isSet(flag)) {
+                    select = false;
+                }
+            }
+            if (select) {
+                retMsgs[cnt++] = msg;
+            }
+        }
+        return retMsgs;
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/CommonsIMAPClient.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/CommonsIMAPClient.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/CommonsIMAPClient.java	(Revision 5834)
@@ -0,0 +1,42 @@
+/****************************************************************
+ * 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.container.spring;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import org.apache.commons.net.imap.AuthenticatingIMAPClient;
+
+/**
+ *
+ * @author MaSt
+ */
+public class CommonsIMAPClient extends AuthenticatingIMAPClient {
+
+    public CommonsIMAPClient(boolean isSSL) {
+        super(isSSL);
+    }
+
+    public OutputStream getOutputStream() {
+        return _output_;
+    }
+
+    public InputStream getInputStream() {
+        return _input_;
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStressTestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStressTestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStressTestForked.java	(Revision 5834)
@@ -0,0 +1,420 @@
+/****************************************************************
+ * 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.container.spring;
+
+import com.sun.mail.imap.IMAPFolder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.NoSuchProviderException;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author MaSt
+ */
+public class IMAPServerJavaMailStressTestForked extends JavaMailTestBase {
+
+    private static final Logger log = Logger.getLogger(IMAPServerJavaMailStressTestForked.class.getName());
+
+    public static final long MESSAGE_CREATION_PHASE_DURATION_MILLIS = 12 * 1000L;
+    public static final long N_THREADS = 10L;
+    public static final boolean TEST_DELETE_CONTENTION = false;
+
+    public static Comparator<Message> subjectComparator = new Comparator<Message>() {
+        @Override
+        public int compare(Message e1, Message e2) {
+            try {
+                return e1.getSubject().compareTo(e2.getSubject());
+            } catch (MessagingException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+    };
+
+    /**
+     * Randomly failing with Netty 3.3.1.
+     * @throws NoSuchProviderException
+     * @throws MessagingException
+     * @throws InterruptedException
+     */
+    @Test
+    public void testMassConnectDisconnect()
+            throws NoSuchProviderException, MessagingException, InterruptedException {
+        log.debug("testMassConnectDisconnect()");
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        final AtomicBoolean failed = new AtomicBoolean(false);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    while (System.currentTimeMillis() < plannedEndTime) {
+                        connectNewImapStore();
+                        IMAPFolder inboxFolder = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                        inboxFolder.open(Folder.READ_WRITE);
+                        inboxFolder.appendMessages(
+                                new Message[]{createSimpleMessage(tagPrefix + msgIdx.incrementAndGet())});
+                        disconnectImapStore();
+                    }
+                } catch (MessagingException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                }
+            }
+        };
+
+        log.debug("creating and starting threads...");
+        List<Thread> threads = new ArrayList<Thread>();
+        for (long nThread = 0; nThread < N_THREADS; nThread++) {
+            Thread t = new Thread(r);
+            t.start();
+            threads.add(t);
+            log.trace("started thread no " + threads.size());
+        }
+        for (Thread t : threads) {
+            log.trace("waiting for thread");
+            t.join();
+        }
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX (1 per conn) using %d threads, %.1f msgs per second",
+                msgIdx.get(), N_THREADS, 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        assertFalse("failure in thread detected", failed.get());
+    }
+
+    @Test
+    public void testAppendMessagesMultipleFolders()
+            throws NoSuchProviderException, MessagingException, InterruptedException {
+        log.debug("testAppendMessagesMultipleFolders()");
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        final AtomicBoolean failed = new AtomicBoolean(false);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    connectNewImapStore();
+                    IMAPFolder threadFolder = (IMAPFolder) imapStores.get().getFolder(
+                            "tfolder" + Thread.currentThread().hashCode());
+                    threadFolder.create(Folder.HOLDS_MESSAGES);
+                    threadFolder.open(Folder.READ_WRITE);
+                    while (System.currentTimeMillis() < plannedEndTime) {
+                        threadFolder.appendMessages(
+                                new Message[]{createSimpleMessage(tagPrefix + msgIdx.incrementAndGet())});
+                    }
+                    disconnectImapStore();
+                } catch (MessagingException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                }
+            }
+        };
+        log.debug("creating and starting threads...");
+        List<Thread> threads = new ArrayList<Thread>();
+        for (long nThread = 0; nThread < N_THREADS; nThread++) {
+            Thread t = new Thread(r);
+            t.start();
+            threads.add(t);
+            log.trace("started thread no " + threads.size());
+        }
+        for (Thread t : threads) {
+            log.trace("waiting for thread");
+            t.join();
+        }
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to separate mailboxes using %d threads, %.1f msgs per second",
+                msgIdx.get(), N_THREADS, 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        assertFalse("failure in thread detected", failed.get());
+    }
+
+    /**
+     * Randomly fails with netty 3.3.1.
+     * 
+     * @throws NoSuchProviderException
+     * @throws MessagingException
+     * @throws InterruptedException
+     */
+    @Test
+    public void testAppendMessages() throws NoSuchProviderException, MessagingException, InterruptedException {
+        log.debug("testAppendMessages()");
+        connectNewImapStore();
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        final AtomicBoolean failed = new AtomicBoolean(false);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        final AtomicLong threadSeed = new AtomicLong(0L);
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    long seed;
+                    Random r;
+                    boolean doRandomReconnects;
+                    synchronized (IMAPServerJavaMailStressTestForked.this) {
+                        seed = threadSeed.getAndIncrement();
+                        r = new Random(seed);
+                        doRandomReconnects = seed % 5L == 1L;
+                        log.debug("thread seed = " + seed);
+                        log.debug("doRandomReconnects = " + doRandomReconnects);
+                        connectNewImapStore();
+                        if (threadSeed.get() != N_THREADS) {
+                            log.debug("waiting for other threads to have started");
+                            IMAPServerJavaMailStressTestForked.this.wait();
+                            log.debug("woken up by notify");
+                        } else {
+                            log.debug("I'm the last thread to have started, waking up the other threads...");
+                            IMAPServerJavaMailStressTestForked.this.notifyAll();
+                        }
+                    }
+
+                    IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                    inbox.open(Folder.READ_WRITE);
+                    while (System.currentTimeMillis() < plannedEndTime) {
+                        log.trace("appending message to INBOX");
+                        inbox.appendMessages(
+                                new Message[]{createSimpleMessage(tagPrefix + msgIdx.incrementAndGet())});
+                        if (doRandomReconnects && r.nextBoolean()) {
+                            if (r.nextBoolean()) {
+                                inbox.close(false);
+                            }
+                            disconnectImapStore();
+                            connectNewImapStore();
+                            inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                            inbox.open(Folder.READ_WRITE);
+                        }
+                    }
+                    disconnectImapStore();
+                } catch (MessagingException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                } catch (InterruptedException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                }
+            }
+        };
+        log.debug("creating and starting threads...");
+        List<Thread> threads = new ArrayList<Thread>();
+        for (long nThread = 0; nThread < N_THREADS; nThread++) {
+            Thread t = new Thread(r);
+            t.start();
+            threads.add(t);
+            log.trace("started thread no " + threads.size());
+        }
+        for (Thread t : threads) {
+            log.trace("waiting for thread");
+            t.join();
+        }
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to same INBOX using %d threads, %.1f msgs per second",
+                msgIdx.get(), N_THREADS, 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        // assert that there were no failures
+        assertFalse(failed.get());
+
+        // read subjects and verify that everything has been stored
+        IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+        inbox.open(Folder.READ_WRITE);
+        assertEquals(msgIdx.get(), inbox.getMessageCount());
+
+        startTime = System.currentTimeMillis();
+        Set<String> subjects = new HashSet<String>();
+        Message[] msgs = inbox.getMessages();
+        Arrays.sort(msgs, subjectComparator);
+        for (Message m : msgs) {
+            if (m.getSubject().startsWith(tagPrefix)) {
+                if (log.isTraceEnabled()) {
+                    log.trace(m.getSubject());
+                }
+                assertTrue(subjects.add(m.getSubject()));
+            }
+        }
+        duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("read %d messsage subjects using 1 thread, %.1f msg subjects per second",
+                subjects.size(), 1000.0 * subjects.size() / (duration > 0.0 ? duration : -1.)));
+        assertEquals(msgIdx.get(), subjects.size());
+
+        // second phase run
+        // do some multi-threaded random ops that does not alter the set of messages we have just created.
+        startTime = System.currentTimeMillis();
+        final long plannedEndTime2 = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        final AtomicLong msgIdx2 = new AtomicLong(0L);
+        r = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    Random r = new Random();
+                    connectNewImapStore();
+                    IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                    inbox.open(Folder.READ_WRITE);
+                    IMAPFolder threadFolder = (IMAPFolder) imapStores.get().getFolder(
+                            "folder" + Thread.currentThread().hashCode());
+                    threadFolder.create(Folder.HOLDS_MESSAGES);
+                    threadFolder.open(Folder.READ_WRITE);
+                    //threadFolder.setSubscribed(true);
+                    int mailsInThreadFolder = 0;
+                    while (System.currentTimeMillis() < plannedEndTime2) {
+                        if (log.isTraceEnabled()) {
+                            log.trace("starting one iteration");
+                        }
+
+                        int nextInt = r.nextInt(inbox.getMessageCount());
+                        nextInt %= N_THREADS * 2;
+                        nextInt++;
+                        Message[] msgs = new Message[]{inbox.getMessage(nextInt)};
+                        if (log.isTraceEnabled()) {
+                            log.trace("moving " + msgs[0].getSubject() + " to " + threadFolder.getFullName());
+                        }
+//                        boolean ok = false;
+//                        try {
+                        inbox.copyMessages(msgs, threadFolder);
+//                            ok = true;
+                        mailsInThreadFolder++;
+//                        } catch (MessagingException ex) {
+//                        }
+//                        if (ok) {
+//                            inbox.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);
+//                        }
+
+                        threadFolder.appendMessages(
+                                new Message[]{createSimpleMessage("" + msgIdx2.incrementAndGet())});
+                        mailsInThreadFolder++;
+
+                        msgs = new Message[]{inbox.getMessage(r.nextInt(inbox.getMessageCount()) + 1)};
+                        if (log.isTraceEnabled()) {
+                            log.trace("moving " + msgs[0].getSubject() + " to " + threadFolder.getFullName());
+                        }
+//                        ok = false;
+//                        try {
+                        inbox.copyMessages(msgs, threadFolder);
+//                            ok = true;
+                        mailsInThreadFolder++;
+//                        } catch (MessagingException ex) {
+//                        }
+//                        if (ok) {
+//                            inbox.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);
+//                        }
+
+                        // workaround for javamail status cache bug:
+                        // (https://kenai.com/bugzilla/show_bug.cgi?id=6361)
+                        threadFolder.close(false);
+                        threadFolder.open(Folder.READ_WRITE);
+                        //Thread.sleep(1100);
+                        if (threadFolder.getMessageCount() != mailsInThreadFolder) {
+                            throw new RuntimeException("invalid number of mails in thread folder: "
+                                    + threadFolder.getMessageCount() + ", expected " + mailsInThreadFolder);
+                        }
+
+//                        if (log.isTraceEnabled()) {
+//                            for (Message m : threadFolder.getMessages()) {
+//                                //log.trace("moving " + m.isSet(Flags.Flag.DELETED) + " to " + inbox.getFullName());
+//                                log.trace("moving " + m.getSubject() + " to " + inbox.getFullName());
+//                            }
+//                        }
+                        msgs = getMessages(threadFolder, new Flags(), new Flags(Flags.Flag.DELETED));
+                        log.trace("messages in thread folder: " + msgs.length
+                                + ", expected: " + mailsInThreadFolder);
+                        if (log.isTraceEnabled()) {
+                            for (Message m : msgs) {
+                                log.trace("delete status for " + m.getSubject() + " is " + m.isSet(Flags.Flag.DELETED));
+                            }
+                        }
+                        if (msgs.length != mailsInThreadFolder) {
+                            throw new RuntimeException("invalid number of mails in thread folder: "
+                                    + msgs.length + ", expected " + mailsInThreadFolder);
+                        }
+//                        threadFolder.copyMessages(msgs, inbox);
+
+                        // TODO this may produce lots of database lock contention problems:
+                        // (not with innodb)
+                        if (TEST_DELETE_CONTENTION) {
+                            threadFolder.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);
+                            threadFolder.expunge(); // database DELETE - evil!
+                            mailsInThreadFolder = 0;
+                        }
+                    }
+                    disconnectImapStore();
+                } catch (MessagingException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                } catch (RuntimeException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                }
+            }
+        };
+        log.debug("creating and starting threads...");
+        threads.clear();
+        for (long nThread = 0; nThread < N_THREADS; nThread++) {
+            Thread t = new Thread(r);
+            t.start();
+            threads.add(t);
+            log.trace("started thread no " + threads.size());
+        }
+        for (Thread t : threads) {
+            log.trace("waiting for thread");
+            t.join();
+        }
+        duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsage operations using %d threads, %.1f ops per second",
+                msgIdx2.get(), N_THREADS, 1000.0 * msgIdx2.get() / (duration > 0.0 ? duration : -1.)));
+
+        // assert that there were no failures
+        assertFalse("some thread had an execution problem", failed.get());
+
+        inbox.expunge();
+        msgs = inbox.getMessages();
+        Arrays.sort(msgs, subjectComparator);
+        // check that our messages are still there and that there are no duplicates
+        for (Message m : msgs) {
+            if (m.getSubject().startsWith(tagPrefix)) {
+                if (log.isTraceEnabled()) {
+                    log.trace(m.getSubject());
+                }
+                assertTrue("mail did not exist before the second phase run", subjects.remove(m.getSubject()));
+            }
+        }
+        assertTrue("some mail unexpectedly vanished during the second phase run", subjects.isEmpty());
+
+        disconnectImapStore();
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStress2TestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStress2TestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailStress2TestForked.java	(Revision 5834)
@@ -0,0 +1,113 @@
+/****************************************************************
+ * 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.container.spring;
+
+import com.sun.mail.imap.IMAPFolder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.NoSuchProviderException;
+import org.apache.log4j.Logger;
+import static org.junit.Assert.assertFalse;
+import org.junit.Test;
+
+/**
+ *
+ * @author MaSt
+ */
+public class IMAPServerJavaMailStress2TestForked extends JavaMailTestBase {
+
+    private static final Logger log = Logger.getLogger(IMAPServerJavaMailStress2TestForked.class.getName());
+
+    public static final long MESSAGE_CREATION_PHASE_DURATION_MILLIS = 12 * 1000L;
+    public static final long N_THREADS = 1L;
+
+    @Test
+    public void testAppendMessages() throws NoSuchProviderException, MessagingException, InterruptedException {
+        log.debug("testAppendMessages()");
+        connectNewImapStore();
+
+        final String tagPrefix = "" + new Random().nextLong() + '.' + System.currentTimeMillis() + '.';
+        final AtomicLong msgIdx = new AtomicLong(0L);
+        final AtomicBoolean failed = new AtomicBoolean(false);
+        long startTime = System.currentTimeMillis();
+        final long plannedEndTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        final AtomicLong threadSeed = new AtomicLong(0L);
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    long seed = threadSeed.getAndIncrement();
+                    log.debug("seed = " + seed);
+                    boolean doReconnect = seed % 2 == 0;
+                    log.debug("doReconnect = " + doReconnect);
+                    Random r = new Random(seed);
+
+                    connectNewImapStore();
+
+                    IMAPFolder inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                    inbox.open(Folder.READ_WRITE);
+                    while (System.currentTimeMillis() < plannedEndTime) {
+                        log.trace("appending message to INBOX");
+                        inbox.appendMessages(
+                                new Message[]{createSimpleMessage(tagPrefix + msgIdx.incrementAndGet())});
+                        if (doReconnect && r.nextBoolean()) {
+                            if (r.nextBoolean()) {
+                                inbox.close(false);
+                            }
+                            disconnectImapStore();
+                            connectNewImapStore();
+                            inbox = (IMAPFolder) imapStores.get().getFolder("Inbox");
+                            inbox.open(Folder.READ_WRITE);
+                        }
+                    }
+                    disconnectImapStore();
+                } catch (MessagingException ex) {
+                    failed.set(true);
+                    log.fatal("oups", ex);
+                }
+            }
+        };
+        log.debug("creating and starting threads...");
+        List<Thread> threads = new ArrayList<Thread>();
+        for (long nThread = 0; nThread < N_THREADS; nThread++) {
+            Thread t = new Thread(r);
+            t.start();
+            threads.add(t);
+            log.trace("started thread no " + threads.size());
+        }
+        for (Thread t : threads) {
+            log.trace("waiting for thread");
+            t.join();
+        }
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to same INBOX using %d threads, %.1f msgs per second",
+                msgIdx.get(), N_THREADS, 1000.0 * msgIdx.get() / (duration > 0.0 ? duration : -1.)));
+
+        // assert that there were no failures
+        assertFalse(failed.get());
+
+        disconnectImapStore();
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/MailServerTestBase.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/MailServerTestBase.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/MailServerTestBase.java	(Revision 5834)
@@ -0,0 +1,123 @@
+/****************************************************************
+ * 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.container.spring;
+
+import java.net.InetSocketAddress;
+import java.util.Random;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.sql.DataSource;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.jpa.model.JPAUser;
+import org.apache.log4j.Logger;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ *
+ * @author MaSt
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = "classpath:application-context.xml")
+public class MailServerTestBase {
+    private static final Logger log = Logger.getLogger(MailServerTestBase.class.getName());
+
+    public static final String TEST_LOGIN_NAME_1 = "rcpt1@localhost";
+    public static final String TEST_LOGIN_PASSWORD_1 = "testpass";
+    public static final String TEST_LOGIN_NAME_2 = "rcpt2@localhost";
+    public static final String TEST_LOGIN_PASSWORD_2 = "testpass";
+    // Password.getSaltedHash("testpass"):
+    public static final String TEST_LOGIN_PASSWORD_HASH =
+            "FD//6VrIIX0jZA5GdFFXgidKLu84CLMbnP0AKUXwgRs=$XxdWmuWGa5B6vBvMj7kt3jX9Ch6M1hwrmaIEjR5H7mY=";
+    public static final String TEST_RELAY_ADDRESS = "notexisting@not.existing1378743439d4domain.de";
+    public static final InetSocketAddress IMAPS_ADDRESS =
+            new InetSocketAddress("127.0.0.1", Integer.valueOf(System.getProperty("imaps.port", "993")));
+    public static final InetSocketAddress SMTP_ADDRESS =
+            new InetSocketAddress("127.0.0.1", Integer.valueOf(System.getProperty("smtp.port", "25")));
+    public static final InetSocketAddress SMTPS_ADDRESS =
+            new InetSocketAddress("127.0.0.1", Integer.valueOf(System.getProperty("smtps.port", "465")));
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Inject
+    protected DataSource dataSource;
+    @Inject
+    protected EntityManagerFactory emf;
+    @PersistenceContext
+    protected EntityManager em;
+    @Inject
+    protected DomainList domainList;
+    @Inject
+    protected UsersRepository userRepository;
+    @Inject
+    protected RecipientRewriteTable recipientRewriteTable;
+    protected Random r;
+
+    @Before
+    public void prepareData() {
+        assertNotNull(domainList);
+        assertNotNull(userRepository);
+        assertNotNull(recipientRewriteTable);
+
+        r = new Random(0L);
+
+        try {
+            if (domainList.containsDomain("localhost")) {
+                return;
+            }
+            domainList.addDomain("localhost");
+            //userRepository.addUser(TEST_LOGIN_NAME_1, TEST_LOGIN_PASSWORD_1);
+            //userRepository.addUser(TEST_LOGIN_NAME_2, TEST_LOGIN_PASSWORD_2);
+            EntityManager em = emf.createEntityManager();
+            em.getTransaction().begin();
+            JPAUser user = new JPAUser(TEST_LOGIN_NAME_1, TEST_LOGIN_PASSWORD_1, "MD5");
+            em.persist(user);
+            user = new JPAUser(TEST_LOGIN_NAME_2, TEST_LOGIN_PASSWORD_2, "MD5");
+            em.persist(user);
+            em.getTransaction().commit();
+            recipientRewriteTable.addAliasDomainMapping("localhost.alias", "localhost");
+            recipientRewriteTable.addAddressMapping("existingalias", "localhost", "rcpt1@localhost");
+            recipientRewriteTable.addAddressMapping("notexistingalias", "localhost", "notexisting@localhost");
+        } catch (DomainListException ex) {
+            throw new RuntimeException(ex);
+        } catch (RecipientRewriteTableException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+
+
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/SMTPServerTestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/SMTPServerTestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/SMTPServerTestForked.java	(Revision 5834)
@@ -0,0 +1,503 @@
+/****************************************************************
+ * 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.container.spring;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import javax.mail.MessagingException;
+import javax.mail.SendFailedException;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedTrustManager;
+import org.apache.commons.net.ProtocolCommandEvent;
+import org.apache.commons.net.ProtocolCommandListener;
+import org.apache.commons.net.smtp.AuthenticatingSMTPClient;
+import org.apache.commons.net.smtp.SMTPClient;
+import org.apache.commons.net.smtp.SMTPReply;
+import org.apache.james.domainlist.jpa.JPADomainList;
+import org.apache.james.rrt.jpa.JPARecipientRewriteTable;
+import org.apache.james.user.jpa.JPAUsersRepository;
+import org.apache.log4j.Logger;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * 
+ * @author MaSt
+ */
+public class SMTPServerTestForked extends JavaMailTestBase {
+
+    private static final Logger log = Logger.getLogger(SMTPServerTestForked.class.getName());
+
+    private static final String msgData = "Subject: some subject\r\n\r\nthe body...";
+    protected static SMTPClient commonsSmtpClient = null;
+
+    @Test
+    public void testAddressMappingExistingTarget() throws IOException {
+        log.debug("testAddressMappingExistingTarget()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("existingalias@localHOST");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    // gets accepted, needs delivery testing
+    @Test
+    public void testAddressMappingNonExistingTarget() throws IOException {
+        log.debug("testAddressMappingNonExistingTarget()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("notexistingalias@localHOST");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testDomainAliasPositive() throws IOException {
+        log.debug("testDomainAliasPositive()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("rcpt1@localhost.alias");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    // gets accepted although the user does not exist for the target domain (domainalias handled at all?)
+    @Test
+    public void testDomainAliasNonExistingUser() throws IOException {
+        log.debug("testDomainAliasNonExistingUser()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("notexisting@localhost.alias");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testInvalidDomain() throws IOException {
+        log.debug("testInvalidDomain()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("rcpt1@localhost.not.existing.domain23131.de");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testInvalidUser() throws IOException {
+        log.debug("testInvalidUser()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // accepted for relay
+        commonsSmtpClient.addRecipient("notexisting@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testGreeting() throws IOException {
+        log.debug("testGreeting()");
+        connectNewCommonsSmtpClient();
+
+        String greeting = commonsSmtpClient.getReplyString();
+        assertEquals("220 brandedServerName SMTP Server\r\n", greeting);
+        assertFalse(greeting.toLowerCase().contains("james"));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testGreetingSSL() throws IOException {
+        log.debug("testGreetingSSL()");
+        connectNewCommonsSmtpsClient();
+
+        String greeting = commonsSmtpClient.getReplyString();
+        assertEquals("220 brandedServerName SMTP Server\r\n", greeting);
+        assertFalse(greeting.toLowerCase().contains("james"));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testUsingJPA() {
+        log.debug("testUsingJPA()");
+        assertTrue(domainList.getClass().getCanonicalName(), domainList instanceof JPADomainList);
+        assertTrue(userRepository.getClass().getCanonicalName(), userRepository instanceof JPAUsersRepository);
+        assertTrue(recipientRewriteTable.getClass().getCanonicalName(), recipientRewriteTable instanceof JPARecipientRewriteTable);
+    }
+
+    public void connectNewCommonsSmtpClient() throws IOException {
+        connectNewCommonsSmtpClient(false);
+    }
+
+    public void connectNewCommonsSmtpsClient() throws IOException {
+        connectNewCommonsSmtpClient(true);
+    }
+
+    protected void setAllTrustingTrustManager() {
+        ((AuthenticatingSMTPClient) commonsSmtpClient).setTrustManager(new X509ExtendedTrustManager() {
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
+            }
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
+            }
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            @Override
+            public X509Certificate[] getAcceptedIssuers() {
+                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+            }
+        });
+    }
+
+    public void connectNewCommonsSmtpClient(boolean isSSL) throws IOException {
+        InetSocketAddress serverAddress = null;
+        if (isSSL) {
+            commonsSmtpClient = new AuthenticatingSMTPClient("TLSv1", true);
+            setAllTrustingTrustManager();
+            serverAddress = SMTPS_ADDRESS;
+        } else {
+            commonsSmtpClient = new SMTPClient();
+            serverAddress = SMTP_ADDRESS;
+        }
+        if (log.isDebugEnabled()) {
+            commonsSmtpClient.addProtocolCommandListener(new ProtocolCommandListener() {
+
+                @Override
+                public void protocolCommandSent(ProtocolCommandEvent event) {
+                    log.debug("> " + event.getMessage().trim());
+                }
+
+                @Override
+                public void protocolReplyReceived(ProtocolCommandEvent event) {
+                    log.debug("< " + event.getMessage().trim());
+                }
+            });
+        }
+        log.info("address: " + serverAddress.toString() + " (isSSL=" + isSSL + ")");
+        commonsSmtpClient.connect(serverAddress.getAddress().getHostAddress(), serverAddress.getPort());
+        assertTrue("connect ok", SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+    }
+
+    public void disconnectCommonsSmtpClient() throws IOException {
+        if (commonsSmtpClient != null) {
+            log.info("sending QUIT");
+            commonsSmtpClient.quit();
+            assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+            log.info("closing connection");
+            commonsSmtpClient.disconnect();
+            commonsSmtpClient = null;
+        }
+    }
+
+    @Ignore
+    @Test
+    public void testTransactionBeginErrorHandling() throws IOException {
+        log.debug("testTransactionBeginErrorHandling()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertFalse(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativeTransient(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Ignore
+    @Test
+    public void testTransactionCommitErrorHandling() throws IOException {
+        log.debug("testTransactionCommitErrorHandling()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertFalse(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativeTransient(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testSmallMessage() throws IOException {
+        log.debug("testSmallMessage()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        Writer writer = commonsSmtpClient.sendMessageData();
+        writer.append(msgData);
+        writer.close();
+        commonsSmtpClient.completePendingCommand();
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testMultipleSmallMessagesNoSenderNoDest() throws IOException {
+        log.debug("testMultipleSmallMessagesNoSenderNoDest()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        assertFalse(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testMultipleSmallMessagesNoSender() throws IOException {
+        log.debug("testMultipleSmallMessagesNoSender()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.addRecipient("rcpt1@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testMultipleSmallMessagesNoDest() throws IOException {
+        log.debug("testMultipleSmallMessagesNoDest()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.setSender("sender@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+        assertFalse(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testMultipleSmallMessages() throws IOException {
+        log.debug("testMultipleSmallMessages()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.setSender("sender@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+        commonsSmtpClient.addRecipient("rcpt1@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testLargeMessage() throws IOException {
+        log.debug("testLargeMessage()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // limit should be 20 MB
+        assertTrue(commonsSmtpClient.sendShortMessageData(constructLargeMessage(20 * 1024 * 1024 - 1024)));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test
+    public void testTooLargeMessage() throws IOException {
+        log.debug("testTooLargeMessage()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        commonsSmtpClient.sendCommand("RSET");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.sendCommand("MAIL FROM:<sender@localhost> SIZE=30123123");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+        assertTrue(commonsSmtpClient.getReplyString().contains("Message size exceeds fixed maximum message size"));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    // bug? disconnect not working properly after trying to transmit a too large message
+    @Ignore
+    @Test
+    public void testTooLargeMessageNoSizeExt() throws IOException {
+        log.debug("testTooLargeMessage()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // limit should be 20 MB
+        assertFalse(commonsSmtpClient.sendShortMessageData(constructLargeMessage(20 * 1024 * 1024 + 1024)));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    // bug? small message after too large message not accepted
+    @Ignore
+    @Test
+    public void testSmallMessageAfterTooLargeMessageNoSizeExt() throws IOException {
+        log.debug("testSmallMessageAfterTooLargeMessage()");
+        connectNewCommonsSmtpClient();
+        initialComms();
+
+        // limit should be 20 MB
+        assertFalse(commonsSmtpClient.sendShortMessageData(constructLargeMessage(20 * 1024 * 1024 + 1024)));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isNegativePermanent(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.setSender("sender@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+        commonsSmtpClient.addRecipient("rcpt1@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+        assertTrue(commonsSmtpClient.sendShortMessageData(msgData));
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        disconnectCommonsSmtpClient();
+    }
+
+    @Test(expected = SendFailedException.class)
+    public void testSSLRelayNoAuthNonLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtps", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, false, false, null);
+    }
+
+    @Test
+    public void testSSLRelayAuthNonLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtps", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, true, false, null);
+    }
+
+    @Test
+    public void testSSLRelayNoAuthLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtps", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, false, true, null);
+    }
+
+    @Test
+    public void testSSLRelayAuthLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtps", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, true, true, null);
+    }
+
+    @Test(expected = SendFailedException.class)
+    public void testNoSSLRelayNoAuthNonLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtp", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, false, false, null);
+    }
+
+    @Test(expected = SendFailedException.class)
+    public void testNoSSLRelayAuthNonLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtp", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, true, false, null);
+    }
+
+    @Test
+    public void testNoSSLRelayNoAuthLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtp", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, false, true, null);
+    }
+
+    @Test
+    public void testNoSSLRelayAuthLocal() throws MessagingException, UnknownHostException {
+        sendJavaMailSmtpMessage("smtp", TEST_LOGIN_NAME_1, TEST_RELAY_ADDRESS, true, true, null);
+    }
+
+    private String constructLargeMessage(int size) {
+        StringBuilder sb = new StringBuilder(size);
+        while (sb.length() < size) {
+            sb.append(msgData);
+        }
+        return sb.toString().substring(0, size);
+    }
+
+    private void initialComms() throws IOException {
+        commonsSmtpClient.sendCommand("EHLO", "localhost");
+        assertTrue(SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.setSender("sender@localhost");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.addRecipient("rcPt1@localHOST");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+
+        commonsSmtpClient.addRecipient("RCpt2@localHOST");
+        assertTrue("Reply=" + commonsSmtpClient.getReplyString(), SMTPReply.isPositiveCompletion(commonsSmtpClient.getReplyCode()));
+    }
+
+    /**
+     * TODO.
+     *
+     * Check that emails do not contain JAMES references (ie. in the Received header fields).
+     * 
+     * Needed for branding.
+     */
+    @Ignore
+    @Test
+    public void testForJamesAnywhereInReceivedEmail() {
+
+    }
+
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/AddressUtils.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/AddressUtils.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/AddressUtils.java	(Revision 5834)
@@ -0,0 +1,75 @@
+/****************************************************************
+ * 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.container.spring;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+
+/**
+ *
+ * @author MaSt
+ */
+public class AddressUtils {
+
+    public static InetAddress getNonLocalHostIPAddress() throws UnknownHostException {
+        try {
+            InetAddress candidateAddress = null;
+            // Iterate all NICs (network interface cards)...
+            for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) {
+                NetworkInterface iface = ifaces.nextElement();
+                // Iterate all IP addresses assigned to each card...
+                for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
+                    InetAddress inetAddr = inetAddrs.nextElement();
+                    if (!inetAddr.isLoopbackAddress()) {
+
+                        if (inetAddr.isSiteLocalAddress() && inetAddr.getHostAddress().startsWith("192.168.")) {
+                            // Found non-loopback site-local address. Return it immediately...
+                            return inetAddr;
+                        } else if (candidateAddress == null) {
+                            // Found non-loopback address, but not necessarily site-local.
+                            // Store it as a candidate to be returned if site-local address is not subsequently found...
+                            candidateAddress = inetAddr;
+                            // Note that we don't repeatedly assign non-loopback non-site-local addresses as candidates,
+                            // only the first. For subsequent iterations, candidate will be non-null.
+                        }
+                    }
+                }
+            }
+            if (candidateAddress != null) {
+                // We did not find a site-local address, but we found some other non-loopback address.
+                // Server might have a non-site-local address assigned to its NIC (or it might be running
+                // IPv6 which deprecates the "site-local" concept).
+                // Return this non-loopback candidate address...
+                return candidateAddress;
+            }
+        } catch (SocketException e) {
+            UnknownHostException unknownHostException = new UnknownHostException("Failed to determine LAN address: " + e);
+            unknownHostException.initCause(e);
+            throw unknownHostException;
+        }
+        // At this point, we did not find a non-loopback address.
+        throw new UnknownHostException("The JDK InetAddress.getLocalHost() method unexpectedly returned null.");
+    }
+
+    private AddressUtils() {}
+
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSimpleTestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSimpleTestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerJavaMailSimpleTestForked.java	(Revision 5834)
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.container.spring;
+
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+import java.util.ArrayList;
+import java.util.List;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.NoSuchProviderException;
+import javax.mail.internet.MimeMessage;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+/**
+ *
+ * @author MaSt
+ */
+public class IMAPServerJavaMailSimpleTestForked extends JavaMailTestBase {
+
+    private static final Logger log = Logger.getLogger(IMAPServerJavaMailSimpleTestForked.class.getName());
+
+    @Test
+    public void testAppendMessagesUsingConcurrentSessions() throws NoSuchProviderException, MessagingException {
+        log.debug("testAppendMessages()");
+        connectNewImapStore();
+
+        long batchSize = 1L;
+        long nBatches = 2L;
+        for (long nBatch = 0; nBatch < nBatches; nBatch++) {
+            IMAPStore store = getImapSSLStore();
+            store.connect();
+            final IMAPFolder inbox = (IMAPFolder) store.getFolder("Inbox");
+            inbox.open(Folder.READ_WRITE);
+            List<Message> msgList = new ArrayList<Message>();
+            while (msgList.size() < batchSize) {
+                MimeMessage msg = createSimpleMessage("bla");
+                msgList.add(msg);
+            }
+            Message[] msgs = msgList.toArray(new Message[]{});
+            inbox.appendMessages(msgs);
+        }
+
+        disconnectImapStore();
+    }
+}
Index: container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerTestForked.java
===================================================================
--- container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerTestForked.java	(Revision 0)
+++ container/spring-integration-tests/src/test/java/org/apache/james/container/spring/IMAPServerTestForked.java	(Revision 5834)
@@ -0,0 +1,493 @@
+/****************************************************************
+ * 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.container.spring;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedTrustManager;
+import org.apache.commons.exec.LogOutputStream;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.net.PrintCommandListener;
+import org.apache.commons.net.SocketClient;
+import org.apache.commons.net.imap.AuthenticatingIMAPClient;
+import org.apache.commons.net.imap.IMAPReply;
+import org.apache.log4j.Logger;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * 
+ * @author MaSt
+ */
+public class IMAPServerTestForked extends MailServerTestBase {
+
+    private static final Logger log = Logger.getLogger(IMAPServerTestForked.class.getName());
+
+    public static final long MESSAGE_CREATION_PHASE_DURATION_MILLIS = 12 * 1000L;
+    private static final String msgData = "Subject: some subject\r\n\r\nthe body...";
+    private CommonsIMAPClient commonsImapClient;
+    private String greeting = null;
+    protected Pattern existsPattern = Pattern.compile("^\\*\\s+([0-9]+)\\s+EXISTS$", Pattern.CASE_INSENSITIVE);
+    protected AtomicInteger tagId = new AtomicInteger(0);
+
+    public IMAPServerTestForked() {
+    }
+
+    public void connectCommonsImapSSLClient() throws IOException {
+        connectCommonsImapClient(IMAPS_ADDRESS, true);
+    }
+
+    public void connectCommonsImapClient(InetSocketAddress address, boolean isSSL) throws IOException {
+        commonsImapClient = new CommonsIMAPClient(isSSL);
+        if (log.isTraceEnabled()) {
+            commonsImapClient.addProtocolCommandListener(new PrintCommandListener(new PrintStream(new LogOutputStream() {
+                @Override
+                protected void processLine(String line, int level) {
+                    log.trace(line);
+                }
+            })));
+        }
+        commonsImapClient.setTrustManager(new X509ExtendedTrustManager() {
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
+            }
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
+            }
+
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            @Override
+            public X509Certificate[] getAcceptedIssuers() {
+                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+            }
+        });
+        log.debug("connecting to: " + address + " (isSSL=" + isSSL + ")");
+        commonsImapClient.connect(address.getAddress().getHostAddress(), address.getPort());
+        greeting = commonsImapClient.getReplyString();
+        assertTrue(commonsImapClient.capability());
+        assertEquals(IMAPReply.OK, getReplyCode());
+        try {
+            assertTrue(commonsImapClient.auth(AuthenticatingIMAPClient.AUTH_METHOD.PLAIN,
+                    TEST_LOGIN_NAME_1, TEST_LOGIN_PASSWORD_1));
+        } catch (InvalidKeySpecException ex) {
+            throw new IOException(ex);
+        } catch (IOException ex) {
+            throw new IOException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new IOException(ex);
+        } catch (InvalidKeyException ex) {
+            throw new IOException(ex);
+        }
+        assertEquals(IMAPReply.OK, getReplyCode());
+        assertTrue(commonsImapClient.noop());
+        assertEquals(IMAPReply.OK, getReplyCode());
+    }
+
+    protected int getReplyCode() {
+        try {
+            return IMAPReply.getReplyCode(commonsImapClient.getReplyStrings()[commonsImapClient.getReplyStrings().length - 1]);
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    @Test
+    public void testLifecycle() throws IOException {
+        log.debug("testLifecycle()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.noop());
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        assertTrue(commonsImapClient.capability());
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        connectCommonsImapSSLClient();
+    }
+
+    @Test
+    public void testGreeting() throws IOException {
+        log.debug("testGreeting()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(greeting.startsWith("* OK brandedServerName IMAP4rev1 Server"));
+        assertFalse(greeting.toLowerCase().contains("james"));
+
+        connectCommonsImapSSLClient();
+    }
+
+    @Test
+    public void testLogin() throws IOException {
+        log.debug("testLogin()");
+        connectCommonsImapSSLClient();
+
+        commonsImapClient.disconnect();
+    }
+
+    @Test
+    public void testMore() throws IOException {
+        log.debug("testMore()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        commonsImapClient.disconnect();
+    }
+
+    /**
+     * Stable with Netty 3.3.1 and 3.8.1.
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testAppendMessages() throws IOException {
+        log.debug("testAppendMessage()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        long msgCount = 0;
+        do {
+            String msg = createMessage();
+            assertTrue(commonsImapClient.append("Inbox () {" + msg.length() + "+}\r\n" + msg));
+            assertEquals(IMAPReply.OK, getReplyCode());
+            msgCount++;
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    /**
+     * Very often fails with Netty 3.3.1. Stable with Netty 3.8.1.
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testAppendMessagesAndFetchFlags() throws IOException {
+        log.debug("testAppendMessagesAndFetchFlags()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        long msgCount = 0;
+        do {
+            String msg = createMessage();
+            assertTrue(commonsImapClient.append("Inbox () {" + msg.length() + "+}\r\n" + msg));
+            assertEquals(IMAPReply.OK, getReplyCode());
+            msgCount++;
+
+            assertTrue(commonsImapClient.select("Inbox"));
+            int nExists = getExists();
+            assertTrue(msgCount <= nExists);
+
+            for (int i = 1; i <= nExists; i++) {
+                assertTrue(commonsImapClient.fetch(Integer.toString(i), "FLAGS"));
+                assertEquals(IMAPReply.OK, getReplyCode());
+            }
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    protected int getExists() {
+        for (String s : commonsImapClient.getReplyStrings()) {
+            Matcher m = existsPattern.matcher(s);
+            if (m.find()) {
+                return Integer.parseInt(m.group(1));
+            }
+        }
+        throw new RuntimeException("no EXISTS line found");
+    }
+
+    /**
+     * Very often fails with Netty 3.3.1. Stable with Netty 3.8.1.
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testFetchFlagsStress() throws IOException {
+        log.debug("testFetchFlagsStress()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        String msg = createMessage();
+        assertTrue(commonsImapClient.append("Inbox () {" + msg.length() + "+}\r\n" + msg));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long flagFetchCount = 0;
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        do {
+            assertTrue(commonsImapClient.fetch("1", "FLAGS"));
+            assertEquals(IMAPReply.OK, getReplyCode());
+            flagFetchCount++;
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d flags fetched from INBOX using 1 thread, %.1f fetches per second",
+                flagFetchCount, 1000.0 * flagFetchCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    @Test
+    public void testAppendMessageAndReconnect() throws IOException {
+        log.debug("testAppendMessageAndReconnect()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        long msgCount = 0;
+        do {
+
+            String msg = createMessage();
+            assertTrue(commonsImapClient.append("Inbox () {" + msg.length() + "+}\r\n" + msg));
+            assertEquals(IMAPReply.OK, getReplyCode());
+            msgCount++;
+
+            if (r.nextBoolean()) {
+                if (r.nextBoolean()) {
+                    assertEquals(IMAPReply.OK, commonsImapClient.sendCommand("UNSELECT"));
+                }
+                assertTrue(commonsImapClient.logout());
+                assertEquals(IMAPReply.OK, getReplyCode());
+                commonsImapClient.disconnect();
+                connectCommonsImapSSLClient();
+                assertTrue(commonsImapClient.select("INBOX"));
+                assertEquals(IMAPReply.OK, getReplyCode());
+            }
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    /**
+     * triggers a bug in netty 3.4.0.Alpha1 ... 3.8.1.
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    @Test
+    public void testAppendMessagePartByPartReducedSize() throws IOException, InterruptedException {
+        log.debug("testAppendMessagePartByPartReducedSize()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        long msgCount = 0;
+        int chunksize = 256;
+        do {
+            log.trace("chunksize = " + chunksize);
+
+            String msg = createMessage();
+            String tag = "B" + tagId.getAndIncrement();
+            String cmd = tag + " APPEND Inbox () {" + msg.length() + "+}" + SocketClient.NETASCII_EOL;
+
+            byte[] allData = (cmd + msg + SocketClient.NETASCII_EOL).getBytes();
+            log.trace("all data size = " + allData.length);
+            int offset = 0;
+            while (offset < allData.length) {
+                int _chunksize = chunksize;
+                if (offset + _chunksize > allData.length) {
+                    _chunksize = allData.length - offset;
+                }
+                log.trace("offset     = " + offset);
+                log.trace("_chunksize = " + _chunksize);
+                commonsImapClient.getOutputStream().write(allData, offset, _chunksize);
+                commonsImapClient.getOutputStream().flush();
+                offset += _chunksize;
+            }
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(commonsImapClient.getInputStream()));
+            String line;
+            do {
+                line = br.readLine();
+                log.trace(line);
+            } while (!line.startsWith(tag + " OK "));
+            // B8 OK [APPENDUID 710005855 9] APPEND completed.
+            Matcher m = Pattern.compile("^"+tag+" OK \\[APPENDUID \\d+ (\\d+)\\] APPEND completed\\.$").matcher(line);
+            assertTrue(m.find());
+            String msgId = m.group(1);
+
+            msgCount++;
+
+            tag = "B" + tagId.getAndIncrement();
+            allData = (tag + " FETCH "+msgId+" body[]" + SocketClient.NETASCII_EOL).getBytes();
+            commonsImapClient.getOutputStream().write(allData);
+            commonsImapClient.getOutputStream().flush();
+            // * 1 FETCH (BODY[] {388}
+            String regex = "^\\* "+msgId+" FETCH .* \\{(\\d+)\\}$";
+            log.debug(regex);
+            Pattern p = Pattern.compile(regex);
+            do {
+                line = br.readLine();
+                log.trace(line);
+                m = p.matcher(line);
+            } while (!m.find());
+            int size = Integer.parseInt(m.group(1));
+            byte[] data = new byte[size];
+            IOUtils.read(commonsImapClient.getInputStream(), data, 0, size);
+            assertEquals(msg, new String(data));
+            do {
+                line = br.readLine();
+                log.trace(line);
+            } while (!line.startsWith(tag + " OK "));
+
+            chunksize /= 2;
+            if (chunksize < 10) {
+                chunksize = 10;
+            }
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    @Test
+    public void testAppendMessagePartByPart() throws IOException, InterruptedException {
+        log.debug("testAppendMessagePartByPart()");
+        connectCommonsImapSSLClient();
+
+        assertTrue(commonsImapClient.select("INBOX"));
+        assertEquals(IMAPReply.OK, getReplyCode());
+
+        long startTime = System.currentTimeMillis();
+        long endTime = startTime + MESSAGE_CREATION_PHASE_DURATION_MILLIS;
+        long msgCount = 0;
+        do {
+            String msg = createMessage();
+            String tag = "B" + tagId.getAndIncrement();
+            String cmd = tag + " APPEND Inbox () {" + msg.length() + "+}";
+
+            commonsImapClient.getOutputStream().write((cmd + commonsImapClient.NETASCII_EOL).getBytes());
+            commonsImapClient.getOutputStream().flush();
+            commonsImapClient.getOutputStream().write((msg + commonsImapClient.NETASCII_EOL).getBytes());
+            commonsImapClient.getOutputStream().flush();
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(commonsImapClient.getInputStream()));
+            String line;
+            do {
+                line = br.readLine();
+                log.trace(line);
+            } while (!line.startsWith(tag + " OK "));
+            msgCount++;
+        } while (System.currentTimeMillis() < endTime);
+
+        long duration = System.currentTimeMillis() - startTime;
+        log.info(String.format("%d messsages appended to INBOX using 1 thread, %.1f msgs per second",
+                msgCount, 1000.0 * msgCount / (duration > 0.0 ? duration : -1.)));
+
+        commonsImapClient.disconnect();
+    }
+
+    protected String createMessage() {
+        /**
+         * <pre>A6 APPEND Inbox () {409+}
+         * To: me@localhost
+         * Message-ID: &lt;2088679777.21.1398385696421.JavaMail.mark@i5>
+         * Subject: kQ23Wrqt.1398385695136.11
+         * MIME-Version: 1.0
+         * Content-Type: multipart/mixed;
+         *    boundary="----=_Part_20_553291430.1398385696419"
+         *
+         * ------=_Part_20_553291430.1398385696419
+         * Content-Type: text/plain; charset=us-ascii
+         * Content-Transfer-Encoding: 7bit
+         *
+         * kQ23Wrqt.1398385695136.11
+         * ------=_Part_20_553291430.1398385696419--
+         * </pre>
+         */
+        StringBuilder sb = new StringBuilder(512);
+        sb.append("To: me@localhost\n"
+                + "Message-ID: <2088679777.21.1398385696421.JavaMail.mark@i5>\n"
+                + "Subject: kQ23Wrqt.1398385695136.11\n"
+                + "MIME-Version: 1.0\n"
+                + "Content-Type: multipart/mixed; \n"
+                + "   boundary=\"----=_Part_20_553291430.1398385696419\"\n"
+                + "\n"
+                + "------=_Part_20_553291430.1398385696419\n"
+                + "Content-Type: text/plain; charset=us-ascii\n"
+                + "Content-Transfer-Encoding: 7bit\n"
+                + "\n")
+                .append("kQ23Wrqt.1398385695136.11kQ23Wrqt.1398385695136.11kQ23Wrqt.1398385695136.11".substring(r.nextInt(75)))
+                .append("\n"
+                        + "------=_Part_20_553291430.1398385696419--\n");
+        return sb.toString();
+    }
+}
Index: container/spring-integration-tests/pom.xml
===================================================================
--- container/spring-integration-tests/pom.xml	(Revision 0)
+++ container/spring-integration-tests/pom.xml	(Revision 5834)
@@ -0,0 +1,499 @@
+<!--
+  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.                                           
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="
+        http://maven.apache.org/POM/4.0.0
+            http://maven.apache.org/maven-v4_0_0.xsd
+            ">
+
+    <parent>
+        <artifactId>james-server</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.0.0-beta5-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    
+    <groupId>org.apache.james</groupId>
+    <artifactId>james-server-spring-integration-tests</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache James :: Server :: Container Spring :: Integration Tests</name>
+    
+    <properties>
+        <smtp.port>1025</smtp.port>
+        <imap.port>1143</imap.port>
+        <smtps.port>1465</smtps.port>
+        <imaps.port>1993</imaps.port>
+        <jmx.address>127.0.0.1</jmx.address>
+        <jmx.port>9998</jmx.port>
+        <!-- used by james to store mails with processing errors: -->
+        <mail.dir>${basedir}/target/var/mail</mail.dir>
+        <!-- main mail domain (ie. for postmaster etc.) -->
+        <mail.domain>localhost</mail.domain>
+        <keystore.location>${basedir}/target/test-classes/keystore</keystore.location>
+    </properties>
+    
+    <profiles>
+        <profile>
+            <!-- use jenkins plugin to allocate ports in order to avoid conflicts: -->
+            <id>jenkins</id>
+            <properties>
+                <smtp.port>${env.ALLOCATED_SMTP_PORT}</smtp.port>
+                <imap.port>${env.ALLOCATED_IMAP_PORT}</imap.port>
+                <smtps.port>${env.ALLOCATED_SMTPS_PORT}</smtps.port>
+                <imaps.port>${env.ALLOCATED_IMAPS_PORT}</imaps.port>
+                <jmx.port>${env.ALLOCATED_JMX_PORT}</jmx.port>
+            </properties>
+        </profile>
+    </profiles>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <version>1.7</version>
+                <executions>
+                    <execution>
+                        <phase>process-test-resources</phase>
+                        <configuration>
+                            <tasks>
+                                <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
+                                <if>
+                                    <available file="${keystore.location}"/>
+                                    <then></then>
+                                    <else>
+                                        <genkey alias="james" storepass="nosecret" keypass="nosecret"
+                                        keystore="${keystore.location}"
+                                        dname="CN=localhost"/>
+                                    </else>
+                                </if>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>ant-contrib</groupId>
+                        <artifactId>ant-contrib</artifactId>
+                        <version>20020829</version>
+                    </dependency>
+                </dependencies>
+            </plugin>            
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>test-forked</id><!-- and here we configure the special execution -->
+                        <phase>test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <!-- needed to use spring junit runner: -->
+                            <forkCount>1</forkCount>
+                            <reuseForks>false</reuseForks>
+                            <includes>
+                                <include>**/*TestForked.java</include>
+                            </includes>
+                        </configuration>
+                    </execution>
+                </executions>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>smtp.port</name>
+                            <value>${smtp.port}</value>
+                        </property>
+                        <property>
+                            <name>imap.port</name>
+                            <value>${imap.port}</value>
+                        </property>
+                        <property>
+                            <name>smtps.port</name>
+                            <value>${smtps.port}</value>
+                        </property>
+                        <property>
+                            <name>imaps.port</name>
+                            <value>${imaps.port}</value>
+                        </property>
+                        <property>
+                            <name>jmx.port</name>
+                            <value>${jmx.port}</value>
+                        </property>
+                        <property>
+                            <name>jmx.address</name>
+                            <value>${jmx.address}</value>
+                        </property>
+                        <property>
+                            <name>mail.dir</name>
+                            <value>${mail.dir}</value>
+                        </property>
+                        <property>
+                            <name>mail.domain</name>
+                            <value>${mail.domain}</value>
+                        </property>
+                        <property>
+                            <name>keystore.location</name>
+                            <value>${keystore.location}</value>
+                        </property>
+                    </systemProperties>
+                    <runOrder>random</runOrder> <!-- use random to make tests more resilient -->
+                </configuration>
+            </plugin>            
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!-- Spring Dependencies -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-orm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+        </dependency>
+
+        <!-- AspectJ rt and weaver libs required for Spring-only AOP to parse AspectJ annotations. -->
+        <!-- The aspectj compiler is *not* required for Spring-only AOP. -->
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjrt</artifactId>
+            <version>1.7.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+            <version>1.7.4</version>
+        </dependency>
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>2.3.2</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- Logging -->
+        <!--        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-exec</artifactId>
+            <version>1.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-entitymanager</artifactId>
+            <version>4.3.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-validator-annotation-processor</artifactId>
+            <version>4.3.1.Final</version>
+        </dependency>
+        <!--        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-search</artifactId>
+        </dependency>-->
+
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!--        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+            <scope>test</scope>
+        </dependency>-->
+        <dependency>
+            <groupId>org.apache.james.protocols</groupId>
+            <artifactId>protocols-smtp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-dnsservice-dnsjava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james.protocols</groupId>
+            <artifactId>protocols-smtp</artifactId>
+            <version>${protocols.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james.protocols</groupId>
+            <artifactId>protocols-api</artifactId>
+            <version>${protocols.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james.protocols</groupId>
+            <artifactId>protocols-netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-queue-activemq</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-data-file</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-mailbox-adapter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-mailets</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-fetchmail</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-protocols-imap4</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-protocols-smtp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-protocols-lmtp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-protocols-pop3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-mailetcontainer-camel</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+            <version>${camel.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-spring</artifactId>
+            <version>${xbean-spring.version}</version>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-mailbox-spring</artifactId>
+                <version>${mailbox.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.james</groupId>
+                        <artifactId>apache-james-mailbox-openjpa</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-mailbox-tool</artifactId>
+                <version>${mailbox.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.james</groupId>
+                        <artifactId>apache-james-mailbox-memory</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>james-server-mailbox-adapter</artifactId>
+                <version>${project.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.james</groupId>
+                        <artifactId>apache-james-mailbox-maildir</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-jsieve-mailet</artifactId>
+                <version>${mailbox.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.geronimo.javamail</groupId>
+                        <artifactId>geronimo-javamail_1.4_mail</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-activation_1.1_spec</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>james-server-spring</artifactId>
+                <version>${project.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.springframework.osgi</groupId>
+                        <artifactId>spring-osgi-extender</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.osgi</groupId>
+                        <artifactId>org.osgi.core</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-jpa_2.0_spec</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>james-server-dnsservice-dnsjava</artifactId>
+                <version>${project.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-annotation_1.1_spec</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+            <!--            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>james-server-queue-activemq</artifactId>
+                <version>${project.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-annotation_1.1_spec</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>-->
+        </dependencies>
+    </dependencyManagement>
+
+</project>
+
Index: container/spring-integration-tests/README
===================================================================
--- container/spring-integration-tests/README	(Revision 0)
+++ container/spring-integration-tests/README	(Revision 5834)
@@ -0,0 +1,20 @@
+Spring-Xml-configured James/Hibernate integration example/test.
+
+This module represents a basic server setup, ie.
+
+  smtp   for incoming deliveries
+  smtps  for authenticated relaying
+  imaps  for mailbox access
+
+ROADMAP
+=======
+
+* Extend James server to allow for descriptor-only server component configuration
+  via spring component scan (backends and protocols selected via dependency
+  definitions).
+* Configure server instances via annotations?
+* Use hibernate-search. OpenJPA and the explicit usage of lucene-search
+  may be the wrong way to go forward because there is obviously no interest in
+  upgrading OpenJPA to the JPA 2.1/JSR 338 standard (which brings with it such
+  essential and useful stuff as @Index and compile/type-safe queries in a
+  standardized manner).
\ No newline at end of file

Eigenschaftsänderungen: container/spring-integration-tests
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: container/lifecycle-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: container/cli
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: container/core
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
===================================================================
--- container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java	(Revision 5815)
+++ container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java	(Revision 5834)
@@ -21,11 +21,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
-
 import org.apache.james.lifecycle.api.LogEnabled;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -44,7 +43,7 @@
     private Logger log;
 
     @Inject
-    public void setMailboxManager(MailboxManager mailboxManager) {
+    public void setMailboxManager(@Named("mailboxmanager") MailboxManager mailboxManager) {
         this.mailboxManager = mailboxManager;
     }
 

Eigenschaftsänderungen: container/mailbox-adapter
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: dns-service/dnsservice-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: dns-service/dnsservice-library
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: dns-service/dnsservice-dnsjava
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: karaf/build.sh
===================================================================
--- karaf/build.sh	(Revision 5815)
+++ karaf/build.sh	(Revision 5834)
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-(cd features && mvn clean install)
-(cd integration && mvn clean install)
-(cd distribution && mvn clean install)
Index: karaf/pom.xml
===================================================================
--- karaf/pom.xml	(Revision 0)
+++ karaf/pom.xml	(Revision 5834)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.james</groupId>
+        <artifactId>james-server</artifactId>
+        <version>3.0.0-beta5-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.james.karaf</groupId>
+    <artifactId>james-karaf</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache James :: Karaf</name>
+
+    <modules>
+        <module>features</module>
+        <module>distribution</module>
+        <module>integration</module>
+    </modules>
+</project>
Index: karaf/README.md
===================================================================
--- karaf/README.md	(Revision 5815)
+++ karaf/README.md	(Revision 5834)
@@ -35,8 +35,8 @@
 Build and run
 =============
 
-You can build the project by running the script provided in karaf folder:
-    $ ./build.sh
+You can build the project by running in karaf folder:
+    $ mvn clean install
 
 You can also build each project individually by running **$ mvn clean install** inside each maven project.
 
Index: karaf/features/pom.xml
===================================================================
--- karaf/features/pom.xml	(Revision 5815)
+++ karaf/features/pom.xml	(Revision 5834)
@@ -94,4 +94,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>

Eigenschaftsänderungen: karaf/features
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: karaf/distribution
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: karaf/integration
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: karaf
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: protocols/protocols-library
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: protocols/fetchmail
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/SwitchableDelimiterBasedFrameDecoder.java
===================================================================
--- protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/SwitchableDelimiterBasedFrameDecoder.java	(Revision 5815)
+++ protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/SwitchableDelimiterBasedFrameDecoder.java	(Revision 5834)
@@ -20,13 +20,19 @@
 package org.apache.james.imapserver.netty;
 
 import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.Channels;
 import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SwitchableDelimiterBasedFrameDecoder extends DelimiterBasedFrameDecoder {
 
+    private static final Logger logger =
+            LoggerFactory.getLogger(SwitchableDelimiterBasedFrameDecoder.class.getName());
+
 	private volatile boolean framingEnabled = true;
 	private volatile ChannelBuffer cumulation;
 
@@ -43,22 +49,49 @@
 		}
 	}
 
-	public synchronized void enableFraming() {
-		this.framingEnabled = true;
+//	public synchronized void enableFraming() {
+//        logger.debug("enableFraming()");
+//		this.framingEnabled = true;
+//
+//	}
+//
+//	public synchronized void disableFraming(final ChannelHandlerContext ctx) {
+//        logger.debug("disableFraming(" + ctx + ")");
+//		this.framingEnabled = false;
+//        ChannelBuffer c = cumulation(ctx);
+//		if(this.cumulation != null && this.cumulation.readable()) {
+//			final ChannelBuffer spareBytes = this.cumulation.readBytes(this.cumulation.readableBytes());
+//			Channels.fireMessageReceived(ctx, spareBytes);
+//		}
+//	}
 
-	}
+//	@Override
+//	protected synchronized ChannelBuffer createCumulationDynamicBuffer(final ChannelHandlerContext ctx) {
+//		this.cumulation = super.createCumulationDynamicBuffer(ctx);
+//		return this.cumulation;
+//	}
 
-	public synchronized void disableFraming(final ChannelHandlerContext ctx) {
-		this.framingEnabled = false;
-		if(this.cumulation != null && this.cumulation.readable()) {
-			final ChannelBuffer spareBytes = this.cumulation.readBytes(this.cumulation.readableBytes());
-			Channels.fireMessageReceived(ctx, spareBytes);
-		}
-	}
+    @Override
+    protected Object decode(
+            ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
+        Object _frame = super.decode(ctx, channel, buffer);
+        if(logger.isDebugEnabled()) {
+            byte[] bb = new byte[buffer.writerIndex() - buffer.readerIndex()];
+            buffer.getBytes(buffer.readerIndex(), bb);
+            logger.debug("undecoded buffer: " + buffer + " [" + new String(bb) + "]");
 
-	@Override
-	protected synchronized ChannelBuffer createCumulationDynamicBuffer(final ChannelHandlerContext ctx) {
-		this.cumulation = super.createCumulationDynamicBuffer(ctx);
-		return this.cumulation;
-	}
+            if(_frame == null) {
+                logger.debug("decoded frame: " + _frame);
+            }
+            else if(!(_frame instanceof ChannelBuffer)) {
+                logger.debug("decoded frame with strange class: "+_frame);
+            } else {
+                ChannelBuffer frame = (ChannelBuffer) _frame;
+                bb = new byte[frame.writerIndex() - frame.readerIndex()];
+                frame.getBytes(frame.readerIndex(), bb);
+                logger.debug("decoded frame: " + frame + " [" + new String(bb) + "]");
+            }
+        }
+        return _frame;
+    }
 }
\ No newline at end of file
Index: protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
===================================================================
--- protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java	(Revision 5815)
+++ protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java	(Revision 5834)
@@ -26,7 +26,6 @@
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.api.ImapSessionState;
@@ -34,6 +33,7 @@
 import org.apache.james.imap.decode.ImapDecoder;
 import org.apache.james.imap.decode.ImapRequestLineReader;
 import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferFactory;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelFutureListener;
@@ -41,12 +41,16 @@
 import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelStateEvent;
 import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link FrameDecoder} which will decode via and {@link ImapDecoder} instance
  */
 public class ImapRequestFrameDecoder extends FrameDecoder implements NettyConstants {
 
+    private static final Logger log = LoggerFactory.getLogger(ImapRequestFrameDecoder.class.getName());
+
     private final ImapDecoder decoder;
     private final int inMemorySizeLimit;
     private final int literalSizeLimit;
@@ -59,6 +63,7 @@
         this.decoder = decoder;
         this.inMemorySizeLimit = inMemorySizeLimit;
         this.literalSizeLimit = literalSizeLimit;
+        setMaxCumulationBufferCapacity(inMemorySizeLimit);
     }
 
     @Override
@@ -77,6 +82,10 @@
         buffer.markReaderIndex();
         boolean retry = false;
 
+        if(log.isTraceEnabled()) {
+            log.trace("decode(): " + buffer + " => " + buffer.toString("US-ASCII"));
+        }
+        
         ImapRequestLineReader reader;
         // check if we failed before and if we already know how much data we
         // need to sucess next run
@@ -85,6 +94,9 @@
         if (attachment.containsKey(NEEDED_DATA)) {
             retry = true;
             size = (Integer) attachment.get(NEEDED_DATA);
+            if(log.isTraceEnabled()) {
+                log.trace("needed size = " + size);
+            }
             // now see if the buffer hold enough data to process.
             if (size != NettyImapRequestLineReader.NotEnoughDataException.UNKNOWN_SIZE && size > buffer.readableBytes()) {
 
@@ -181,7 +193,7 @@
 //                    channel.getPipeline().addFirst(FRAMER, handler);
 //                }
                 
-                ((SwitchableDelimiterBasedFrameDecoder) channel.getPipeline().get(FRAMER)).enableFraming();
+//                ((SwitchableDelimiterBasedFrameDecoder) channel.getPipeline().get(FRAMER)).enableFraming();
                 
                 attachment.clear();
                 return message;
@@ -201,8 +213,8 @@
 //                attachment.put(FRAMER, handler);
 
                 // SwitchableDelimiterBasedFrameDecoder added further to JAMES-1436.
-                final SwitchableDelimiterBasedFrameDecoder framer = (SwitchableDelimiterBasedFrameDecoder) pipeline.get(FRAMER);
-                framer.disableFraming(framerContext);
+//                final SwitchableDelimiterBasedFrameDecoder framer = (SwitchableDelimiterBasedFrameDecoder) pipeline.get(FRAMER);
+//                framer.disableFraming(framerContext);
                 
                 buffer.resetReaderIndex();
                 return null;
@@ -217,21 +229,23 @@
         }
     }
 
-    @SuppressWarnings("unchecked")
-    @Override
-    protected ChannelBuffer createCumulationDynamicBuffer(ChannelHandlerContext ctx) {
-        Map<String, Object> attachment = (Map<String, Object>) ctx.getAttachment();
-        int size = (Integer) attachment.get(NEEDED_DATA);
-        
-        if (inMemorySizeLimit > 0) {
-            return ChannelBuffers.dynamicBuffer(Math.min(size, inMemorySizeLimit), ctx.getChannel().getConfig().getBufferFactory());
-        } else {
-
-            if (size > 0) {
-                return ChannelBuffers.dynamicBuffer(size, ctx.getChannel().getConfig().getBufferFactory());
-            }
-            return super.createCumulationDynamicBuffer(ctx);
-        }
-    }
-
+//    @Override
+//    protected ChannelBuffer newCumulationBuffer(
+//            ChannelHandlerContext ctx, int minimumCapacity) {
+//
+//        Map<String, Object> attachment = (Map<String, Object>) ctx.getAttachment();
+//        int size = (Integer) attachment.get(NEEDED_DATA);
+//
+//        if(size > 0 && size > minimumCapacity) {
+//            minimumCapacity = size;
+//        }
+//
+//        ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
+//
+//        if (inMemorySizeLimit > 0) {
+//            return factory.getBuffer(Math.min(inMemorySizeLimit, Math.max(minimumCapacity, 256)));
+//        }
+//
+//        return ChannelBuffers.dynamicBuffer(minimumCapacity, ctx.getChannel().getConfig().getBufferFactory());
+//    }
 }
Index: protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
===================================================================
--- protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java	(Revision 5815)
+++ protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java	(Revision 5834)
@@ -55,8 +55,6 @@
  */
 public class IMAPServer extends AbstractConfigurableAsyncServer implements ImapConstants, IMAPServerMBean, NettyConstants {
 
-    private static final String softwaretype = "JAMES " + VERSION + " Server ";
-
     private ImapProcessor processor;
     private ImapEncoder encoder;
     private ImapDecoder decoder;
@@ -94,7 +92,7 @@
         
         super.doConfigure(configuration);
         
-        hello = softwaretype + " Server " + getHelloName() + " is ready.";
+        hello = configuration.getString("serverName", "JAMES") + " " + VERSION + " Server " + getHelloName() + " is ready.";
         compress = configuration.getBoolean("compress", false);
         maxLineLength = configuration.getInt("maxLineLength", DEFAULT_MAX_LINE_LENGTH);
         inMemorySizeLimit = configuration.getInt("inMemorySizeLimit", DEFAULT_IN_MEMORY_SIZE_LIMIT);
Index: protocols/protocols-imap4/pom.xml
===================================================================
--- protocols/protocols-imap4/pom.xml	(Revision 5815)
+++ protocols/protocols-imap4/pom.xml	(Revision 5834)
@@ -39,15 +39,10 @@
             <groupId>org.apache.james</groupId>
             <artifactId>james-server-protocols-library</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-filesystem-api</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>org.apache.james.protocols</groupId>
             <artifactId>protocols-imap</artifactId>
-            <version>${protocols.version}</version>
         </dependency>
 
         <dependency>
@@ -75,9 +70,38 @@
             <artifactId>geronimo-annotation_1.1_spec</artifactId>
         </dependency>
         <dependency>
-          <groupId>javax.inject</groupId>
-          <artifactId>javax.inject</artifactId>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-protocols-library</artifactId>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-dnsservice-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-mailet-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-filesystem-api</artifactId>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        
     </dependencies>
 
     <build>

Eigenschaftsänderungen: protocols/protocols-imap4
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: protocols/protocols-lmtp
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: protocols/protocols-pop3
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
===================================================================
--- protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java	(Revision 5815)
+++ protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java	(Revision 5834)
@@ -58,6 +58,9 @@
      * SMTPGreeting to use
      */
     private String smtpGreeting = null;
+    
+    private static final String DEFAULT_SOFTWARE_NAME = "JAMES SMTP Server";
+    private String softwareName = null;
 
     /**
      * This is a Network Matcher that should be configured to contain authorized
@@ -169,6 +172,8 @@
 
             // get the smtpGreeting
             smtpGreeting = configuration.getString("smtpGreeting", null);
+            
+            softwareName = configuration.getString("softwareName", DEFAULT_SOFTWARE_NAME);
 
             addressBracketsEnforcement = configuration.getBoolean("addressBracketsEnforcement", true);
 
@@ -274,7 +279,7 @@
 
         @Override
         public String getSoftwareName() {
-            return "JAMES SMTP Server ";
+            return softwareName;
         }
 
     }
Index: protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
===================================================================
--- protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java	(Revision 5815)
+++ protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java	(Revision 5834)
@@ -321,8 +321,7 @@
     public void testMaxLineLength() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < AbstractChannelPipelineFactory.MAX_LINE_LENGTH; i++) {
@@ -344,18 +343,13 @@
         smtpConfiguration.setConnectionLimit(2);
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
-        SMTPClient smtpProtocol2 = new SMTPClient();
-        smtpProtocol2.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
+        SMTPClient smtpProtocol2 = newSMTPClient();
 
-        SMTPClient smtpProtocol3 = new SMTPClient();
-
         try {
-            smtpProtocol3.connect("127.0.0.1", smtpListenerPort);
-            Thread.sleep(3000);
-            fail("Shold disconnect connection 3");
-        } catch (Exception e) {
+            newSMTPClient();
+            fail("Should disconnect connection 3");
+        } catch (IOException ex) {
         }
 
         smtpProtocol.quit();
@@ -363,9 +357,8 @@
         smtpProtocol2.quit();
         smtpProtocol2.disconnect();
 
-        smtpProtocol3.connect("127.0.0.1", smtpListenerPort);
-        Thread.sleep(3000);
-
+        SMTPClient smtpProtocol3 = newSMTPClient();
+        assertTrue(SMTPReply.isPositiveCompletion(smtpProtocol3.helo("test")));
     }
 
     @After
@@ -402,8 +395,7 @@
     public void testSimpleMailSendWithEHLO() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         // no message there, yet
         assertNull("no mail received by mail server", queue.getLastMail());
@@ -437,8 +429,7 @@
         smtpConfiguration.setStartTLS();
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         // no message there, yet
         assertNull("no mail received by mail server", queue.getLastMail());
@@ -464,7 +455,6 @@
 
     protected SMTPClient newSMTPClient() throws IOException {
         SMTPClient smtp = new SMTPClient();
-        smtp.connect("127.0.0.1", smtpListenerPort);
         if (log.isDebugEnabled()) {
             smtp.addProtocolCommandListener(new ProtocolCommandListener() {
 
@@ -479,34 +469,29 @@
                 }
             });
         }
+        smtp.connect("127.0.0.1", smtpListenerPort);
         return smtp;
     }
 
     @Test
-    public void testReceivedHeader() throws Exception {
+    public void testSetSmtpGreeting() throws Exception {
+        smtpConfiguration.setSmtpGreeting("myGreeting");
         init(smtpConfiguration);
 
         SMTPClient smtp = newSMTPClient();
+        String serverGreeting = smtp.getReplyString();
 
-        // no message there, yet
-        assertNull("no mail received by mail server", queue.getLastMail());
-
-        smtp.helo(InetAddress.getLocalHost().toString());
-        smtp.setSender("mail@localhost");
-        smtp.addRecipient("mail@localhost");
-        smtp.sendShortMessageData("Subject: test\r\n\r\n");
-
         smtp.quit();
         smtp.disconnect();
 
-        assertNotNull("spooled mail has Received header",
-                queue.getLastMail().getMessage().getHeader("Received"));
+        log.debug("server greeting: " + serverGreeting.trim());
+        assertFalse(serverGreeting.toLowerCase().contains("james"));
+        assertTrue(serverGreeting.contains("myGreeting"));
     }
-
-    // FIXME
-    @Ignore
+    
     @Test
-    public void testEmptyMessageReceivedHeader() throws Exception {
+    public void testSetSoftwareName() throws Exception {
+        smtpConfiguration.setSoftwareName("mySoftwareName");
         init(smtpConfiguration);
 
         SMTPClient smtp = newSMTPClient();
@@ -517,22 +502,30 @@
         smtp.helo(InetAddress.getLocalHost().toString());
         smtp.setSender("mail@localhost");
         smtp.addRecipient("mail@localhost");
-        smtp.sendShortMessageData("");
+        smtp.sendShortMessageData("Subject: test\r\n\r\nthe body");
 
         smtp.quit();
         smtp.disconnect();
 
         assertNotNull("spooled mail has Received header",
                 queue.getLastMail().getMessage().getHeader("Received"));
-        // TODO: test body size
+        assertTrue(queue.getLastMail().getMessage().getHeader("Received", "")
+                .contains("mySoftwareName"));
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        queue.getLastMail().getMessage().writeTo(baos);
+        String msgContent = baos.toString("US-ASCII");
+        log.debug("message content: >>>" + msgContent + "<<<");
+        
+        assertFalse(msgContent.toLowerCase().contains("james"));
+        assertTrue(msgContent.contains("mySoftwareName"));
     }
 
     @Test
     public void testSimpleMailSendWithHELO() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         // no message there, yet
         assertNull("no mail received by mail server", queue.getLastMail());
@@ -556,10 +549,8 @@
     public void testTwoSimultaneousMails() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
-        SMTPClient smtpProtocol2 = new SMTPClient();
-        smtpProtocol2.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
+        SMTPClient smtpProtocol2 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
         assertTrue("second connection taken", smtpProtocol2.isConnected());
@@ -597,8 +588,7 @@
     public void testTwoMailsInSequence() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -637,8 +627,7 @@
     }
 
     private void doTestHeloEhloResolv(String heloCommand) throws IOException {
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol.isConnected());
 
@@ -674,8 +663,7 @@
     public void testHeloResolvDefault() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         smtpProtocol1.helo("abgsfe3rsf.de");
         // helo should not be checked. so this should give a 250 code
@@ -697,8 +685,7 @@
         try {
             init(smtpConfiguration);
 
-            SMTPClient smtpProtocol1 = new SMTPClient();
-            smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+            SMTPClient smtpProtocol1 = newSMTPClient();
 
             assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -737,8 +724,7 @@
         smtpConfiguration.setAuthorizedAddresses("192.168.0.1/32");
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -762,8 +748,7 @@
     public void testSenderDomainResolvDefault() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -779,8 +764,7 @@
         smtpConfiguration.setSenderDomainResolv();
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -804,8 +788,7 @@
         smtpConfiguration.setCheckAuthNetworks(true);
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -831,8 +814,7 @@
         smtpConfiguration.setMaxRcpt(1);
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -870,8 +852,7 @@
     public void testMaxRcptDefault() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -900,8 +881,7 @@
     public void testEhloResolvDefault() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         smtpProtocol1.sendCommand("ehlo", "abgsfe3rsf.de");
         // ehlo should not be checked. so this should give a 250 code
@@ -934,8 +914,7 @@
         try {
             init(smtpConfiguration);
 
-            SMTPClient smtpProtocol1 = new SMTPClient();
-            smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+            SMTPClient smtpProtocol1 = newSMTPClient();
 
             assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -972,8 +951,7 @@
     public void testHeloEnforcement() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -996,8 +974,7 @@
         smtpConfiguration.setHeloEhloEnforcement(false);
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol1 = new SMTPClient();
-        smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol1 = newSMTPClient();
 
         assertTrue("first connection taken", smtpProtocol1.isConnected());
 
@@ -1017,8 +994,7 @@
         smtpConfiguration.setAuthorizingAnnounce();
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
@@ -1041,8 +1017,7 @@
         smtpConfiguration.setAuthorizingAnnounce();
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
         String[] capabilityRes = smtpProtocol.getReplyStrings();
@@ -1103,9 +1078,8 @@
         smtpConfiguration.setAuthorizingAnnounce();
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
-
+        SMTPClient smtpProtocol = newSMTPClient();
+        
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
         String userName = "test_user_smtp";
@@ -1127,8 +1101,7 @@
     public void testNoRecepientSpecified() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1149,8 +1122,7 @@
     public void testMultipleMailsAndRset() throws Exception {
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1171,8 +1143,7 @@
         smtpConfiguration.setAuthorizedAddresses("128.0.0.1/8");
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1187,8 +1158,7 @@
         smtpConfiguration.setMaxMessageSize(1); // set message limit to 1kb
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1203,8 +1173,7 @@
         smtpConfiguration.setMaxMessageSize(1); // set message limit to 1kb
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1239,8 +1208,7 @@
         smtpConfiguration.setMaxMessageSize(1); // set message limit to 1kb
         init(smtpConfiguration);
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
@@ -1278,8 +1246,7 @@
 
         dnsServer.setLocalhostByName(InetAddress.getByName("127.0.0.1"));
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
         String[] capabilityRes = smtpProtocol.getReplyStrings();
@@ -1323,8 +1290,7 @@
 
         dnsServer.setLocalhostByName(InetAddress.getByName("127.0.0.1"));
 
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
@@ -1347,8 +1313,7 @@
     public void testAddressBracketsEnforcementDisabled() throws Exception {
         smtpConfiguration.setAddressBracketsEnforcement(false);
         init(smtpConfiguration);
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
@@ -1376,8 +1341,7 @@
     @Test
     public void testAddressBracketsEnforcementEnabled() throws Exception {
         init(smtpConfiguration);
-        SMTPClient smtpProtocol = new SMTPClient();
-        smtpProtocol.connect("127.0.0.1", smtpListenerPort);
+        SMTPClient smtpProtocol = newSMTPClient();
 
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
Index: protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPTestConfiguration.java
===================================================================
--- protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPTestConfiguration.java	(Revision 5815)
+++ protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPTestConfiguration.java	(Revision 5834)
@@ -44,6 +44,8 @@
     private boolean m_useRBL = false;
     private boolean m_addressBracketsEnforcement = true;
     private boolean m_startTLS = false;
+    private String m_smtpGreeting = null;
+    private String m_softwareName = null;
 
     public SMTPTestConfiguration(int smtpListenerPort) {
         m_smtpListenerPort = smtpListenerPort;
@@ -131,7 +133,15 @@
     public void setStartTLS() {
         m_startTLS = true;
     }
+    
+    public void setSmtpGreeting(String smtpGreeting) {
+        m_smtpGreeting = smtpGreeting;
+    }
 
+    public void setSoftwareName(String softwareName) {
+        m_softwareName = softwareName;
+    }
+
     public void init() {
 
         addProperty("[@enabled]", true);
@@ -149,6 +159,12 @@
         addProperty("authRequired", m_authorizingMode);
         addProperty("heloEhloEnforcement", m_heloEhloEnforcement);
         addProperty("addressBracketsEnforcement", m_addressBracketsEnforcement);
+        if (m_smtpGreeting != null) {
+            addProperty("smtpGreeting", m_smtpGreeting);
+        }
+        if (m_softwareName != null) {
+            addProperty("softwareName", m_softwareName);
+        }
 
         addProperty("tls.[@startTLS]", m_startTLS);
         addProperty("tls.keystore", "file://conf/test_keystore");
Index: protocols/protocols-smtp/src/test/resources/log4j.xml
===================================================================
--- protocols/protocols-smtp/src/test/resources/log4j.xml	(Revision 5815)
+++ protocols/protocols-smtp/src/test/resources/log4j.xml	(Revision 5834)
@@ -16,7 +16,6 @@
         <level value="info"></level>
         <appender-ref ref="stdout" />
     </logger>
-
     
     <root>
         <priority value="info" />

Eigenschaftsänderungen: protocols/protocols-smtp
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: queue/queue-activemq
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: queue/queue-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: queue/queue-jms
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: queue/queue-file
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: pom.xml
===================================================================
--- pom.xml	(Revision 5815)
+++ pom.xml	(Revision 5834)
@@ -54,13 +54,12 @@
     <modules>
         <module>app</module>
 
-        <module>karaf/distribution</module>
-        <module>karaf/features</module>
-        <module>karaf/integration</module>
+        <module>karaf</module>
 
         <module>container/util</module>
         <module>container/cli</module>
         <module>container/spring</module>
+        <module>container/spring-integration-tests</module>
         <module>container/core</module>
         <module>container/lifecycle-api</module>
         <module>container/mailbox-adapter</module>
@@ -77,6 +76,7 @@
         <module>data/data-api</module>
         <module>data/data-library</module>
         <module>data/data-jpa</module>
+        <module>data/data-openjpa</module>
         <module>data/data-jcr</module>
         <module>data/data-jdbc</module>
         <module>data/data-file</module>
@@ -114,9 +114,9 @@
 
         <activemq.version>5.7.0</activemq.version>
         <camel.version>2.10.3</camel.version>
-        <derby.version>10.9.1.0</derby.version>
+        <derby.version>10.10.1.1</derby.version>
         <hadoop.version>1.1.1</hadoop.version>
-        <hbase.version>0.92.0</hbase.version>
+        <hbase.version>0.92.2</hbase.version>
         <javax.inject.version>1</javax.inject.version>
         <javax.mail.groupId>org.apache.geronimo.javamail</javax.mail.groupId>
         <javax.mail.artifactId>geronimo-javamail_1.4_mail</javax.mail.artifactId>
@@ -126,8 +126,8 @@
         <jsieve.version>0.6-SNAPSHOT</jsieve.version>
         <mailbox.version>0.6-SNAPSHOT</mailbox.version>
         <mailet.version>2.5.1-SNAPSHOT</mailet.version>
-        <protocols.version>1.6.3</protocols.version>
-        <spring.version>3.1.2.RELEASE</spring.version>
+        <protocols.version>1.6.4-SNAPSHOT</protocols.version>
+        <spring.version>4.0.3.RELEASE</spring.version>
         <geronimo-jms-spec.version>1.1.1</geronimo-jms-spec.version>
         <h2.version>1.3.170</h2.version>
         <apache-jspf-resolver.version>1.0.0</apache-jspf-resolver.version>
@@ -136,7 +136,7 @@
         <geronimo-activation-spec.version>1.1</geronimo-activation-spec.version>
         <geronimo-javamail.version>1.8.3</geronimo-javamail.version>
         <slf4j.version>1.7.2</slf4j.version>
-        <servlet-api.version>2.4</servlet-api.version>
+        <servlet-api.version>2.5</servlet-api.version>
         <!-- commons -->
         <commons-daemon.version>1.0.10</commons-daemon.version>
         <commons-collections.version>3.2.1</commons-collections.version>
@@ -146,10 +146,10 @@
         <commons-pool.version>1.6</commons-pool.version>
         <commons-configuration.version>1.9</commons-configuration.version>
         <commons-dbcp.version>1.4</commons-dbcp.version>
-        <commons-net.version>3.2</commons-net.version>
+        <commons-net.version>3.3</commons-net.version>
         <commons-beanutils-core.version>1.8.3</commons-beanutils-core.version>
         <commons-io.version>2.4</commons-io.version>
-        <commons-logging.version>1.1.1</commons-logging.version>
+        <commons-logging.version>1.1.3</commons-logging.version>
 
         <dnsjava.version>2.1.1</dnsjava.version>
         <junit.version>4.11</junit.version>
@@ -161,20 +161,22 @@
         <jcr.version>2.0</jcr.version>
         <tika-parsers.version>1.2</tika-parsers.version>
         <xbean-spring.version>3.12</xbean-spring.version>
-        <netty.version>3.3.1.Final</netty.version>
+        <netty.version>3.9.1.Final</netty.version>
         <geronimo-annotation-spec.version>1.0.1</geronimo-annotation-spec.version>
         <spring-osgi-extender.version>1.2.1</spring-osgi-extender.version>
         <org.osgi.core.version>5.0.0</org.osgi.core.version>
-        <guava.version>13.0</guava.version>
+        <guava.version>13.0.1</guava.version>
+        <jackson.version>1.9.13</jackson.version>
 
         <!-- karaf dependencies -->
         <exam.version>2.6.0</exam.version>
+        <ops4j-base.version>1.4.0</ops4j-base.version>
         <url.version>1.4.0</url.version>
         <felix.version>4.0.3</felix.version>
         <pax-swissbox-tinybundles.version>1.3.1</pax-swissbox-tinybundles.version>
         <karaf.version>2.3.0</karaf.version>
         <karaf.tooling.exam.container.version>2.3.0</karaf.tooling.exam.container.version>
-        <pax-logging-api.version>1.6.4</pax-logging-api.version>
+        <pax-logging-api.version>1.7.0</pax-logging-api.version>
         <mockito-core.version>1.9.0</mockito-core.version>
     </properties>
 
@@ -445,6 +447,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>james-server-data-openjpa</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>james-server-data-hbase</artifactId>
                 <version>${project.version}</version>
             </dependency>
@@ -582,6 +589,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-mailbox-openjpa</artifactId>
+                <version>${mailbox.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>apache-james-mailbox-tool</artifactId>
                 <version>${mailbox.version}</version>
             </dependency>
@@ -848,6 +860,12 @@
                 <version>${derby.version}</version>
                 <scope>runtime</scope>
             </dependency>
+            <dependency>
+                <groupId>org.apache.derby</groupId>
+                <artifactId>derbytools</artifactId>
+                <version>${derby.version}</version>
+                <scope>runtime</scope>
+            </dependency>
 
             <!-- Used by Mime4J -->
             <dependency>
@@ -1201,6 +1219,205 @@
                 <version>${hadoop.version}</version>
             </dependency>
 
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.plexus</groupId>
+                <artifactId>plexus-classworlds</artifactId>
+                <version>2.4</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.plexus</groupId>
+                <artifactId>plexus-utils</artifactId>
+                <version>3.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>commons-logging</groupId>
+                <artifactId>commons-logging</artifactId>
+                <version>${commons-logging.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.hamcrest</groupId>
+                <artifactId>hamcrest-core</artifactId>
+                <version>1.3</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.jackson</groupId>
+                <artifactId>jackson-mapper-asl</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.jackson</groupId>
+                <artifactId>jackson-core-asl</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.jboss.netty</groupId>
+                <artifactId>netty</artifactId>
+                <version>3.2.10.Final</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.ftpserver</groupId>
+                <artifactId>ftpserver-core</artifactId>
+                <version>1.0.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.ftpserver</groupId>
+                <artifactId>ftplet-api</artifactId>
+                <version>1.0.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>commons-httpclient</groupId>
+                <artifactId>commons-httpclient</artifactId>
+                <version>3.1</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.mina</groupId>
+                <artifactId>mina-core</artifactId>
+                <version>2.0.7</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.aries.blueprint</groupId>
+                <artifactId>org.apache.aries.blueprint.core</artifactId>
+                <version>1.0.1</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>4.3.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>biz.aQute</groupId>
+                <artifactId>bndlib</artifactId>
+                <version>1.43.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.maven.wagon</groupId>
+                <artifactId>wagon-provider-api</artifactId>
+                <version>1.0</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpclient</artifactId>
+                <version>4.3.3</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpmime</artifactId>
+                <version>4.3.3</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpcore</artifactId>
+                <version>4.3.2</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.jackson</groupId>
+                <artifactId>jackson-xc</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.codehaus.jackson</groupId>
+                <artifactId>jackson-jaxrs</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>javax.xml.bind</groupId>
+                <artifactId>jaxb-api</artifactId>
+                <version>2.2.11</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-util-property</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-net</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-monitors</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-io</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-store</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.base</groupId>
+                <artifactId>ops4j-base-lang</artifactId>
+                <version>${ops4j-base.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-container-remote</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-extender-service</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-spi</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-inject</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-container-rbc-client</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+            <!-- dependency convergence fix: -->
+            <dependency>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>pax-exam-container-rbc</artifactId>
+                <version>${exam.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 
@@ -1214,15 +1431,13 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <!-- avoid race with bundle plugin manifest (known bug): -->
+                    <useDefaultManifestFile>true</useDefaultManifestFile>
+                </configuration>
             </plugin>
             <plugin>
-                <artifactId>versions-maven-plugin</artifactId>
-                <version>2.0</version>
-            </plugin>
-            <plugin>
                 <artifactId>maven-release-plugin</artifactId>
                 <configuration>
                     <!-- During release:perform, enable the "release" profile -->
@@ -1230,6 +1445,9 @@
                     <goals>deploy assembly:single</goals>
                 </configuration>
             </plugin>
+            <plugin>
+                <artifactId>maven-enforcer-plugin</artifactId>
+            </plugin>
         </plugins>
         <pluginManagement>
           <plugins>
@@ -1256,6 +1474,47 @@
                 </lifecycleMappingMetadata>
               </configuration>
             </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.8</version>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.3</version>
+            </plugin>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.4.0</version>
+            </plugin>
+            <plugin>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <version>1.3.1</version>
+                <executions>
+                    <execution>
+                        <id>enforce-sane-versions</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <rules>
+                        <requirePluginVersions />
+                        <dependencyConvergence />
+                        <requireUpperBoundDeps />
+                        <requireReleaseDeps>
+                            <message>No Snapshots Allowed!</message>
+                            <onlyWhenRelease>true</onlyWhenRelease>
+                        </requireReleaseDeps>
+                    </rules>
+                </configuration>
+            </plugin>
           </plugins>
         </pluginManagement>
     </build>

Eigenschaftsänderungen: data/data-api
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: data/data-jpa/src/test/resources/log4j.properties
===================================================================
--- data/data-jpa/src/test/resources/log4j.properties	(Revision 5815)
+++ data/data-jpa/src/test/resources/log4j.properties	(Revision 5834)
@@ -1,6 +0,0 @@
-log4j.rootLogger=WARN, A1
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-
-# Print the date in ISO 8601 format
-log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
Index: data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
===================================================================
--- data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java	(Revision 5815)
+++ data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java	(Revision 5834)
@@ -1,87 +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.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.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 {
-
-    private HashMap<String, String> properties;
-    private OpenJPAEntityManagerFactory factory;
-
-    @Before
-    @Override
-    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
-    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();
-        }
-    }
-
-    @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;
-    }
-}
Index: data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
===================================================================
--- data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java	(Revision 5815)
+++ data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java	(Revision 5834)
@@ -1,62 +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.domainlist.jpa;
-
-import java.util.HashMap;
-
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.jpa.model.JPADomain;
-import org.apache.james.domainlist.lib.AbstractDomainListTest;
-import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test the JPA implementation of the DomainList.
- */
-public class JPADomainListTest extends AbstractDomainListTest {
-
-    @Override
-    protected DomainList createDomainList() {
-        // Use a memory database.
-        HashMap<String, String> properties = new HashMap<String, String>();
-        properties.put("openjpa.ConnectionDriverName", org.apache.derby.jdbc.EmbeddedDriver.class.getName());
-        properties.put("openjpa.ConnectionURL", "jdbc:derby:memory:JPADomainListTestDB;create=true");
-        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=" + JPADomain.class.getName() + ")");
-        /*
-      The OpenJPA Entity Manager used for the tests.
-     */
-        OpenJPAEntityManagerFactory factory = OpenJPAPersistence.getEntityManagerFactory(properties);
-
-        // Initialize the JPADomainList (no autodetect,...).
-        JPADomainList jpaDomainList = new JPADomainList();
-        jpaDomainList.setLog(LoggerFactory.getLogger("JPADomainListMockLog"));
-        jpaDomainList.setDNSService(getDNSServer("localhost"));
-        jpaDomainList.setAutoDetect(false);
-        jpaDomainList.setAutoDetectIP(false);
-        jpaDomainList.setEntityManagerFactory(factory);
-        
-        return jpaDomainList;
-
-    }
-
-}
Index: data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
===================================================================
--- data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java	(Revision 5815)
+++ data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java	(Revision 5834)
@@ -1,114 +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.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.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;
-
-/**
- * Test the JPA Virtual User Table implementation.
- */
-public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
-
-    /**
-     * The OpenJPA Entity Manager used for the tests.
-     */
-    private OpenJPAEntityManagerFactory factory;
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-
-        // Use a memory database.
-        /*
-      The properties for the OpenJPA Entity Manager.
-     */
-        HashMap<String, String> 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();
-    }
-
-    @Override
-    protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
-        JPARecipientRewriteTable localVirtualUserTable = new JPARecipientRewriteTable();
-        localVirtualUserTable.setLog(LoggerFactory.getLogger("MockLog"));
-        localVirtualUserTable.setEntityManagerFactory(factory);
-        DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
-        localVirtualUserTable.configure(defaultConfiguration);
-        return localVirtualUserTable;
-    }
-
-    @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;
-        }
-    }
-
-    @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;
-        }
-    }
-}
Index: data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/model/JPADomain.java
===================================================================
--- data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/model/JPADomain.java	(Revision 5815)
+++ data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/model/JPADomain.java	(Revision 5834)
@@ -24,6 +24,7 @@
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.Table;
+import javax.persistence.Version;
 
 /**
  * Domain class for the James Domain to be used for JPA persistence.
@@ -45,6 +46,9 @@
     @Column(name = "DOMAIN_NAME", nullable = false, length = 100)
     private String name;
 
+    @Version
+    private int version;
+    
     /**
      * Default no-args constructor to avoid warning during JPA class enhancement.
      * Do not us this.
Index: data/data-jpa/src/main/java/org/apache/james/rrt/jpa/model/JPARecipientRewrite.java
===================================================================
--- data/data-jpa/src/main/java/org/apache/james/rrt/jpa/model/JPARecipientRewrite.java	(Revision 5815)
+++ data/data-jpa/src/main/java/org/apache/james/rrt/jpa/model/JPARecipientRewrite.java	(Revision 5834)
@@ -29,6 +29,7 @@
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.Table;
+import javax.persistence.Version;
 
 /**
  * RecipientRewriteTable class for the James Virtual User Table to be used for JPA
@@ -96,6 +97,9 @@
     @Column(name = "TARGET_ADDRESS", nullable = false, length = 100)
     private String targetAddress = "";
     
+    @Version
+    private int version;
+    
     /**
      * Default no-args constructor to avoid warning during JPA class enhancement.
      * Do not us this.
Index: data/data-jpa/src/main/java/org/apache/james/user/jpa/model/PBKDF2.java
===================================================================
--- data/data-jpa/src/main/java/org/apache/james/user/jpa/model/PBKDF2.java	(Revision 0)
+++ data/data-jpa/src/main/java/org/apache/james/user/jpa/model/PBKDF2.java	(Revision 5834)
@@ -0,0 +1,96 @@
+/****************************************************************
+ * 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.user.jpa.model;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.InvalidKeySpecException;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import org.apache.commons.codec.binary.Base64;
+
+public class PBKDF2 {
+    // The higher the number of iterations the more
+    // expensive computing the hash is for us
+    // and also for a brute force attack.
+    private static final int iterations = 10*1024;
+    private static final int saltLen = 32;
+    private static final int desiredKeyLen = 256;
+
+    /** Computes a salted PBKDF2 hash of given plaintext password suitable for storing in a database.
+     * Empty passwords are not supported.
+     * @param password the password to hash
+     * @return the password hash prefixed by the salt
+     * @throws RuntimeException
+     */
+    public static String getSaltedHash(String password) {
+        byte[] salt;
+        try {
+            salt = SecureRandom.getInstance("SHA1PRNG").generateSeed(saltLen);
+            // store the salt with the password
+            return Base64.encodeBase64String(salt) + "$" + hash(password, salt);
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException(e);
+        } catch (InvalidKeySpecException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Checks whether given plaintext password corresponds to a stored salted hash of the password.
+     * @param password
+     * @param stored the stored hash of the password prefixed by the salt
+     * @return true if and only if the password matches the stored hash
+     */
+    public static boolean check(String password, String stored) {
+        String[] saltAndPass = stored.split("\\$");
+        if (saltAndPass.length != 2) {
+            return false;
+        }
+        String hashOfInput;
+        try {
+            hashOfInput = hash(password, Base64.decodeBase64(saltAndPass[0]));
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException(e);
+        } catch (InvalidKeySpecException e) {
+            throw new RuntimeException(e);
+        }
+        return hashOfInput.equals(saltAndPass[1]);
+    }
+
+    /**
+     * using PBKDF2 from Sun, an alternative is https://github.com/wg/scrypt
+     * cf. http://www.unlimitednovelty.com/2012/03/dont-use-bcrypt.html
+     */
+    private static String hash(String password, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        if (password == null || password.length() == 0) {
+            throw new IllegalArgumentException("Empty passwords are not supported.");
+        }
+        SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
+        SecretKey key = f.generateSecret(new PBEKeySpec(
+            password.toCharArray(), salt, iterations, desiredKeyLen)
+        );
+        return Base64.encodeBase64String(key.getEncoded());
+    }
+
+    private PBKDF2() {
+    }
+}
\ No newline at end of file
Index: data/data-jpa/src/main/java/org/apache/james/user/jpa/model/JPAUser.java
===================================================================
--- data/data-jpa/src/main/java/org/apache/james/user/jpa/model/JPAUser.java	(Revision 5815)
+++ data/data-jpa/src/main/java/org/apache/james/user/jpa/model/JPAUser.java	(Revision 5834)
@@ -60,6 +60,8 @@
             newPass = DigestUtils.sha256Hex(password);
         } else if (alg.equals("SHA-512")) {
             newPass = DigestUtils.sha512Hex(password);
+        } else if (alg.equals("PBKDF2")) {
+            newPass = PBKDF2.getSaltedHash(password);
         } else {
             newPass = DigestUtils.sha1Hex(password);
         }
@@ -77,7 +79,7 @@
 
     /** Hashed password */
     @Basic
-    @Column(name = "PASSWORD", nullable = false, length = 128)
+    @Column(name = "PASSWORD", nullable = false, length = 255)
     private String password;
 
     @Basic
@@ -97,6 +99,7 @@
     /**
      * @see org.apache.james.user.api.model.User#getUserName()
      */
+    @Override
     public String getUserName() {
         return name;
     }
@@ -104,6 +107,7 @@
     /**
      * @see org.apache.james.user.api.model.User#setPassword(java.lang.String)
      */
+    @Override
     public boolean setPassword(String newPass) {
         final boolean result;
         if (newPass == null) {
@@ -118,10 +122,13 @@
     /**
      * @see org.apache.james.user.api.model.User#verifyPassword(java.lang.String)
      */
+    @Override
     public boolean verifyPassword(String pass) {
         final boolean result;
         if (pass == null) {
             result = password == null;
+        } else if (alg.equals("PBKDF2")) {
+            result = password != null && PBKDF2.check(pass, password);
         } else result = password != null && password.equals(hashPassword(name, pass, alg));
         return result;
     }
Index: data/data-jpa/src/main/resources/META-INF/persistence.xml
===================================================================
--- data/data-jpa/src/main/resources/META-INF/persistence.xml	(Revision 5815)
+++ data/data-jpa/src/main/resources/META-INF/persistence.xml	(Revision 5834)
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.    
--->
-
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
-    version="2.0">
-
-    <persistence-unit name="James" transaction-type="JTA">
-       <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-        <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/james)</jta-data-source>
-        <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
-        <class>org.apache.james.user.jpa.model.JPAUser</class>
-        <class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
-        <exclude-unlisted-classes>true</exclude-unlisted-classes>
-        <properties>
-            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
-            <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
-            <property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
-            <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
-        </properties>
-
-    </persistence-unit>
-
-</persistence>
Index: data/data-jpa/pom.xml
===================================================================
--- data/data-jpa/pom.xml	(Revision 5815)
+++ data/data-jpa/pom.xml	(Revision 5834)
@@ -67,97 +67,26 @@
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
         </dependency>
+
+        <!-- JPA 2.1 API: -->
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>2.1.0</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-annotation_1.1_spec</artifactId>
-        </dependency>
 
-        <!-- Test dependencies -->
+        <!-- generate static metamodel classes for JPA Criteria API: -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-jpamodelgen</artifactId>
+            <version>4.3.5.Final</version>
+            <scope>provided</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>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
         <plugins>
-
             <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>

Eigenschaftsänderungen: data/data-jpa
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: data/data-openjpa/src/main/resources/META-INF/persistence.xml
===================================================================
--- data/data-openjpa/src/main/resources/META-INF/persistence.xml	(Revision 0)
+++ data/data-openjpa/src/main/resources/META-INF/persistence.xml	(Revision 5834)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.    
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+    version="2.0">
+
+    <persistence-unit name="James" transaction-type="JTA">
+       <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/james)</jta-data-source>
+        <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
+        <class>org.apache.james.user.jpa.model.JPAUser</class>
+        <class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
+        <exclude-unlisted-classes>true</exclude-unlisted-classes>
+        <properties>
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+            <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
+            <property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
+            <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
+        </properties>
+
+    </persistence-unit>
+
+</persistence>
Index: data/data-openjpa/src/reporting-site/site.xml
===================================================================
--- data/data-openjpa/src/reporting-site/site.xml	(Revision 0)
+++ data/data-openjpa/src/reporting-site/site.xml	(Revision 5834)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.    
+-->
+<project name="${project.name}">
+
+    <body>
+
+        <menu ref="parent" />
+        <menu ref="reports" />
+
+    </body>
+
+</project>
Index: data/data-openjpa/src/test/resources/log4j.properties
===================================================================
--- data/data-openjpa/src/test/resources/log4j.properties	(Revision 0)
+++ data/data-openjpa/src/test/resources/log4j.properties	(Revision 5834)
@@ -0,0 +1,6 @@
+log4j.rootLogger=WARN, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+
+# Print the date in ISO 8601 format
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
Index: data/data-openjpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
===================================================================
--- data/data-openjpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java	(Revision 0)
+++ data/data-openjpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java	(Revision 5834)
@@ -0,0 +1,114 @@
+/****************************************************************
+ * 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.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.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;
+
+/**
+ * Test the JPA Virtual User Table implementation.
+ */
+public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
+
+    /**
+     * The OpenJPA Entity Manager used for the tests.
+     */
+    private OpenJPAEntityManagerFactory factory;
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+
+        // Use a memory database.
+        /*
+      The properties for the OpenJPA Entity Manager.
+     */
+        HashMap<String, String> 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();
+    }
+
+    @Override
+    protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
+        JPARecipientRewriteTable localVirtualUserTable = new JPARecipientRewriteTable();
+        localVirtualUserTable.setLog(LoggerFactory.getLogger("MockLog"));
+        localVirtualUserTable.setEntityManagerFactory(factory);
+        DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
+        localVirtualUserTable.configure(defaultConfiguration);
+        return localVirtualUserTable;
+    }
+
+    @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;
+        }
+    }
+
+    @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;
+        }
+    }
+}
Index: data/data-openjpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
===================================================================
--- data/data-openjpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java	(Revision 0)
+++ data/data-openjpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java	(Revision 5834)
@@ -0,0 +1,87 @@
+/****************************************************************
+ * 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.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.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 {
+
+    private HashMap<String, String> properties;
+    private OpenJPAEntityManagerFactory factory;
+
+    @Before
+    @Override
+    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
+    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();
+        }
+    }
+
+    @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;
+    }
+}
Index: data/data-openjpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
===================================================================
--- data/data-openjpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java	(Revision 0)
+++ data/data-openjpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java	(Revision 5834)
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.domainlist.jpa;
+
+import java.util.HashMap;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.jpa.model.JPADomain;
+import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test the JPA implementation of the DomainList.
+ */
+public class JPADomainListTest extends AbstractDomainListTest {
+
+    @Override
+    protected DomainList createDomainList() {
+        // Use a memory database.
+        HashMap<String, String> properties = new HashMap<String, String>();
+        properties.put("openjpa.ConnectionDriverName", org.apache.derby.jdbc.EmbeddedDriver.class.getName());
+        properties.put("openjpa.ConnectionURL", "jdbc:derby:memory:JPADomainListTestDB;create=true");
+        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=" + JPADomain.class.getName() + ")");
+        /*
+      The OpenJPA Entity Manager used for the tests.
+     */
+        OpenJPAEntityManagerFactory factory = OpenJPAPersistence.getEntityManagerFactory(properties);
+
+        // Initialize the JPADomainList (no autodetect,...).
+        JPADomainList jpaDomainList = new JPADomainList();
+        jpaDomainList.setLog(LoggerFactory.getLogger("JPADomainListMockLog"));
+        jpaDomainList.setDNSService(getDNSServer("localhost"));
+        jpaDomainList.setAutoDetect(false);
+        jpaDomainList.setAutoDetectIP(false);
+        jpaDomainList.setEntityManagerFactory(factory);
+        
+        return jpaDomainList;
+
+    }
+
+}
Index: data/data-openjpa/pom.xml
===================================================================
--- data/data-openjpa/pom.xml	(Revision 0)
+++ data/data-openjpa/pom.xml	(Revision 5834)
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>james-server</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.0.0-beta5-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.james</groupId>
+    <artifactId>james-server-data-openjpa</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache James :: Server :: Data :: OpenJPA Persistence</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-data-jpa</artifactId>
+            <scope>provided</scope>
+        </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>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- include jpa-implementation-shared entity classes for openjpa enhancement: -->
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.james</groupId>
+                                    <artifactId>james-server-data-jpa</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>jar</type>
+                                </artifactItem>
+                            </artifactItems>
+                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
+                        </configuration>
+                    </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>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Eigenschaftsänderungen: data/data-openjpa
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: data/data-jcr
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: data/data-file
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: data/data-ldap
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: data/data-hbase
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: data/data-jdbc
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


Index: data/data-library/pom.xml
===================================================================
--- data/data-library/pom.xml	(Revision 5815)
+++ data/data-library/pom.xml	(Revision 5834)
@@ -94,11 +94,6 @@
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>

Eigenschaftsänderungen: data/data-library
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target



Eigenschaftsänderungen: .
___________________________________________________________________
Hinzugefügt: svn:ignore
   + target


