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 fe...@apache.org on 2011/04/04 22:38:17 UTC
svn commit: r1088781 [3/5] - in /james/server/trunk:
core/src/test/java/org/apache/james/core/
data-api/src/test/java/org/apache/james/domainlist/api/mock/
data-library/src/test/java/org/apache/james/mailrepository/
data-library/src/test/java/org/apach...
Modified: james/server/trunk/jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java (original)
+++ james/server/trunk/jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java Mon Apr 4 20:38:14 2011
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
* Test the JPA implementation of the DomainList.
*/
public class JPADomainListTest extends TestCase {
-
+
// Domains we will play with.
private final String DOMAIN_1 = "domain1.tld";
private final String DOMAIN_2 = "domain2.tld";
@@ -54,17 +54,17 @@ public class JPADomainListTest extends T
* The properties for the OpenJPA Entity Manager.
*/
private HashMap<String, String> properties;
-
+
/**
* The JPA DomainList service.
*/
private JPADomainList jpaDomainList;
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
// Use a memory database.
properties = new HashMap<String, String>();
properties.put("openjpa.ConnectionDriverName", org.apache.derby.jdbc.EmbeddedDriver.class.getName());
@@ -72,9 +72,9 @@ public class JPADomainListTest extends T
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() +")");
+ properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPADomain.class.getName() + ")");
factory = OpenJPAPersistence.getEntityManagerFactory(properties);
-
+
// Initialize the JPADomainList (no autodetect,...).
jpaDomainList = new JPADomainList();
jpaDomainList.setLog(LoggerFactory.getLogger("JPADomainListMockLog"));
@@ -85,17 +85,18 @@ public class JPADomainListTest extends T
// Always delete everything before running any tests.
deleteAll();
-
+
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Add 3 domains and list them.
- * @throws DomainListException
+ *
+ * @throws DomainListException
*/
public void createListDomains() throws DomainListException {
jpaDomainList.addDomain(DOMAIN_3);
@@ -106,7 +107,8 @@ public class JPADomainListTest extends T
/**
* Add a domain and check it is present.
- * @throws DomainListException
+ *
+ * @throws DomainListException
*/
public void testAddContainsDomain() throws DomainListException {
jpaDomainList.addDomain(DOMAIN_2);
@@ -115,7 +117,8 @@ public class JPADomainListTest extends T
/**
* Add and remove a domain, and check database is empty.
- * @throws DomainListException
+ *
+ * @throws DomainListException
*/
public void testAddRemoveContainsSameDomain() throws DomainListException {
jpaDomainList.addDomain(DOMAIN_1);
@@ -124,8 +127,10 @@ public class JPADomainListTest extends T
}
/**
- * Add a domain and remove another domain, and check first domain is still present.
- * @throws DomainListException
+ * Add a domain and remove another domain, and check first domain is still
+ * present.
+ *
+ * @throws DomainListException
*/
public void testAddRemoveContainsDifferentDomain() throws DomainListException {
jpaDomainList.addDomain(DOMAIN_1);
@@ -133,10 +138,11 @@ public class JPADomainListTest extends T
assertEquals(1, jpaDomainList.getDomains().length);
assertEquals(true, jpaDomainList.containsDomain(DOMAIN_1));
}
-
+
/**
* Delete all possible domains from database.
- * @throws DomainListException
+ *
+ * @throws DomainListException
*/
private void deleteAll() throws DomainListException {
jpaDomainList.removeDomain(DOMAIN_1);
@@ -157,14 +163,16 @@ public class JPADomainListTest extends T
public String getHostName(InetAddress inet) {
return hostName;
}
+
public InetAddress[] getAllByName(String name) throws UnknownHostException {
- return new InetAddress[] { InetAddress.getByName("127.0.0.1")};
+ return new InetAddress[] { InetAddress.getByName("127.0.0.1") };
}
+
public InetAddress getLocalHost() throws UnknownHostException {
- return InetAddress.getLocalHost();
+ return InetAddress.getLocalHost();
}
};
return dns;
}
-
+
}
Modified: james/server/trunk/jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java (original)
+++ james/server/trunk/jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -45,7 +45,7 @@ public class JpaUsersRepositoryTest exte
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() +")");
+ properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPAUser.class.getName() + ")");
super.setUp();
deleteAll();
}
@@ -54,9 +54,9 @@ public class JpaUsersRepositoryTest exte
protected void tearDown() throws Exception {
deleteAll();
super.tearDown();
-
+
}
-
+
private void deleteAll() {
OpenJPAEntityManager manager = factory.createEntityManager();
final OpenJPAEntityTransaction transaction = manager.getTransaction();
@@ -75,9 +75,9 @@ public class JpaUsersRepositoryTest exte
}
@Override
- protected UsersRepository getUsersRepository() throws Exception {
+ protected UsersRepository getUsersRepository() throws Exception {
factory = OpenJPAPersistence.getEntityManagerFactory(properties);
- JPAUsersRepository repos = new JPAUsersRepository();
+ JPAUsersRepository repos = new JPAUsersRepository();
repos.setLog(LoggerFactory.getLogger("JPA"));
repos.setEntityManagerFactory(factory);
repos.configure(new DefaultConfigurationBuilder());
Modified: james/server/trunk/jpa/src/test/java/org/apache/james/vut/jpa/JPAVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jpa/src/test/java/org/apache/james/vut/jpa/JPAVirtualUserTableTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jpa/src/test/java/org/apache/james/vut/jpa/JPAVirtualUserTableTest.java (original)
+++ james/server/trunk/jpa/src/test/java/org/apache/james/vut/jpa/JPAVirtualUserTableTest.java Mon Apr 4 20:38:14 2011
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
* Test the JPA Virtual User Table implementation.
*/
public class JPAVirtualUserTableTest extends AbstractVirtualUserTableTest {
-
+
/**
* The OpenJPA Entity Manager used for the tests.
*/
@@ -44,7 +44,7 @@ public class JPAVirtualUserTableTest ext
* The properties for the OpenJPA Entity Manager.
*/
private HashMap<String, String> properties;
-
+
@Override
protected void setUp() throws Exception {
@@ -55,12 +55,12 @@ public class JPAVirtualUserTableTest ext
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=" + JPAVirtualUser.class.getName() +")");
-
+ properties.put("openjpa.MetaDataFactory", "jpa(Types=" + JPAVirtualUser.class.getName() + ")");
+
factory = OpenJPAPersistence.getEntityManagerFactory(properties);
super.setUp();
-
+
}
/**
@@ -73,12 +73,13 @@ public class JPAVirtualUserTableTest ext
DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
virtualUserTable.configure(defaultConfiguration);
return virtualUserTable;
- }
-
+ }
+
/**
- * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#addMapping(java.lang.String, java.lang.String, java.lang.String, int)
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#addMapping(java.lang.String,
+ * java.lang.String, java.lang.String, int)
*/
- protected boolean addMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException{
+ protected boolean addMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException {
try {
if (type == ERROR_TYPE) {
virtualUserTable.addErrorMapping(user, domain, mapping);
@@ -98,25 +99,26 @@ public class JPAVirtualUserTableTest ext
}
/**
- * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#removeMapping(java.lang.String, java.lang.String, java.lang.String, int)
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#removeMapping(java.lang.String,
+ * java.lang.String, java.lang.String, int)
*/
- protected boolean removeMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException{
+ protected boolean removeMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException {
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 {
+ 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 (VirtualUserTableException e) {
return false;
}
- return true;
- } catch (VirtualUserTableException e) {
- return false;
}
- }
-
+
}
Modified: james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessorTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessorTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessorTest.java (original)
+++ james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessorTest.java Mon Apr 4 20:38:14 2011
@@ -28,7 +28,7 @@ import org.apache.james.mailetcontainer.
import org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor;
import org.slf4j.LoggerFactory;
-public class CamelCompositeProcessorTest extends AbstractStateCompositeProcessorTest{
+public class CamelCompositeProcessorTest extends AbstractStateCompositeProcessorTest {
@Override
protected AbstractStateCompositeProcessor createProcessor(HierarchicalConfiguration config) throws ConfigurationException, Exception {
Modified: james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessorTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessorTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessorTest.java (original)
+++ james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessorTest.java Mon Apr 4 20:38:14 2011
@@ -38,8 +38,9 @@ public class CamelMailetProcessorTest ex
try {
processor = new CamelMailetProcessor();
Logger log = LoggerFactory.getLogger("MockLog");
- // slf4j can't set programmatically any log level. It's just a facade
- //log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
+ // slf4j can't set programmatically any log level. It's just a
+ // facade
+ // log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
processor.setLog(log);
processor.setCamelContext(new DefaultCamelContext());
processor.setMailetContext(new MockMailetContext());
@@ -49,7 +50,8 @@ public class CamelMailetProcessorTest ex
processor.init();
return processor;
} finally {
- if (processor != null) processor.destroy();
+ if (processor != null)
+ processor.destroy();
}
}
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java Mon Apr 4 20:38:14 2011
@@ -25,13 +25,12 @@ import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
-public class ExceptionThrowingMailet implements Mailet{
+public class ExceptionThrowingMailet implements Mailet {
private MailetConfig config;
public void destroy() {
-
}
public MailetConfig getMailetConfig() {
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java Mon Apr 4 20:38:14 2011
@@ -27,11 +27,11 @@ import org.apache.mailet.Mail;
import org.apache.mailet.Matcher;
import org.apache.mailet.MatcherConfig;
-public class ExceptionThrowingMatcher implements Matcher{
+public class ExceptionThrowingMatcher implements Matcher {
private MatcherConfig config;
- public void destroy() {
+ public void destroy() {
}
public MatcherConfig getMatcherConfig() {
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java Mon Apr 4 20:38:14 2011
@@ -23,15 +23,15 @@ import javax.mail.MessagingException;
import org.apache.james.mailetcontainer.api.MailProcessor;
import org.apache.mailet.Mail;
-public class MockMailProcessor implements MailProcessor{
+public class MockMailProcessor implements MailProcessor {
private boolean shouldThrow = false;
private String newState = null;
-
+
public MockMailProcessor(boolean shouldThrow) {
this.shouldThrow = shouldThrow;
}
-
+
public MockMailProcessor(String newState) {
this.newState = newState;
}
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java Mon Apr 4 20:38:14 2011
@@ -25,11 +25,11 @@ import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
-public class MockMailet implements Mailet{
+public class MockMailet implements Mailet {
private MailetConfig config;
-
- public void destroy() {
+
+ public void destroy() {
}
public MailetConfig getMailetConfig() {
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java Mon Apr 4 20:38:14 2011
@@ -35,19 +35,19 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
-public class MockMailetContext implements MailetContext{
+public class MockMailetContext implements MailetContext {
private Map<String, Object> attributes = new HashMap<String, Object>();
private List<Mail> mails = new ArrayList<Mail>();
-
+
public void bounce(Mail arg0, String arg1) throws MessagingException {
throw new UnsupportedOperationException("Not implemented");
-
+
}
public void bounce(Mail arg0, String arg1, MailAddress arg2) throws MessagingException {
throw new UnsupportedOperationException("Not implemented");
-
+
}
public Object getAttribute(String arg0) {
@@ -59,8 +59,8 @@ public class MockMailetContext implement
}
/**
- * Return an {@link Collection} which holds "mx.localhost" if the given host was "localhost". Otherwise
- * and empty {@link Collection} is returned
+ * Return an {@link Collection} which holds "mx.localhost" if the given host
+ * was "localhost". Otherwise and empty {@link Collection} is returned
*/
public Collection getMailServers(String host) {
List<String> servers = new ArrayList<String>();
@@ -123,7 +123,7 @@ public class MockMailetContext implement
public void log(String arg0, Throwable arg1) {
System.out.println(arg0);
arg1.printStackTrace();
-
+
}
public void removeAttribute(String arg0) {
@@ -132,21 +132,21 @@ public class MockMailetContext implement
public void sendMail(MimeMessage arg0) throws MessagingException {
throw new UnsupportedOperationException("Not implemented");
-
+
}
public void sendMail(Mail mail) throws MessagingException {
- mails.add(mail);
+ mails.add(mail);
}
public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2) throws MessagingException {
throw new UnsupportedOperationException("Not implemented");
-
+
}
public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2, String arg3) throws MessagingException {
throw new UnsupportedOperationException("Not implemented");
-
+
}
public void setAttribute(String arg0, Object arg1) {
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java Mon Apr 4 20:38:14 2011
@@ -24,12 +24,12 @@ import org.apache.james.mailetcontainer.
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
-public class MockMailetLoader implements MailetLoader{
+public class MockMailetLoader implements MailetLoader {
@SuppressWarnings("unchecked")
public Mailet getMailet(MailetConfig config) throws MessagingException {
try {
- Class<Mailet> clazz = (Class<Mailet>)Thread.currentThread().getContextClassLoader().loadClass(config.getMailetName());
+ Class<Mailet> clazz = (Class<Mailet>) Thread.currentThread().getContextClassLoader().loadClass(config.getMailetName());
Mailet m = clazz.newInstance();
m.init(config);
return m;
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java Mon Apr 4 20:38:14 2011
@@ -31,14 +31,14 @@ import org.apache.mailet.MailAddress;
import org.apache.mailet.Matcher;
import org.apache.mailet.MatcherConfig;
-public class MockMatcher implements Matcher{
+public class MockMatcher implements Matcher {
private int matchCount = 0;
-
+
private MatcherConfig config;
-
+
public void destroy() {
-
+
}
public MatcherConfig getMatcherConfig() {
@@ -56,12 +56,12 @@ public class MockMatcher implements Matc
public Collection match(Mail mail) throws MessagingException {
List<MailAddress> match = new ArrayList<MailAddress>();
-
+
Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
while (rcpts.hasNext() && match.size() < matchCount) {
MailAddress addr = rcpts.next();
match.add(addr);
-
+
}
if (match.isEmpty()) {
return null;
Modified: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java (original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java Mon Apr 4 20:38:14 2011
@@ -24,13 +24,13 @@ import org.apache.james.mailetcontainer.
import org.apache.mailet.Matcher;
import org.apache.mailet.MatcherConfig;
-public class MockMatcherLoader implements MatcherLoader{
+public class MockMatcherLoader implements MatcherLoader {
@SuppressWarnings("unchecked")
public Matcher getMatcher(MatcherConfig config) throws MessagingException {
-
+
try {
- Class<Matcher> clazz = (Class<Matcher>)Thread.currentThread().getContextClassLoader().loadClass(config.getMatcherName());
+ Class<Matcher> clazz = (Class<Matcher>) Thread.currentThread().getContextClassLoader().loadClass(config.getMatcherName());
Matcher m = clazz.newInstance();
m.init(config);
return m;
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java Mon Apr 4 20:38:14 2011
@@ -1,19 +1,23 @@
-package org.apache.james.samples.mailets;
-
+/****************************************************************
+ * 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. *
+ ****************************************************************/
-/*
- * Licensed 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.samples.mailets;
import javax.mail.MessagingException;
@@ -28,7 +32,7 @@ import org.apache.mailet.MailetContext;
public class HelloWorldMailet implements Mailet {
private MailetConfig config;
-
+
public void destroy() {
}
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java Mon Apr 4 20:38:14 2011
@@ -1,18 +1,23 @@
-package org.apache.james.samples.mailets;
+/****************************************************************
+ * 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. *
+ ****************************************************************/
-/*
- * Licensed 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.samples.mailets;
import java.io.IOException;
import java.util.Collection;
@@ -36,13 +41,13 @@ import org.apache.mailet.MailetConfig;
import org.apache.mailet.MailetContext;
/**
- * Mailet just prints out the details of a message.
- * Sometimes Useful for debugging.
+ * Mailet just prints out the details of a message. Sometimes Useful for
+ * debugging.
*/
public class InstrumentationMailet implements Mailet {
private MailetConfig config;
-
+
public void destroy() {
}
@@ -63,12 +68,12 @@ public class InstrumentationMailet imple
MailetContext context = config.getMailetContext();
context.log("######## MAIL STARTS");
context.log("");
-
+
MimeMessage message = mail.getMessage();
-
+
context.log("Mail named: " + mail.getName());
-
- for (Iterator it=mail.getAttributeNames(); it.hasNext();) {
+
+ for (Iterator it = mail.getAttributeNames(); it.hasNext();) {
String attributeName = (String) it.next();
context.log("Attribute " + attributeName);
}
@@ -80,48 +85,45 @@ public class InstrumentationMailet imple
context.log("Sender host: " + mail.getSender().getDomain());
context.log("Sender user: " + mail.getSender().getLocalPart());
Collection<MailAddress> recipients = mail.getRecipients();
- for (Iterator<MailAddress> it = recipients.iterator(); it.hasNext();)
- {
+ for (Iterator<MailAddress> it = recipients.iterator(); it.hasNext();) {
MailAddress address = it.next();
context.log("Recipient: " + address.getLocalPart() + "@" + address.getDomain());
}
-
+
context.log("Subject: " + message.getSubject());
context.log("MessageID: " + message.getMessageID());
context.log("Received: " + message.getReceivedDate());
context.log("Sent: " + message.getSentDate());
-
+
Enumeration allHeadersLines = message.getAllHeaderLines();
- while(allHeadersLines.hasMoreElements()) {
+ while (allHeadersLines.hasMoreElements()) {
String header = (String) allHeadersLines.nextElement();
context.log("Header Line:= " + header);
}
-
-
+
Enumeration allHeadersEnumeration = message.getAllHeaders();
- while(allHeadersEnumeration.hasMoreElements()) {
+ while (allHeadersEnumeration.hasMoreElements()) {
Header header = (Header) allHeadersEnumeration.nextElement();
context.log("Header: " + header.getName() + "=" + header.getValue());
}
-
+
Address[] to = message.getRecipients(RecipientType.TO);
printAddresses(to, "TO: ");
Address[] cc = message.getRecipients(RecipientType.CC);
- printAddresses(cc, "CC: ");
+ printAddresses(cc, "CC: ");
Address[] bcc = message.getRecipients(RecipientType.BCC);
- printAddresses(bcc, "BCC: ");
+ printAddresses(bcc, "BCC: ");
-
Flags flags = message.getFlags();
Flag[] systemFlags = flags.getSystemFlags();
- for (int i=0;i<systemFlags.length;i++) {
+ for (int i = 0; i < systemFlags.length; i++) {
context.log("System Flag:" + systemFlags[i]);
}
String[] userFlags = flags.getUserFlags();
- for (int i=0;i<userFlags.length;i++) {
+ for (int i = 0; i < userFlags.length; i++) {
context.log("User flag: " + userFlags[i]);
}
-
+
String mimeType = message.getContentType();
context.log("Mime type: " + mimeType);
if (mimeType == "text/plain") {
@@ -131,16 +133,16 @@ public class InstrumentationMailet imple
} catch (IOException e) {
e.printStackTrace();
}
-
+
}
-
+
context.log("");
context.log("######## MAIL ENDS");
}
-
+
private final void printAddresses(Address[] addresses, String prefix) {
MailetContext context = config.getMailetContext();
- for (int i=0;i<addresses.length;i++) {
+ for (int i = 0; i < addresses.length; i++) {
if (addresses[i] instanceof InternetAddress) {
InternetAddress address = (InternetAddress) addresses[i];
context.log(prefix + address.getPersonal() + "@" + address.getAddress());
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/mailets/VirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/mailets/VirtualUserTableTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/mailets/VirtualUserTableTest.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/mailets/VirtualUserTableTest.java Mon Apr 4 20:38:14 2011
@@ -38,13 +38,13 @@ import org.apache.mailet.base.test.FakeM
import org.apache.mailet.base.test.FakeMailetConfig;
import org.apache.mailet.base.test.FakeMimeMessage;
-public class VirtualUserTableTest extends TestCase{
+public class VirtualUserTableTest extends TestCase {
private org.apache.james.transport.mailets.VirtualUserTable table;
-
+
@Override
protected void setUp() throws Exception {
-
+
table = new org.apache.james.transport.mailets.VirtualUserTable();
final FakeMailContext mockMailetContext = new FakeMailContext() {
@@ -53,10 +53,10 @@ public class VirtualUserTableTest extend
if (serverName.equals("localhost")) {
return true;
}
-
+
return false;
}
-
+
};
FakeMailetConfig mockMailetConfig = new FakeMailetConfig("vut", mockMailetContext, new Properties());
// mockMailetConfig.put("virtualusertable", "vut");
@@ -131,29 +131,27 @@ public class VirtualUserTableTest extend
}
-
@Override
protected void tearDown() throws Exception {
table = null;
-
- }
+ }
public void testAddressMapping() throws Exception {
- Mail mail = createMail(new String[] {"test@localhost", "apache@localhost"});
+ Mail mail = createMail(new String[] { "test@localhost", "apache@localhost" });
table.service(mail);
-
- assertEquals(3,mail.getRecipients().size());
+
+ assertEquals(3, mail.getRecipients().size());
Iterator<MailAddress> it = mail.getRecipients().iterator();
- assertEquals("whatever@localhost", ((MailAddress)it.next()).toString());
- assertEquals("blah@localhost", ((MailAddress)it.next()).toString());
- assertEquals("apache@localhost", ((MailAddress)it.next()).toString());
+ assertEquals("whatever@localhost", ((MailAddress) it.next()).toString());
+ assertEquals("blah@localhost", ((MailAddress) it.next()).toString());
+ assertEquals("apache@localhost", ((MailAddress) it.next()).toString());
}
-
+
/**
* @return
- * @throws MessagingException
+ * @throws MessagingException
*/
private Mail createMail(String[] recipients) throws MessagingException {
Mail mail = new FakeMail();
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
import java.io.Serializable;
@@ -53,8 +52,7 @@ public abstract class AbstractRemoteAddr
private DNSService dnsServer;
- public AbstractRemoteAddrInNetworkTest(String arg0)
- throws UnsupportedEncodingException {
+ public AbstractRemoteAddrInNetworkTest(String arg0) throws UnsupportedEncodingException {
super(arg0);
}
@@ -68,49 +66,40 @@ public abstract class AbstractRemoteAddr
private static final long serialVersionUID = 1L;
public String getName() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void setName(String newName) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public MimeMessage getMessage() throws MessagingException {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Collection<MailAddress> getRecipients() {
ArrayList<MailAddress> r = new ArrayList<MailAddress>();
try {
- r = new ArrayList<MailAddress>(Arrays
- .asList(new MailAddress[] { new MailAddress(
- "test@james.apache.org") }));
+ r = new ArrayList<MailAddress>(Arrays.asList(new MailAddress[] { new MailAddress("test@james.apache.org") }));
} catch (ParseException e) {
}
return r;
}
public void setRecipients(Collection recipients) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public MailAddress getSender() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public String getState() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public String getRemoteHost() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public String getRemoteAddr() {
@@ -118,68 +107,55 @@ public abstract class AbstractRemoteAddr
}
public String getErrorMessage() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void setErrorMessage(String msg) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void setMessage(MimeMessage message) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void setState(String state) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Serializable getAttribute(String name) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Iterator getAttributeNames() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public boolean hasAttributes() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Serializable removeAttribute(String name) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void removeAllAttributes() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Serializable setAttribute(String name, Serializable object) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public long getMessageSize() throws MessagingException {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public Date getLastUpdated() {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
public void setLastUpdated(Date lastUpdated) {
- throw new UnsupportedOperationException(
- "Unimplemented mock service");
+ throw new UnsupportedOperationException("Unimplemented mock service");
}
};
@@ -188,25 +164,23 @@ public abstract class AbstractRemoteAddr
protected void setupDNSServer() {
dnsServer = new MockDNSService() {
- public InetAddress getByName(String host)
- throws UnknownHostException {
+ public InetAddress getByName(String host) throws UnknownHostException {
if ("192.168.200.0".equals(host) || "255.255.255.0".equals(host) || "192.168.200.1".equals(host) || "192.168.0.1".equals(host) || "192.168.1.1".equals(host)) {
// called with an IP it only check formal validity
return InetAddress.getByName(host);
}
- throw new UnsupportedOperationException("getByName("+host+") unimplemented in AbstractRemoteAddrInNetworkTest");
+ throw new UnsupportedOperationException("getByName(" + host + ") unimplemented in AbstractRemoteAddrInNetworkTest");
}
};
}
protected void setupMatcher() throws MessagingException {
-
+
FakeMailContext mmc = new FakeMailContext();
matcher = createMatcher();
matcher.setDNSService(dnsServer);
- FakeMatcherConfig mci = new FakeMatcherConfig(getConfigOption()
- + getAllowedNetworks(), mmc);
+ FakeMatcherConfig mci = new FakeMatcherConfig(getConfigOption() + getAllowedNetworks(), mmc);
matcher.init(mci);
}
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
import org.apache.james.dnsservice.api.DNSService;
@@ -44,7 +43,7 @@ public class InSpammerBlacklistTest exte
private FakeMail mockedMail;
private InSpammerBlacklist matcher;
-
+
private final static String BLACKLIST = "my.black.list.";
private final static StringBuffer LISTED_HOST = new StringBuffer("111.222.111.222");
@@ -64,10 +63,11 @@ public class InSpammerBlacklistTest exte
};
return dns;
}
+
private void setupMockedMail(String remoteAddr) throws ParseException {
mockedMail = new FakeMail();
mockedMail.setRemoteAddr(remoteAddr);
- mockedMail.setRecipients(Arrays.asList(new MailAddress[] {new MailAddress("test@email")}));
+ mockedMail.setRecipients(Arrays.asList(new MailAddress[] { new MailAddress("test@email") }));
}
@@ -75,11 +75,10 @@ public class InSpammerBlacklistTest exte
matcher = new InSpammerBlacklist();
matcher.setDNSService(setUpDNSServer());
FakeMailContext context = new FakeMailContext();
- FakeMatcherConfig mci = new FakeMatcherConfig("InSpammerBlacklist=" + blacklist,context);
+ FakeMatcherConfig mci = new FakeMatcherConfig("InSpammerBlacklist=" + blacklist, context);
matcher.init(mci);
}
-
public void testInBlackList() throws MessagingException {
setupMockedMail(LISTED_HOST.toString());
setupMatcher(BLACKLIST);
@@ -89,7 +88,7 @@ public class InSpammerBlacklistTest exte
assertNotNull(matchedRecipients);
assertEquals(matchedRecipients.size(), mockedMail.getRecipients().size());
}
-
+
public void testNotInBlackList() throws MessagingException {
setupMockedMail("212.12.14.1");
setupMatcher(BLACKLIST);
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
import java.io.UnsupportedEncodingException;
@@ -31,8 +30,7 @@ public class RemoteAddrInNetworkTest ext
private final String ALLOWED_NETWORK = "192.168.200.0/24";
- public RemoteAddrInNetworkTest(String arg0)
- throws UnsupportedEncodingException {
+ public RemoteAddrInNetworkTest(String arg0) throws UnsupportedEncodingException {
super(arg0);
}
@@ -45,8 +43,7 @@ public class RemoteAddrInNetworkTest ext
Collection<MailAddress> matchedRecipients = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
- assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
- .size());
+ assertEquals(matchedRecipients.size(), mockedMail.getRecipients().size());
}
// test if no recipient get returned cause it not match
Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java (original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
import java.io.UnsupportedEncodingException;
@@ -31,8 +30,7 @@ public class RemoteAddrNotInNetworkTest
private final String ALLOWED_NETWORK = "192.168.200.0/24";
- public RemoteAddrNotInNetworkTest(String arg0)
- throws UnsupportedEncodingException {
+ public RemoteAddrNotInNetworkTest(String arg0) throws UnsupportedEncodingException {
super(arg0);
}
@@ -45,8 +43,7 @@ public class RemoteAddrNotInNetworkTest
Collection<MailAddress> matchedRecipients = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
- assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
- .size());
+ assertEquals(matchedRecipients.size(), mockedMail.getRecipients().size());
}
// test if no recipient get returned cause it not match
Modified: james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/CRLFTerminatedInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/CRLFTerminatedInputStreamTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/CRLFTerminatedInputStreamTest.java (original)
+++ james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/CRLFTerminatedInputStreamTest.java Mon Apr 4 20:38:14 2011
@@ -27,7 +27,7 @@ import org.apache.james.pop3server.core.
import junit.framework.TestCase;
-public class CRLFTerminatedInputStreamTest extends TestCase{
+public class CRLFTerminatedInputStreamTest extends TestCase {
public void testCRLFPresent() throws IOException {
String data = "Subject: test\r\n\r\ndata\r\n";
@@ -35,15 +35,14 @@ public class CRLFTerminatedInputStreamTe
checkWithArray(data, data);
}
-
-
+
public void testCRPresent() throws IOException {
String data = "Subject: test\r\n\r\ndata\r";
String expected = data + "\n";
check(data, expected);
checkWithArray(data, expected);
}
-
+
public void testNonPresent() throws IOException {
String data = "Subject: test\r\n\r\ndata";
String expected = data + "\r\n";
@@ -51,29 +50,28 @@ public class CRLFTerminatedInputStreamTe
checkWithArray(data, expected);
}
-
-
+
private void check(String source, String expected) throws IOException {
CRLFTerminatedInputStream in = new CRLFTerminatedInputStream(new ByteArrayInputStream(source.getBytes()));
-
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
int i = -1;
- while((i = in.read()) != -1) {
+ while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(expected, output);
}
-
+
private void checkWithArray(String source, String expected) throws IOException {
CRLFTerminatedInputStream in = new CRLFTerminatedInputStream(new ByteArrayInputStream(source.getBytes()));
-
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
byte[] buf = new byte[1024];
int i = 0;
while ((i = in.read(buf)) != -1) {
@@ -82,7 +80,7 @@ public class CRLFTerminatedInputStreamTe
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(expected, output);
}
Modified: james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/ExtraDotInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/ExtraDotInputStreamTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/ExtraDotInputStreamTest.java (original)
+++ james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/ExtraDotInputStreamTest.java Mon Apr 4 20:38:14 2011
@@ -27,70 +27,71 @@ import org.apache.james.pop3server.core.
import junit.framework.TestCase;
-public class ExtraDotInputStreamTest extends TestCase{
+public class ExtraDotInputStreamTest extends TestCase {
public void testExtraDot() throws IOException {
String data = "This\r\n.\r\nThis.\r\n";
String expectedOutput = "This\r\n..\r\nThis.\r\n";
ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
int i = -1;
- while((i = in.read()) != -1) {
+ while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(expectedOutput, output);
-
+
}
-
+
public void testNoDotCLRF() throws IOException {
String data = "ABCD\r\n";
ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
int i = -1;
- while((i = in.read()) != -1) {
+ while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(data, output);
}
-
+
public void testNoDot() throws IOException {
String data = "ABCD";
ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
int i = -1;
- while((i = in.read()) != -1) {
+ while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(data, output);
}
+
// Proof of BUG JAMES-1152
public void testNoDotHeaderBody() throws IOException {
String data = "Subject: test\r\n\r\nABCD\r\n";
ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
int i = -1;
- while((i = in.read()) != -1) {
+ while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
-
+
String output = new String(out.toByteArray());
assertEquals(data, output);
}
Modified: james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java (original)
+++ james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java Mon Apr 4 20:38:14 2011
@@ -21,12 +21,11 @@ package org.apache.james.pop3server;
import org.apache.james.pop3server.netty.OioPOP3Server;
import org.apache.james.pop3server.netty.POP3Server;
-public class OioPOP3ServerTest extends POP3ServerTest{
+public class OioPOP3ServerTest extends POP3ServerTest {
@Override
protected POP3Server createPOP3Server() {
return new OioPOP3Server();
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org