You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ie...@apache.org on 2012/03/12 02:34:17 UTC

svn commit: r1299516 [1/4] - in /james/server/trunk/protocols-smtp: ./ src/test/java/org/apache/james/smtpserver/ src/test/java/org/apache/james/smtpserver/mock/ src/test/java/org/apache/james/smtpserver/mock/mailet/ src/test/java/org/apache/james/smtp...

Author: ieugen
Date: Mon Mar 12 01:34:16 2012
New Revision: 1299516

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

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

Modified:
    james/server/trunk/protocols-smtp/pom.xml
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Base64.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPTestConfiguration.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/SpamAssassinHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/URIRBLHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/MockMimeMessage.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailetConfig.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMatcherConfig.java
    james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/util/MockSpamd.java

Modified: james/server/trunk/protocols-smtp/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/protocols-smtp/pom.xml?rev=1299516&r1=1299515&r2=1299516&view=diff
==============================================================================
--- james/server/trunk/protocols-smtp/pom.xml (original)
+++ james/server/trunk/protocols-smtp/pom.xml Mon Mar 12 01:34:16 2012
@@ -21,10 +21,10 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <artifactId>james-server</artifactId>
-        <groupId>org.apache.james</groupId>
-        <version>3.0-beta5-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
+	<artifactId>james-server</artifactId>
+	<groupId>org.apache.james</groupId>
+	<version>3.0-beta5-SNAPSHOT</version>
+	<relativePath>../pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.james</groupId>
@@ -34,206 +34,206 @@
 
     <properties>
         <!-- OSGI stuff -->
-        <james.osgi.export>
-            org.apache.james.smtpserver.*
-        </james.osgi.export>
-        <james.osgi.import>
-            org.apache.james.jspf.*;resolution:=optional,*
-        </james.osgi.import>
+	<james.osgi.export>
+	    org.apache.james.smtpserver.*
+	</james.osgi.export>
+	<james.osgi.import>
+	    org.apache.james.jspf.*;resolution:=optional,*
+	</james.osgi.import>
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-dnsservice-library</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-queue-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-filesystem-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-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-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-protocols-library</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.protocols</groupId>
-            <artifactId>protocols-api</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.james.protocols</groupId>
-            <artifactId>protocols-smtp</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.protocols</groupId>
-            <artifactId>protocols-netty</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.jspf</groupId>
-            <artifactId>apache-jspf-resolver</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-configuration</groupId>
-            <artifactId>commons-configuration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${javax.mail.groupId}</groupId>
-            <artifactId>${javax.mail.artifactId}</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${javax.activation.groupId}</groupId>
-            <artifactId>${javax.activation.artifactId}</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-annotation_1.1_spec</artifactId>
-        </dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-util</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-dnsservice-library</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-queue-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-filesystem-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-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-core</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-protocols-library</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>apache-mailet</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james.protocols</groupId>
+	    <artifactId>protocols-api</artifactId>
+	</dependency>
+
+	<dependency>
+	    <groupId>org.apache.james.protocols</groupId>
+	    <artifactId>protocols-smtp</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james.protocols</groupId>
+	    <artifactId>protocols-netty</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james.jspf</groupId>
+	    <artifactId>apache-jspf-resolver</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.slf4j</groupId>
+	    <artifactId>slf4j-api</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>commons-configuration</groupId>
+	    <artifactId>commons-configuration</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>${javax.mail.groupId}</groupId>
+	    <artifactId>${javax.mail.artifactId}</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>${javax.activation.groupId}</groupId>
+	    <artifactId>${javax.activation.artifactId}</artifactId>
+	    <scope>provided</scope>
+	</dependency>
+	<dependency>
+	    <groupId>io.netty</groupId>
+	    <artifactId>netty</artifactId>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.geronimo.specs</groupId>
+	    <artifactId>geronimo-annotation_1.1_spec</artifactId>
+	</dependency>
 
         <!-- Test dependencies -->
-        <dependency>
-            <artifactId>dnsjava</artifactId>
-            <groupId>dnsjava</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-queue-api</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-library</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.james</groupId>
-            <artifactId>james-server-dnsservice-api</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.protocols</groupId>
-            <artifactId>protocols-smtp</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-net</groupId>
-            <artifactId>commons-net</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-data-api</artifactId>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-filesystem-api</artifactId>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.protocols</groupId>
-            <artifactId>protocols-api</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>james-server-protocols-library</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-nop</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <scope>test</scope>
-        </dependency>
+	<dependency>
+	    <artifactId>dnsjava</artifactId>
+	    <groupId>dnsjava</groupId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-queue-api</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-data-library</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.james</groupId>
+	    <artifactId>james-server-dnsservice-api</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james.protocols</groupId>
+	    <artifactId>protocols-smtp</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>commons-net</groupId>
+	    <artifactId>commons-net</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>apache-mailet-base</artifactId>
+	    <classifier>tests</classifier>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>junit</groupId>
+	    <artifactId>junit</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-data-api</artifactId>
+	    <scope>test</scope>
+	    <type>test-jar</type>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-filesystem-api</artifactId>
+	    <scope>test</scope>
+	    <type>test-jar</type>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james.protocols</groupId>
+	    <artifactId>protocols-api</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.apache.james</groupId>
+	    <artifactId>james-server-protocols-library</artifactId>
+	    <type>test-jar</type>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>org.slf4j</groupId>
+	    <artifactId>slf4j-nop</artifactId>
+	    <scope>test</scope>
+	</dependency>
+	<dependency>
+	    <groupId>commons-codec</groupId>
+	    <artifactId>commons-codec</artifactId>
+	    <scope>test</scope>
+	</dependency>
     </dependencies>
 
     <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
+	<plugins>
+	    <plugin>
+		<groupId>org.apache.maven.plugins</groupId>
+		<artifactId>maven-jar-plugin</artifactId>
                 <!--
                     Inherit configuration from parent pom.
                 -->
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>jar</goal>
+		<executions>
+		    <execution>
+			<goals>
+			    <goal>jar</goal>
                             <!--
                                 Allow tests to be used by other modules.
                                 Parent pom build failure prevents inheritance.
                             -->
-                            <goal>test-jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
+			    <goal>test-jar</goal>
+			</goals>
+		    </execution>
+		</executions>
+	    </plugin>
+	</plugins>
     </build>
 </project>

Modified: james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Base64.java
URL: http://svn.apache.org/viewvc/james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Base64.java?rev=1299516&r1=1299515&r2=1299516&view=diff
==============================================================================
--- james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Base64.java (original)
+++ james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/Base64.java Mon Mar 12 01:34:16 2012
@@ -16,16 +16,11 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.smtpserver;
 
+import java.io.*;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeUtility;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
 
 /**
  * Performs simple Base64 encoding and decode suitable for authentication. Note
@@ -44,7 +39,8 @@ public class Base64 {
      *             the String
      */
     public static BufferedReader decode(String b64string) throws MessagingException {
-        return new BufferedReader(new InputStreamReader(MimeUtility.decode(new ByteArrayInputStream(b64string.getBytes()), "base64")));
+	return new BufferedReader(new InputStreamReader(MimeUtility.decode(
+		new ByteArrayInputStream(b64string.getBytes()), "base64")));
     }
 
     /**
@@ -60,14 +56,14 @@ public class Base64 {
      *             get thrown when I/O error was detected
      */
     public static String decodeAsString(String b64string) throws IOException, MessagingException {
-        if (b64string == null) {
-            return b64string;
-        }
-        String returnString = decode(b64string).readLine();
-        if (returnString == null) {
-            return returnString;
-        }
-        return returnString.trim();
+	if (b64string == null) {
+	    return b64string;
+	}
+	String returnString = decode(b64string).readLine();
+	if (returnString == null) {
+	    return returnString;
+	}
+	return returnString.trim();
     }
 
     /**
@@ -83,19 +79,19 @@ public class Base64 {
      *             the String
      */
     public static ByteArrayOutputStream encode(String plaintext) throws IOException, MessagingException {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        byte[] in = plaintext.getBytes();
-        ByteArrayOutputStream inStream = new ByteArrayOutputStream();
-        inStream.write(in, 0, in.length);
-        // pad
-        if ((in.length % 3) == 1) {
-            inStream.write(0);
-            inStream.write(0);
-        } else if ((in.length % 3) == 2) {
-            inStream.write(0);
-        }
-        inStream.writeTo(MimeUtility.encode(out, "base64"));
-        return out;
+	ByteArrayOutputStream out = new ByteArrayOutputStream();
+	byte[] in = plaintext.getBytes();
+	ByteArrayOutputStream inStream = new ByteArrayOutputStream();
+	inStream.write(in, 0, in.length);
+	// pad
+	if ((in.length % 3) == 1) {
+	    inStream.write(0);
+	    inStream.write(0);
+	} else if ((in.length % 3) == 2) {
+	    inStream.write(0);
+	}
+	inStream.writeTo(MimeUtility.encode(out, "base64"));
+	return out;
     }
 
     /**
@@ -111,7 +107,6 @@ public class Base64 {
      *             the String
      */
     public static String encodeAsString(String plaintext) throws IOException, MessagingException {
-        return encode(plaintext).toString();
+	return encode(plaintext).toString();
     }
-
 }

Modified: james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java?rev=1299516&r1=1299515&r2=1299516&view=diff
==============================================================================
--- james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java (original)
+++ james/server/trunk/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java Mon Mar 12 01:34:16 2012
@@ -16,102 +16,106 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.smtpserver;
 
 import java.net.InetSocketAddress;
-
-import junit.framework.TestCase;
-
 import org.apache.james.protocols.lib.POP3BeforeSMTPHelper;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
 
-public class POP3BeforeSMTPHandlerTest extends TestCase {
+public class POP3BeforeSMTPHandlerTest {
 
     private SMTPSession mockedSession;
 
     private void setupMockedSMTPSession() {
-        mockedSession = new BaseFakeSMTPSession() {
-            private boolean relayingAllowed = false;
+	mockedSession = new BaseFakeSMTPSession() {
 
-            @Override
-            public InetSocketAddress getRemoteAddress() {
-                return new InetSocketAddress(getRemoteIPAddress(), 0);
-            }
-
-            public String getRemoteIPAddress() {
-                return "192.168.200.1";
-            }
-
-            public boolean isRelayingAllowed() {
-                return relayingAllowed;
-            }
-
-            public void setRelayingAllowed(boolean relayingAllowed) {
-                this.relayingAllowed = relayingAllowed;
-            }
+	    private boolean relayingAllowed = false;
 
-        };
+	    @Override
+	    public InetSocketAddress getRemoteAddress() {
+		return new InetSocketAddress(getRemoteIPAddress(), 0);
+	    }
+
+	    public String getRemoteIPAddress() {
+		return "192.168.200.1";
+	    }
+
+	    @Override
+	    public boolean isRelayingAllowed() {
+		return relayingAllowed;
+	    }
+
+	    @Override
+	    public void setRelayingAllowed(boolean relayingAllowed) {
+		this.relayingAllowed = relayingAllowed;
+	    }
+	};
     }
 
+    @Test
     public void testAuthWorks() {
 
-        POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
+	POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
-        setupMockedSMTPSession();
-        POP3BeforeSMTPHelper.addIPAddress("192.168.200.1");
+	setupMockedSMTPSession();
+	POP3BeforeSMTPHelper.addIPAddress("192.168.200.1");
 
-        assertFalse(mockedSession.isRelayingAllowed());
-        handler.onConnect(mockedSession);
-        assertTrue(mockedSession.isRelayingAllowed());
+	assertFalse(mockedSession.isRelayingAllowed());
+	handler.onConnect(mockedSession);
+	assertTrue(mockedSession.isRelayingAllowed());
     }
 
+    @Test
     public void testIPGetRemoved() {
-        long sleepTime = 100;
-        POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
+	long sleepTime = 100;
+	POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
-        setupMockedSMTPSession();
-        POP3BeforeSMTPHelper.addIPAddress("192.168.200.1");
-        assertFalse(mockedSession.isRelayingAllowed());
-
-        try {
-            Thread.sleep(sleepTime);
-            POP3BeforeSMTPHelper.removeExpiredIP(10);
-            handler.onConnect(mockedSession);
-            assertFalse(mockedSession.isRelayingAllowed());
-
-        } catch (InterruptedException e) {
-            // ignore
-        }
+	setupMockedSMTPSession();
+	POP3BeforeSMTPHelper.addIPAddress("192.168.200.1");
+	assertFalse(mockedSession.isRelayingAllowed());
+
+	try {
+	    Thread.sleep(sleepTime);
+	    POP3BeforeSMTPHelper.removeExpiredIP(10);
+	    handler.onConnect(mockedSession);
+	    assertFalse(mockedSession.isRelayingAllowed());
+
+	} catch (InterruptedException e) {
+	    // ignore
+	}
     }
 
+    @Test
     public void testThrowExceptionOnIllegalExpireTime() {
-        boolean exception = false;
-        POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
+	boolean exception = false;
+	POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
-        setupMockedSMTPSession();
+	setupMockedSMTPSession();
 
-        try {
-            handler.setExpireTime("1 unit");
-        } catch (NumberFormatException e) {
-            exception = true;
-        }
-        assertTrue(exception);
+	try {
+	    handler.setExpireTime("1 unit");
+	} catch (NumberFormatException e) {
+	    exception = true;
+	}
+	assertTrue(exception);
     }
 
+    @Test
     public void testValidExpireTime() {
-        boolean exception = false;
-        POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
+	boolean exception = false;
+	POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
-        setupMockedSMTPSession();
+	setupMockedSMTPSession();
 
-        try {
-            handler.setExpireTime("1 hour");
-        } catch (NumberFormatException e) {
-            exception = true;
-        }
-        assertFalse(exception);
+	try {
+	    handler.setExpireTime("1 hour");
+	} catch (NumberFormatException e) {
+	    exception = true;
+	}
+	assertFalse(exception);
     }
-
 }



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