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 [2/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/data-library/src/test/java/org/apache/james/vut/lib/AbstractVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/AbstractVirtualUserTableTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/AbstractVirtualUserTableTest.java (original)
+++ james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/AbstractVirtualUserTableTest.java Mon Apr 4 20:38:14 2011
@@ -31,14 +31,14 @@ import org.apache.james.vut.api.VirtualU
import org.apache.james.vut.lib.AbstractVirtualUserTable;
/**
- * The abstract test for the virtual user table.
- * Contains tests related to simple, regexp, wildcard, error,...
- * Extend this and instanciate the needed virtualUserTable implementation.
+ * The abstract test for the virtual user table. Contains tests related to
+ * simple, regexp, wildcard, error,... Extend this and instanciate the needed
+ * virtualUserTable implementation.
*/
public abstract class AbstractVirtualUserTableTest extends TestCase {
protected AbstractVirtualUserTable virtualUserTable;
-
+
protected final static int REGEX_TYPE = 0;
protected final static int ERROR_TYPE = 1;
protected final static int ADDRESS_TYPE = 2;
@@ -49,14 +49,14 @@ public abstract class AbstractVirtualUse
}
protected void tearDown() throws Exception {
-
- Map<String,Collection<String>> mappings = virtualUserTable.getAllMappings();
+
+ Map<String, Collection<String>> mappings = virtualUserTable.getAllMappings();
if (mappings != null) {
-
+
Iterator<String> mappingsIt = virtualUserTable.getAllMappings().keySet().iterator();
- while(mappingsIt.hasNext()) {
+ while (mappingsIt.hasNext()) {
String key = mappingsIt.next().toString();
String args[] = key.split("@");
@@ -73,25 +73,25 @@ public abstract class AbstractVirtualUse
}
}
}
-
+
LifecycleUtil.dispose(virtualUserTable);
-
+
}
public void testStoreAndRetrieveRegexMapping() throws org.apache.james.vut.api.VirtualUserTable.ErrorMappingException, VirtualUserTableException {
-
+
String user = "test";
String domain = "localhost";
// String regex = "(.*):{$1}@localhost";
- // String regex2 = "(.+):{$1}@test";
+ // String regex2 = "(.+):{$1}@test";
String regex = "(.*)@localhost";
- String regex2 = "(.+)@test";
+ String regex2 = "(.+)@test";
String invalidRegex = ".*):";
boolean catched = false;
-
+
try {
- assertNull("No mapping",virtualUserTable.getMappings(user, domain));
+ assertNull("No mapping", virtualUserTable.getMappings(user, domain));
assertTrue("Added virtual mapping", addMapping(user, domain, regex, REGEX_TYPE));
assertTrue("Added virtual mapping", addMapping(user, domain, regex2, REGEX_TYPE));
@@ -105,7 +105,7 @@ public abstract class AbstractVirtualUse
} catch (VirtualUserTableException e) {
catched = true;
}
- assertTrue("Invalid Mapping throw exception" , catched);
+ assertTrue("Invalid Mapping throw exception", catched);
assertTrue("remove virtual mapping", removeMapping(user, domain, regex2, REGEX_TYPE));
@@ -120,9 +120,8 @@ public abstract class AbstractVirtualUse
}
-
public void testStoreAndRetrieveAddressMapping() throws ErrorMappingException, VirtualUserTableException {
-
+
String user = "test";
String domain = "localhost";
String address = "test@localhost2";
@@ -130,27 +129,24 @@ public abstract class AbstractVirtualUse
try {
- assertNull("No mapping",virtualUserTable.getMappings(user, domain));
+ assertNull("No mapping", virtualUserTable.getMappings(user, domain));
assertTrue("Added virtual mapping", addMapping(user, domain, address, ADDRESS_TYPE));
assertTrue("Added virtual mapping", addMapping(user, domain, address2, ADDRESS_TYPE));
- assertEquals("Two mappings", virtualUserTable.getMappings(user, domain).size(),2);
- assertEquals("One mappingline", virtualUserTable.getAllMappings().size(),1);
+ assertEquals("Two mappings", virtualUserTable.getMappings(user, domain).size(), 2);
+ assertEquals("One mappingline", virtualUserTable.getAllMappings().size(), 1);
assertTrue("remove virtual mapping", removeMapping(user, domain, address, ADDRESS_TYPE));
- /* TEMPORARILY REMOVE JDBC specific test
- String invalidAddress= ".*@localhost2:";
- boolean catched = false;
- if (virtualUserTable instanceof JDBCVirtualUserTable) {
- try {
- assertTrue("Added virtual mapping", addMapping(user, domain, invalidAddress, ADDRESS_TYPE));
- } catch (InvalidMappingException e) {
- catched = true;
- }
- assertTrue("Invalid Mapping throw exception" , catched);
- }
+ /*
+ * TEMPORARILY REMOVE JDBC specific test String invalidAddress=
+ * ".*@localhost2:"; boolean catched = false; if (virtualUserTable
+ * instanceof JDBCVirtualUserTable) { try {
+ * assertTrue("Added virtual mapping", addMapping(user, domain,
+ * invalidAddress, ADDRESS_TYPE)); } catch (InvalidMappingException
+ * e) { catched = true; }
+ * assertTrue("Invalid Mapping throw exception" , catched); }
*/
assertTrue("remove virtual mapping", removeMapping(user, domain, address2, ADDRESS_TYPE));
@@ -162,11 +158,10 @@ public abstract class AbstractVirtualUse
fail("Storing failed");
}
-
}
public void testStoreAndRetrieveErrorMapping() throws ErrorMappingException, VirtualUserTableException {
-
+
String user = "test";
String domain = "localhost";
String error = "bounce!";
@@ -174,17 +169,17 @@ public abstract class AbstractVirtualUse
try {
- assertNull("No mapping",virtualUserTable.getMappings(user, domain));
+ assertNull("No mapping", virtualUserTable.getMappings(user, domain));
assertTrue("Added virtual mapping", addMapping(user, domain, error, ERROR_TYPE));
- assertEquals("One mappingline", virtualUserTable.getAllMappings().size(),1);
+ assertEquals("One mappingline", virtualUserTable.getAllMappings().size(), 1);
try {
virtualUserTable.getMappings(user, domain);
} catch (ErrorMappingException e) {
catched = true;
}
- assertTrue("Error Mapping throw exception" , catched);
+ assertTrue("Error Mapping throw exception", catched);
assertTrue("remove virtual mapping", removeMapping(user, domain, error, ERROR_TYPE));
assertNull("No mapping", virtualUserTable.getMappings(user, domain));
@@ -226,7 +221,7 @@ public abstract class AbstractVirtualUse
}
public void testRecursiveMapping() throws ErrorMappingException, VirtualUserTableException {
-
+
String user1 = "user1";
String user2 = "user2";
String user3 = "user3";
@@ -238,11 +233,11 @@ public abstract class AbstractVirtualUse
virtualUserTable.setRecursiveMapping(true);
try {
- assertNull("No mappings",virtualUserTable.getAllMappings());
+ assertNull("No mappings", virtualUserTable.getAllMappings());
assertTrue("Add mapping", addMapping(user1, domain1, user2 + "@" + domain2, ADDRESS_TYPE));
assertTrue("Add mapping", addMapping(user2, domain2, user3 + "@" + domain3, ADDRESS_TYPE));
- assertEquals("Recursive mapped", virtualUserTable.getMappings(user1, domain1).iterator().next(),user3 + "@" + domain3);
+ assertEquals("Recursive mapped", virtualUserTable.getMappings(user1, domain1).iterator().next(), user3 + "@" + domain3);
assertTrue("Add mapping", addMapping(user3, domain3, user1 + "@" + domain1, ADDRESS_TYPE));
try {
@@ -254,26 +249,25 @@ public abstract class AbstractVirtualUse
// disable recursive mapping
virtualUserTable.setRecursiveMapping(false);
- assertEquals("Not recursive mapped", virtualUserTable.getMappings(user1, domain1).iterator().next(),user2 + "@" + domain2);
+ assertEquals("Not recursive mapped", virtualUserTable.getMappings(user1, domain1).iterator().next(), user2 + "@" + domain2);
} catch (IllegalArgumentException e) {
fail("Storing failed");
}
}
-
public void testAliasDomainMapping() throws ErrorMappingException, VirtualUserTableException {
-
+
String domain = "realdomain";
String aliasDomain = "aliasdomain";
String user = "user";
String user2 = "user2";
- assertNull("No mappings",virtualUserTable.getAllMappings());
-
+ assertNull("No mappings", virtualUserTable.getAllMappings());
+
try {
-
- assertTrue("Add mapping",addMapping(VirtualUserTable.WILDCARD, aliasDomain, user2 + "@" + domain, ADDRESS_TYPE));
+
+ assertTrue("Add mapping", addMapping(VirtualUserTable.WILDCARD, aliasDomain, user2 + "@" + domain, ADDRESS_TYPE));
assertTrue("Add aliasDomain mapping", addMapping(VirtualUserTable.WILDCARD, aliasDomain, domain, ALIASDOMAIN_TYPE));
Iterator<String> mappings = virtualUserTable.getMappings(user, aliasDomain).iterator();
@@ -291,7 +285,7 @@ public abstract class AbstractVirtualUse
protected abstract AbstractVirtualUserTable getVirtualUserTable() throws Exception;
- protected abstract boolean addMapping(String user , String domain, String mapping,int type) throws VirtualUserTableException;
+ protected abstract boolean addMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException;
protected abstract boolean removeMapping(String user, String domain, String mapping, int type) throws VirtualUserTableException;
Modified: james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/mock/MockVirtualUserTableManagementImpl.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/mock/MockVirtualUserTableManagementImpl.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/mock/MockVirtualUserTableManagementImpl.java (original)
+++ james/server/trunk/data-library/src/test/java/org/apache/james/vut/lib/mock/MockVirtualUserTableManagementImpl.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.vut.lib.mock;
import java.util.Collection;
@@ -31,27 +30,27 @@ import org.apache.james.vut.lib.VirtualU
public class MockVirtualUserTableManagementImpl implements VirtualUserTable {
HashMap store = new HashMap();
-
+
public void addAddressMapping(String user, String domain, String address) throws VirtualUserTableException {
- addRawMapping(user,domain,address);
+ addRawMapping(user, domain, address);
}
- public void addErrorMapping(String user, String domain, String error) throws VirtualUserTableException{
- addRawMapping(user,domain,VirtualUserTable.ERROR_PREFIX + error);
+ public void addErrorMapping(String user, String domain, String error) throws VirtualUserTableException {
+ addRawMapping(user, domain, VirtualUserTable.ERROR_PREFIX + error);
}
- public void addMapping(String user, String domain, String mapping) throws VirtualUserTableException{
- if (mapping.startsWith(VirtualUserTable.ERROR_PREFIX)){
- addErrorMapping(user,domain,mapping.substring(VirtualUserTable.ERROR_PREFIX.length()));
+ public void addMapping(String user, String domain, String mapping) throws VirtualUserTableException {
+ if (mapping.startsWith(VirtualUserTable.ERROR_PREFIX)) {
+ addErrorMapping(user, domain, mapping.substring(VirtualUserTable.ERROR_PREFIX.length()));
} else if (mapping.startsWith(VirtualUserTable.REGEX_PREFIX)) {
- addErrorMapping(user,domain,mapping.substring(VirtualUserTable.REGEX_PREFIX.length()));
+ addErrorMapping(user, domain, mapping.substring(VirtualUserTable.REGEX_PREFIX.length()));
} else {
- addAddressMapping(user,domain,mapping);
+ addAddressMapping(user, domain, mapping);
}
}
public void addRegexMapping(String user, String domain, String regex) throws VirtualUserTableException {
- addRawMapping(user,domain,VirtualUserTable.REGEX_PREFIX + regex);
+ addRawMapping(user, domain, VirtualUserTable.REGEX_PREFIX + regex);
}
public Map getAllMappings() throws VirtualUserTableException {
@@ -62,7 +61,7 @@ public class MockVirtualUserTableManagem
}
}
- public Collection getUserDomainMappings(String user, String domain) throws VirtualUserTableException{
+ public Collection getUserDomainMappings(String user, String domain) throws VirtualUserTableException {
String mapping = (String) store.get(user + "@" + domain);
if (mapping != null) {
return VirtualUserTableUtil.mappingToCollection(mapping);
@@ -72,39 +71,39 @@ public class MockVirtualUserTableManagem
}
public void removeAddressMapping(String user, String domain, String address) throws VirtualUserTableException {
- removeRawMapping(user,domain,address);
+ removeRawMapping(user, domain, address);
}
public void removeErrorMapping(String user, String domain, String error) throws VirtualUserTableException {
- removeRawMapping(user,domain,VirtualUserTable.ERROR_PREFIX + error);
+ removeRawMapping(user, domain, VirtualUserTable.ERROR_PREFIX + error);
}
- public void removeMapping(String user, String domain, String mapping) throws VirtualUserTableException{
- if (mapping.startsWith(VirtualUserTable.ERROR_PREFIX)){
- removeErrorMapping(user,domain,mapping.substring(VirtualUserTable.ERROR_PREFIX.length()));
+ public void removeMapping(String user, String domain, String mapping) throws VirtualUserTableException {
+ if (mapping.startsWith(VirtualUserTable.ERROR_PREFIX)) {
+ removeErrorMapping(user, domain, mapping.substring(VirtualUserTable.ERROR_PREFIX.length()));
} else if (mapping.startsWith(VirtualUserTable.REGEX_PREFIX)) {
- removeErrorMapping(user,domain,mapping.substring(VirtualUserTable.REGEX_PREFIX.length()));
+ removeErrorMapping(user, domain, mapping.substring(VirtualUserTable.REGEX_PREFIX.length()));
} else {
- removeAddressMapping(user,domain,mapping);
+ removeAddressMapping(user, domain, mapping);
}
}
- public void removeRegexMapping(String user, String domain, String regex) throws VirtualUserTableException {
- removeRawMapping(user,domain,VirtualUserTable.REGEX_PREFIX + regex);
+ public void removeRegexMapping(String user, String domain, String regex) throws VirtualUserTableException {
+ removeRawMapping(user, domain, VirtualUserTable.REGEX_PREFIX + regex);
}
- public Collection<String> getMappings(String user, String domain) throws ErrorMappingException, VirtualUserTableException{
+ public Collection<String> getMappings(String user, String domain) throws ErrorMappingException, VirtualUserTableException {
throw new UnsupportedOperationException("Not implemented yet");
}
-
- private void addRawMapping(String user,String domain, String mapping) throws VirtualUserTableException {
+
+ private void addRawMapping(String user, String domain, String mapping) throws VirtualUserTableException {
Collection map;
String key = user + "@" + domain;
String mappings = (String) store.get(key);
-
+
if (mappings != null) {
map = VirtualUserTableUtil.mappingToCollection(mappings);
-
+
if (map.contains(mapping)) {
throw new VirtualUserTableException("Mapping " + mapping + " already exist!");
} else {
@@ -115,8 +114,8 @@ public class MockVirtualUserTableManagem
store.put(key, mapping);
}
}
-
- private void removeRawMapping(String user,String domain, String mapping) throws VirtualUserTableException {
+
+ private void removeRawMapping(String user, String domain, String mapping) throws VirtualUserTableException {
Collection map;
String key = user + "@" + domain;
String mappings = (String) store.get(key);
@@ -129,12 +128,12 @@ public class MockVirtualUserTableManagem
throw new VirtualUserTableException("Mapping does not exist");
}
- public void addAliasDomainMapping(String aliasDomain, String realDomain) throws VirtualUserTableException {
- addRawMapping(null,aliasDomain,VirtualUserTable.ALIASDOMAIN_PREFIX + realDomain);
+ public void addAliasDomainMapping(String aliasDomain, String realDomain) throws VirtualUserTableException {
+ addRawMapping(null, aliasDomain, VirtualUserTable.ALIASDOMAIN_PREFIX + realDomain);
}
public void removeAliasDomainMapping(String aliasDomain, String realDomain) throws VirtualUserTableException {
- removeRawMapping(null,aliasDomain,VirtualUserTable.ALIASDOMAIN_PREFIX + realDomain);
+ removeRawMapping(null, aliasDomain, VirtualUserTable.ALIASDOMAIN_PREFIX + realDomain);
}
}
Modified: james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java (original)
+++ james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java Mon Apr 4 20:38:14 2011
@@ -23,13 +23,11 @@ import java.net.UnknownHostException;
import org.apache.james.dnsservice.api.mock.MockDNSService;
-
import junit.framework.TestCase;
/**
- * Basic tests for AbstractDNSServer.
- * The goal is to verify that the interface remains constants and
- * that the built platform has access to the Internet.
+ * Basic tests for AbstractDNSServer. The goal is to verify that the interface
+ * remains constants and that the built platform has access to the Internet.
*/
public class AbstractDNSServiceTest extends TestCase {
@@ -37,25 +35,25 @@ public class AbstractDNSServiceTest exte
* Simple Mock DNSService relaying on InetAddress.
*/
private static final DNSService DNS_SERVER = new MockDNSService() {
-
+
public String getHostName(InetAddress inet) {
return inet.getCanonicalHostName();
}
-
+
public InetAddress[] getAllByName(String name) throws UnknownHostException {
- return InetAddress.getAllByName(name);
+ return InetAddress.getAllByName(name);
}
public InetAddress getLocalHost() throws UnknownHostException {
return InetAddress.getLocalHost();
}
-
+
public InetAddress getByName(String host) throws UnknownHostException {
return InetAddress.getByName(host);
}
};
-
+
/**
* Simple localhost resolution.
*
@@ -63,14 +61,15 @@ public class AbstractDNSServiceTest exte
*/
public void testLocalhost() throws UnknownHostException {
- assertEquals("localhost/127.0.0.1", DNS_SERVER.getByName("localhost").toString());
-
- String localHost = DNS_SERVER.getHostName(InetAddress.getByName("127.0.0.1")).toString();
- // We only can check if the returned localhost is not empty. Its value depends on the hosts file.
- assertTrue(localHost.length() > 0);
-
+ assertEquals("localhost/127.0.0.1", DNS_SERVER.getByName("localhost").toString());
+
+ String localHost = DNS_SERVER.getHostName(InetAddress.getByName("127.0.0.1")).toString();
+ // We only can check if the returned localhost is not empty. Its value
+ // depends on the hosts file.
+ assertTrue(localHost.length() > 0);
+
}
-
+
/**
* Simple apache.org resolution.
*
@@ -79,5 +78,5 @@ public class AbstractDNSServiceTest exte
public void testApache() throws UnknownHostException {
assertEquals(true, DNS_SERVER.getByName("www.apache.org").toString().startsWith("www.apache.org"));
}
-
+
}
Modified: james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/mock/DNSFixture.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/mock/DNSFixture.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/mock/DNSFixture.java (original)
+++ james/server/trunk/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/mock/DNSFixture.java Mon Apr 4 20:38:14 2011
@@ -23,7 +23,6 @@ import java.net.UnknownHostException;
import org.apache.james.dnsservice.api.DNSService;
-
/**
* Some DNS Fixtures used by various Test related to DNS and InetNetwork.
*/
@@ -32,31 +31,31 @@ public class DNSFixture {
public static final String LOCALHOST_IP_V4_ADDRESS_0 = "localhost/16";
public static final String LOCALHOST_IP_V4_ADDRESS_1 = "172.16.0.0/16";
public static final String LOCALHOST_IP_V4_ADDRESS_2 = "192.168.1.0/255.255.255.0";
- public static final String[] LOCALHOST_IP_V4_ADDRESSES = new String[]{LOCALHOST_IP_V4_ADDRESS_0, LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_2};
- public static final String[] LOCALHOST_IP_V4_ADDRESSES_DUPLICATE = new String[]{LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_2, LOCALHOST_IP_V4_ADDRESS_2};
+ public static final String[] LOCALHOST_IP_V4_ADDRESSES = new String[] { LOCALHOST_IP_V4_ADDRESS_0, LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_2 };
+ public static final String[] LOCALHOST_IP_V4_ADDRESSES_DUPLICATE = new String[] { LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_1, LOCALHOST_IP_V4_ADDRESS_2, LOCALHOST_IP_V4_ADDRESS_2 };
public static final String LOCALHOST_IP_V6_ADDRESS_0 = "00:00:00:00:00:00:00:1";
public static final String LOCALHOST_IP_V6_ADDRESS_1 = "2781:0db8:1234:8612:45ee:0000:f05e:0001/48";
- public static final String[] LOCALHOST_IP_V6_ADDRESSES = new String[]{LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_1};
- public static final String[] LOCALHOST_IP_V6_ADDRESSES_DUPLICATE = new String[]{LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_1, LOCALHOST_IP_V6_ADDRESS_1};
-
+ public static final String[] LOCALHOST_IP_V6_ADDRESSES = new String[] { LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_1 };
+ public static final String[] LOCALHOST_IP_V6_ADDRESSES_DUPLICATE = new String[] { LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_0, LOCALHOST_IP_V6_ADDRESS_1, LOCALHOST_IP_V6_ADDRESS_1 };
+
/**
* A Mock DNS Server that handles IPv4-only InetAddress.
*/
public static final DNSService DNS_SERVER_IPV4_MOCK = new MockDNSService() {
-
+
public String getHostName(InetAddress inet) {
return "localhost";
}
-
+
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();
}
-
+
public InetAddress getByName(String host) throws UnknownHostException {
return InetAddress.getByName(host);
}
@@ -67,23 +66,23 @@ public class DNSFixture {
* A Mock DNS Server that handles IPv6-only InetAddress.
*/
public static final DNSService DNS_SERVER_IPV6_MOCK = new MockDNSService() {
-
+
public String getHostName(InetAddress inet) {
return "localhost";
}
-
+
public InetAddress[] getAllByName(String name) throws UnknownHostException {
- return new InetAddress[] { InetAddress.getByName("::1")};
+ return new InetAddress[] { InetAddress.getByName("::1") };
}
public InetAddress getLocalHost() throws UnknownHostException {
return InetAddress.getLocalHost();
}
-
+
public InetAddress getByName(String host) throws UnknownHostException {
return InetAddress.getByName(host);
}
};
-
+
}
Modified: james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java (original)
+++ james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java Mon Apr 4 20:38:14 2011
@@ -47,29 +47,28 @@ public class DNSJavaServiceTest extends
private Cache defaultCache;
private Resolver defaultResolver;
private Name[] defaultSearchPaths;
-
+
public void testNoMX() throws Exception {
dnsServer.setResolver(null);
dnsServer.setCache(new ZoneCache("dnstest.com."));
- //a.setSearchPath(new String[] { "searchdomain.com." });
+ // a.setSearchPath(new String[] { "searchdomain.com." });
Collection<String> records = dnsServer.findMXRecords("nomx.dnstest.com.");
assertEquals(1, records.size());
- assertEquals("nomx.dnstest.com.", records.iterator()
- .next());
+ assertEquals("nomx.dnstest.com.", records.iterator().next());
}
-
+
public void testBadMX() throws Exception {
dnsServer.setResolver(null);
dnsServer.setCache(new ZoneCache("dnstest.com."));
- //a.setSearchPath(new String[] { "searchdomain.com." });
+ // a.setSearchPath(new String[] { "searchdomain.com." });
Collection<String> records = dnsServer.findMXRecords("badmx.dnstest.com.");
assertEquals(1, records.size());
- assertEquals("badhost.dnstest.com.", records.iterator()
- .next());
- //Iterator<HostAddress> it = dnsServer.getSMTPHostAddresses("badmx.dnstest.com.");
- // assertFalse(it.hasNext());
+ assertEquals("badhost.dnstest.com.", records.iterator().next());
+ // Iterator<HostAddress> it =
+ // dnsServer.getSMTPHostAddresses("badmx.dnstest.com.");
+ // assertFalse(it.hasNext());
}
-
+
public void testINARecords() throws Exception {
// Zone z = loadZone("pippo.com.");
dnsServer.setResolver(null);
@@ -77,8 +76,7 @@ public class DNSJavaServiceTest extends
// dnsServer.setLookupper(new ZoneLookupper(z));
Collection<String> records = dnsServer.findMXRecords("www.pippo.com.");
assertEquals(1, records.size());
- assertEquals("pippo.com.inbound.mxlogic.net.", records.iterator()
- .next());
+ assertEquals("pippo.com.inbound.mxlogic.net.", records.iterator().next());
}
public void testMXCatches() throws Exception {
@@ -92,20 +90,18 @@ public class DNSJavaServiceTest extends
fail("MX Collection should not be modifiable");
} catch (UnsupportedOperationException e) {
}
- assertEquals(1,res.size());
- assertEquals("mail.test-zone.com.",res.iterator().next());
+ assertEquals(1, res.size());
+ assertEquals("mail.test-zone.com.", res.iterator().next());
}
/*
- public void testCNAMEasMXrecords() throws Exception {
- // Zone z = loadZone("brandilyncollins.com.");
- dnsServer.setResolver(null);
- dnsServer.setCache(new ZoneCache("brandilyncollins.com."));
- // dnsServer.setLookupper(new ZoneLookupper(z));
- //Iterator<HostAddress> records = dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
- //assertEquals(true, records.hasNext());
- }
-*/
+ * public void testCNAMEasMXrecords() throws Exception { // Zone z =
+ * loadZone("brandilyncollins.com."); dnsServer.setResolver(null);
+ * dnsServer.setCache(new ZoneCache("brandilyncollins.com.")); //
+ * dnsServer.setLookupper(new ZoneLookupper(z)); //Iterator<HostAddress>
+ * records = dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
+ * //assertEquals(true, records.hasNext()); }
+ */
protected void setUp() throws Exception {
dnsServer = new TestableDNSServer();
DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
@@ -114,8 +110,7 @@ public class DNSJavaServiceTest extends
dnsServer.setLog(LoggerFactory.getLogger("MockLog"));
dnsServer.configure(db);
dnsServer.init();
-
-
+
defaultCache = Lookup.getDefaultCache(DClass.IN);
defaultResolver = Lookup.getDefaultResolver();
defaultSearchPaths = Lookup.getDefaultSearchPath();
@@ -137,14 +132,14 @@ public class DNSJavaServiceTest extends
URL zoneResource = getClass().getResource(zoneFilename);
assertNotNull("test resource for zone could not be loaded: " + zoneFilename, zoneResource);
String zoneFile = zoneResource.getFile();
- Zone zone = new Zone(Name.fromString(zoneName),zoneFile);
+ Zone zone = new Zone(Name.fromString(zoneName), zoneFile);
return zone;
}
private final class ZoneCache extends Cache {
Zone z = null;
-
+
public ZoneCache(String string) throws IOException {
z = loadZone(string);
}
@@ -210,9 +205,9 @@ public class DNSJavaServiceTest extends
}
public SetResponse lookupRecords(Name arg0, int arg1, int arg2) {
- System.out.println("Cache.lookupRecords "+arg0+","+arg1+","+arg2);
+ System.out.println("Cache.lookupRecords " + arg0 + "," + arg1 + "," + arg2);
return z.findRecords(arg0, arg1);
- //return super.lookupRecords(arg0, arg1, arg2);
+ // return super.lookupRecords(arg0, arg1, arg2);
}
public void setCleanInterval(int arg0) {
@@ -233,7 +228,7 @@ public class DNSJavaServiceTest extends
}
private final class TestableDNSServer extends DNSJavaService {
-
+
public void setResolver(Resolver r) {
resolver = r;
}
@@ -241,11 +236,11 @@ public class DNSJavaServiceTest extends
public Resolver getResolver() {
return resolver;
}
-
+
public void setCache(Cache c) {
cache = c;
}
-
+
public Cache getCache() {
return cache;
}
Modified: james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java (original)
+++ james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/InetNetworkBuilderTest.java Mon Apr 4 20:38:14 2011
@@ -30,42 +30,42 @@ import org.apache.james.dnsservice.libra
* Test the InetNetworkBuilder.
*/
public class InetNetworkBuilderTest extends TestCase {
-
+
private InetNetworkBuilder inetNetworkBuilder;
private InetNetwork inetNetwork;
-
+
/**
* Verify that InetNetworkBuild return correctly initialized Inet4Network.
*
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testInetNetworkBuilderDnsV4() throws UnknownHostException {
-
+
inetNetworkBuilder = new InetNetworkBuilder(DNSFixture.DNS_SERVER_IPV4_MOCK);
-
+
inetNetwork = inetNetworkBuilder.getFromString(DNSFixture.LOCALHOST_IP_V4_ADDRESS_0);
assertEquals("127.0.0.0/255.255.0.0", inetNetwork.toString());
-
+
inetNetwork = inetNetworkBuilder.getFromString(DNSFixture.LOCALHOST_IP_V4_ADDRESS_1);
assertEquals("172.16.0.0/255.255.0.0", inetNetwork.toString());
-
+
}
/**
* Verify that InetNetworkBuild return correctly initialized Inet6Network.
*
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testInetNetworkBuilderDnsV6() throws UnknownHostException {
-
+
inetNetworkBuilder = new InetNetworkBuilder(DNSFixture.DNS_SERVER_IPV6_MOCK);
-
+
inetNetwork = inetNetworkBuilder.getFromString(DNSFixture.LOCALHOST_IP_V6_ADDRESS_0);
assertEquals("0:0:0:0:0:0:0:1/32768", inetNetwork.toString());
-
+
inetNetwork = inetNetworkBuilder.getFromString(DNSFixture.LOCALHOST_IP_V6_ADDRESS_1);
assertEquals("2781:db8:1234:0:0:0:0:0/48", inetNetwork.toString());
-
+
}
}
Modified: james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java (original)
+++ james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java Mon Apr 4 20:38:14 2011
@@ -30,8 +30,7 @@ import org.apache.james.dnsservice.libra
import junit.framework.TestCase;
/**
- * Test the InetNetwork class with various IPv4 and IPv6
- * network specification.
+ * Test the InetNetwork class with various IPv4 and IPv6 network specification.
*/
public class InetNetworkTest extends TestCase {
@@ -39,36 +38,36 @@ public class InetNetworkTest extends Tes
private static InetAddress subnetmask4;
private static Inet4Network network4;
-
+
private static Integer subnetmask6;
private static Inet6Network network6;
-
+
/**
- * Preliminary test method to validate the InetAddress behaviour
- * (V4 and V6 name and address).
+ * Preliminary test method to validate the InetAddress behaviour (V4 and V6
+ * name and address).
*
* The InetAddress.toString() returns a string with format
- * "name/ip_address". It has no indication of subnetmask.
- * The name is optional.
+ * "name/ip_address". It has no indication of subnetmask. The name is
+ * optional.
*
* @throws UnknownHostException
*/
public void testInetAddress() throws UnknownHostException {
- // Test name alone (can be IPv4 or IPv6 depending on the OS plaform configuration).
+ // Test name alone (can be IPv4 or IPv6 depending on the OS plaform
+ // configuration).
address = InetAddress.getByName("localhost");
assertEquals(true, address instanceof InetAddress);
assertEquals(true, address.toString().contains("localhost"));
-
+
}
-
+
/**
- * Test method to validate the Inet4Address behavior
- * (name and address).
+ * Test method to validate the Inet4Address behavior (name and address).
*
* The InetAddress.toString() returns a string with format
- * "name/ip_address". It has no indication of subnetmask.
- * The returned name is optional.
+ * "name/ip_address". It has no indication of subnetmask. The returned name
+ * is optional.
*
* @throws UnknownHostException
*/
@@ -81,32 +80,31 @@ public class InetNetworkTest extends Tes
} catch (UnknownHostException e) {
assertTrue(true);
}
-
+
// Test IP V4 address.
address = InetAddress.getByAddress(getBytesFromAddress("127.0.0.1"));
assertEquals(true, address instanceof Inet4Address);
assertEquals(true, address.toString().contains("/127.0.0.1"));
-
+
// Test IP V4 with 255 values (just 'like' a subnet mask).
address = InetAddress.getByAddress(getBytesFromAddress("255.255.225.0"));
assertEquals(true, address instanceof Inet4Address);
assertEquals(true, address.toString().contains("/255.255.225.0"));
-
+
// Test IP V4 Address with name and IP address.
address = InetAddress.getByAddress("localhost", getBytesFromAddress("127.0.0.1"));
assertEquals(true, address instanceof Inet4Address);
assertEquals(true, address.toString().contains("localhost"));
assertEquals(true, address.toString().contains("/127.0.0.1"));
-
+
}
-
+
/**
- * Test method to validate the Inet6Address behavior
- * (name and address).
+ * Test method to validate the Inet6Address behavior (name and address).
*
* The InetAddress.toString() returns a string with format
- * "name/ip_address". It has no indication of subnetmask.
- * The returned name is optional.
+ * "name/ip_address". It has no indication of subnetmask. The returned name
+ * is optional.
*
* @throws UnknownHostException
*/
@@ -119,23 +117,23 @@ public class InetNetworkTest extends Tes
} catch (UnknownHostException e) {
assertTrue(true);
}
-
+
// Test IP V6 address.
address = InetAddress.getByAddress(getBytesFromAddress("0000:0000:0000:0000:0000:0000:0000:0001"));
assertEquals(true, address instanceof Inet6Address);
assertEquals(true, address.toString().contains("/0:0:0:0:0:0:0:1"));
-
+
// Test IP V6 Address with name and IP address.
address = InetAddress.getByAddress("localhost", getBytesFromAddress("0000:0000:0000:0000:0000:0000:0000:0001"));
assertEquals(true, address instanceof Inet6Address);
assertEquals(true, address.toString().contains("localhost"));
assertEquals(true, address.toString().contains("/0:0:0:0:0:0:0:1"));
-
+
}
-
+
/**
- * Test the Inet4Network.
- *
+ * Test the Inet4Network.
+ *
* @throws UnknownHostException
*/
public void testInet4Network() throws UnknownHostException {
@@ -156,10 +154,10 @@ public class InetNetworkTest extends Tes
assertEquals("127.0.0.0/255.255.255.0", network4.toString());
}
-
+
/**
- * Test the Inet6Network.
- *
+ * Test the Inet6Network.
+ *
* @throws UnknownHostException
*/
public void testInet6Network() throws UnknownHostException {
@@ -172,71 +170,72 @@ public class InetNetworkTest extends Tes
} catch (NullPointerException e) {
assertTrue(true);
}
-
+
// Test IP V6 with subnet mask 32768.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 32768;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2781:db8:1234:8612:45ee:0:f05e:1/32768", network6.toString());
-
+
// Test IP V6 with subnet mask 128.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 128;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2781:db8:1234:8612:0:0:0:0/128", network6.toString());
-
+
// Test IP V6 with subnet mask 48.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 48;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2781:db8:1234:0:0:0:0:0/48", network6.toString());
-
+
// Test IP V6 with subnet mask 16.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 16;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2781:db8:1200:0:0:0:0:0/16", network6.toString());
-
+
// Test IP V6 with subnet mask 2.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 2;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2781:0:0:0:0:0:0:0/2", network6.toString());
-
+
// Test IP V6 with subnet mask 1.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 1;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("2700:0:0:0:0:0:0:0/1", network6.toString());
-
+
// Test IP V6 with subnet mask 0.
address = InetAddress.getByAddress(getBytesFromAddress("2781:0db8:1234:8612:45ee:0000:f05e:0001"));
subnetmask6 = 0;
network6 = new Inet6Network(address, subnetmask6);
assertEquals("0:0:0:0:0:0:0:0/0", network6.toString());
-
+
}
-
+
/**
- * Returns the bytes representation of an IP address.<br/>
- * <br/>
- * The address must respect "xyz.xyz.xyz.xyz" format for IP V4
- * ("127.0.0.1", "172.16.1.38",..)
+ * Returns the bytes representation of an IP address.<br>
+ * <br>
+ * The address must respect "xyz.xyz.xyz.xyz" format for IP V4 ("127.0.0.1",
+ * "172.16.1.38",..)
*
- * or wxyz:wxyz:wxyz:wxyz:wxyz:wxyz:wxyz:wxyz for IP V6
- * ("0000:0000:0000:0000:0000:0000:0000:0001"
+ * or wxyz:wxyz:wxyz:wxyz:wxyz:wxyz:wxyz:wxyz for IP V6 <br>
+ * ("0000:0000:0000:0000:0000:0000:0000:0001"<br>
* or "2001:0db8:85a3:0000:0000:8a2e:0370:7334").
*
- * @param the ip address as a string.
+ * @param the
+ * ip address as a string.
* @return the byte array representation of the ip address.
*/
private byte[] getBytesFromAddress(String address) {
-
+
if (address.contains(".")) {
StringTokenizer st = new StringTokenizer(address, ".");
byte[] bytes = new byte[st.countTokens()];
- int i=0;
- while (st.hasMoreTokens()) {
+ int i = 0;
+ while (st.hasMoreTokens()) {
Integer inb = Integer.parseInt(st.nextToken());
bytes[i] = inb.byteValue();
i++;
@@ -247,8 +246,8 @@ public class InetNetworkTest extends Tes
else if (address.contains(":")) {
StringTokenizer st = new StringTokenizer(address, ":");
byte[] bytes = new byte[st.countTokens() * 2];
- int i=0;
- while (st.hasMoreTokens()) {
+ int i = 0;
+ while (st.hasMoreTokens()) {
String token = st.nextToken();
bytes[i] = (byte) Integer.parseInt(token.substring(0, 2), 16);
i++;
@@ -257,9 +256,9 @@ public class InetNetworkTest extends Tes
}
return bytes;
}
-
+
throw new IllegalArgumentException("The address [" + address + "] is not of the correct format. It should at least contain a . or a :");
-
+
}
}
Modified: james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java (original)
+++ james/server/trunk/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java Mon Apr 4 20:38:14 2011
@@ -27,7 +27,7 @@ import org.apache.james.dnsservice.libra
/**
* Test the NetMatcher class with various IPv4 and IPv6 parameters.
- *
+ *
*/
public class NetMatcherTest extends TestCase {
@@ -35,7 +35,7 @@ public class NetMatcherTest extends Test
*
*/
private static NetMatcher netMatcher;
-
+
/**
*
*/
@@ -43,7 +43,7 @@ public class NetMatcherTest extends Test
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV4_MOCK);
assertEquals("[172.16.0.0/255.255.0.0, 192.168.1.0/255.255.255.0]", netMatcher.toString());
}
-
+
/**
*
*/
@@ -51,65 +51,65 @@ public class NetMatcherTest extends Test
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV6_MOCK);
assertEquals("[0:0:0:0:0:0:0:1/32768, 2781:db8:1234:0:0:0:0:0/48]", netMatcher.toString());
}
-
+
/**
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testIpV4Matcher() throws UnknownHostException {
-
+
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
-
+
assertEquals(true, netMatcher.matchInetNetwork("127.0.0.1"));
assertEquals(true, netMatcher.matchInetNetwork("localhost"));
assertEquals(true, netMatcher.matchInetNetwork("172.16.15.254"));
assertEquals(true, netMatcher.matchInetNetwork("192.168.1.254"));
assertEquals(false, netMatcher.matchInetNetwork("192.169.1.254"));
-
+
}
/**
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testIpV4MatcherWithIpV6() throws UnknownHostException {
-
+
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
-
+
assertEquals(false, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0"));
assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1"));
assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2"));
assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001"));
assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001"));
-
+
}
/**
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testIpV6Matcher() throws UnknownHostException {
-
+
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
-
+
assertEquals(true, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0"));
assertEquals(true, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1"));
assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2"));
assertEquals(true, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001"));
assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001"));
-
+
}
/**
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
public void testIpV6MatcherWithIpV4() throws UnknownHostException {
-
+
netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
-
+
assertEquals(false, netMatcher.matchInetNetwork("127.0.0.1"));
assertEquals(false, netMatcher.matchInetNetwork("localhost"));
assertEquals(false, netMatcher.matchInetNetwork("172.16.15.254"));
assertEquals(false, netMatcher.matchInetNetwork("192.168.1.254"));
assertEquals(false, netMatcher.matchInetNetwork("192.169.1.254"));
-
+
}
}
Modified: james/server/trunk/file/src/test/java/org/apache/james/domainlist/xml/XMLDomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/test/java/org/apache/james/domainlist/xml/XMLDomainListTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/file/src/test/java/org/apache/james/domainlist/xml/XMLDomainListTest.java (original)
+++ james/server/trunk/file/src/test/java/org/apache/james/domainlist/xml/XMLDomainListTest.java Mon Apr 4 20:38:14 2011
@@ -17,9 +17,6 @@
* under the License. *
****************************************************************/
-
-
-
package org.apache.james.domainlist.xml;
import java.net.InetAddress;
@@ -37,28 +34,28 @@ import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
public class XMLDomainListTest extends TestCase {
-
- private HierarchicalConfiguration setUpConfiguration(boolean auto,boolean autoIP, List<String> names) {
+
+ private HierarchicalConfiguration setUpConfiguration(boolean auto, boolean autoIP, List<String> names) {
DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder();
configuration.addProperty("autodetect", auto);
configuration.addProperty("autodetectIP", autoIP);
- for (int i= 0; i< names.size(); i++) {
+ for (int i = 0; i < names.size(); i++) {
configuration.addProperty("domainnames.domainname", names.get(i).toString());
}
return configuration;
}
-
+
private DNSService setUpDNSServer(final String hostName) {
DNSService dns = new MockDNSService() {
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();
}
@@ -66,8 +63,6 @@ public class XMLDomainListTest extends T
return dns;
}
-
-
// See https://issues.apache.org/jira/browse/JAMES-998
public void testNoConfiguredDomains() throws Exception {
List<String> domains = new ArrayList<String>();
@@ -83,37 +78,37 @@ public class XMLDomainListTest extends T
List<String> domains = new ArrayList<String>();
domains.add("domain1.");
domains.add("domain2.");
-
+
XMLDomainList dom = new XMLDomainList();
dom.setLog(LoggerFactory.getLogger("MockLog"));
- dom.configure(setUpConfiguration(false,false,domains));
+ dom.configure(setUpConfiguration(false, false, domains));
dom.setDNSService(setUpDNSServer("localhost"));
-
- assertTrue("Two domain found",dom.getDomains().length ==2);
+
+ assertTrue("Two domain found", dom.getDomains().length == 2);
}
-
+
public void testGetDomainsAutoDetectNotLocalHost() throws Exception {
List<String> domains = new ArrayList<String>();
domains.add("domain1.");
-
+
XMLDomainList dom = new XMLDomainList();
dom.setLog(LoggerFactory.getLogger("MockLog"));
- dom.configure(setUpConfiguration(true,false,domains));
+ dom.configure(setUpConfiguration(true, false, domains));
dom.setDNSService(setUpDNSServer("local"));
- assertEquals("Two domains found",dom.getDomains().length, 2);
+ assertEquals("Two domains found", dom.getDomains().length, 2);
}
-
+
public void testGetDomainsAutoDetectLocalHost() throws Exception {
List<String> domains = new ArrayList<String>();
domains.add("domain1.");
-
+
XMLDomainList dom = new XMLDomainList();
dom.setLog(LoggerFactory.getLogger("MockLog"));
- dom.configure(setUpConfiguration(true,false,domains));
+ dom.configure(setUpConfiguration(true, false, domains));
dom.setDNSService(setUpDNSServer("localhost"));
-
- assertEquals("One domain found",dom.getDomains().length, 1);
+
+ assertEquals("One domain found", dom.getDomains().length, 1);
}
}
Modified: james/server/trunk/file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java (original)
+++ james/server/trunk/file/src/test/java/org/apache/james/mailrepository/FileMailRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.mailrepository;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
@@ -35,17 +34,16 @@ public class FileMailRepositoryTest exte
* @throws Exception
*/
protected MailRepository getMailRepository() throws Exception {
- MockFileSystem fs = new MockFileSystem();
+ MockFileSystem fs = new MockFileSystem();
FileMailRepository mr = new FileMailRepository();
mr.setFileSystem(fs);
mr.setLog(LoggerFactory.getLogger("MockLog"));
DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
- defaultConfiguration.addProperty( "[@destinationURL]","file://target/var/mr");
- defaultConfiguration.addProperty( "[@type]","MAIL");
+ defaultConfiguration.addProperty("[@destinationURL]", "file://target/var/mr");
+ defaultConfiguration.addProperty("[@type]", "MAIL");
mr.configure(defaultConfiguration);
mr.init();
return mr;
}
}
-
Modified: james/server/trunk/file/src/test/java/org/apache/james/mailrepository/MBoxMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/test/java/org/apache/james/mailrepository/MBoxMailRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/file/src/test/java/org/apache/james/mailrepository/MBoxMailRepositoryTest.java (original)
+++ james/server/trunk/file/src/test/java/org/apache/james/mailrepository/MBoxMailRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.mailrepository;
import java.io.File;
@@ -32,53 +31,51 @@ import org.apache.james.mailrepository.f
import org.slf4j.LoggerFactory;
/**
- * NOTE this test *WAS* disabled because MBoxMailRepository does not
- * currently support most simple operations for the MailRepository interface.
+ * NOTE this test *WAS* disabled because MBoxMailRepository does not currently
+ * support most simple operations for the MailRepository interface.
*
* NOTE this previously extended AbstractMailRepositoryTest to run all of the
* common mail repository tests on the MBox implementation.
*/
public class MBoxMailRepositoryTest extends TestCase {
-
- protected MailRepository getMailRepository() throws Exception {
+ protected MailRepository getMailRepository() throws Exception {
MBoxMailRepository mr = new MBoxMailRepository();
DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
-
+
File fInbox = new MockFileSystem().getFile("file://conf/org/apache/james/mailrepository/testdata/Inbox");
- String mboxPath = "mbox://"+fInbox.toURI().toString().substring(new File("").toURI().toString().length());
-
- defaultConfiguration.addProperty("[@destinationURL]",mboxPath);
- defaultConfiguration.addProperty("[@type]","MAIL");
- mr.setLog(LoggerFactory.getLogger("MockLog"));;
+ String mboxPath = "mbox://" + fInbox.toURI().toString().substring(new File("").toURI().toString().length());
+
+ defaultConfiguration.addProperty("[@destinationURL]", mboxPath);
+ defaultConfiguration.addProperty("[@type]", "MAIL");
+ mr.setLog(LoggerFactory.getLogger("MockLog"));
+ ;
mr.configure(defaultConfiguration);
return mr;
}
- // Try to write a unit test for JAMES-744. At the moment it seems that we cannot reproduce it.
+ // Try to write a unit test for JAMES-744. At the moment it seems that we
+ // cannot reproduce it.
public void testReadMboxrdFile() throws Exception {
MailRepository mr = getMailRepository();
-
+
Iterator<String> keys = mr.list();
-
+
assertTrue("Two messages in list", keys.hasNext());
keys.next();
-
+
assertTrue("One messages in list", keys.hasNext());
keys.next();
-
+
assertFalse("No messages", keys.hasNext());
}
/*
- public void runBare() throws Throwable {
- System.err.println("TEST DISABLED!");
- // Decomment this or remove this method to re-enable the MBoxRepository testing
- // super.runBare();
- }
- */
+ * public void runBare() throws Throwable {
+ * System.err.println("TEST DISABLED!"); // Decomment this or remove this
+ * method to re-enable the MBoxRepository testing // super.runBare(); }
+ */
}
-
Modified: james/server/trunk/file/src/test/java/org/apache/james/user/file/UsersFileRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/test/java/org/apache/james/user/file/UsersFileRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/file/src/test/java/org/apache/james/user/file/UsersFileRepositoryTest.java (original)
+++ james/server/trunk/file/src/test/java/org/apache/james/user/file/UsersFileRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -40,7 +40,7 @@ import org.apache.mailet.MailAddress;
import org.slf4j.LoggerFactory;
/**
- * Test basic behaviours of UsersFileRepository
+ * Test basic behaviors of UsersFileRepository
*/
public class UsersFileRepositoryTest extends AbstractUsersRepositoryTest {
@@ -48,7 +48,7 @@ public class UsersFileRepositoryTest ext
* Create the repository to be tested.
*
* @return the user repository
- * @throws Exception
+ * @throws Exception
*/
protected UsersRepository getUsersRepository() throws Exception {
FileSystem fs = new FileSystem() {
@@ -58,21 +58,19 @@ public class UsersFileRepositoryTest ext
}
public InputStream getResource(String url) throws IOException {
- return new FileInputStream(getFile(url));
+ return new FileInputStream(getFile(url));
}
public File getFile(String fileURL) throws FileNotFoundException {
return new File(fileURL.substring(FileSystem.FILE_PROTOCOL.length()));
}
-
+
};
-
+
DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder("test");
configuration.addProperty("destination.[@URL]", "file://target/var/users");
-
- UsersFileRepository res = new UsersFileRepository();
-
+ UsersFileRepository res = new UsersFileRepository();
res.setFileSystem(fs);
res.setLog(LoggerFactory.getLogger("MockLog"));
@@ -90,45 +88,43 @@ public class UsersFileRepositoryTest ext
LifecycleUtil.dispose(this.usersRepository);
}
}
-
+
public void testVirtualUserTableImpl() throws Exception {
String username = "test";
String password = "pass";
String alias = "alias";
String domain = "localhost";
String forward = "forward@somewhere";
-
+
UsersFileRepository repos = (UsersFileRepository) getUsersRepository();
repos.setEnableAliases(true);
repos.setEnableForwarding(true);
- repos.addUser(username,password);
-
- JamesUser user = (JamesUser)repos.getUserByName(username);
+ repos.addUser(username, password);
+
+ JamesUser user = (JamesUser) repos.getUserByName(username);
user.setAlias(alias);
repos.updateUser(user);
-
+
Collection<String> map = ((VirtualUserTable) repos).getMappings(username, domain);
assertNull("No mapping", map);
-
+
user.setAliasing(true);
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
assertEquals("One mapping", 1, map.size());
assertEquals("Alias found", map.iterator().next().toString(), alias + "@" + domain);
-
-
+
user.setForwardingDestination(new MailAddress(forward));
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
assertTrue("One mapping", map.size() == 1);
assertEquals("Alias found", map.iterator().next().toString(), alias + "@" + domain);
-
-
+
user.setForwarding(true);
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
Iterator<String> mappings = map.iterator();
- assertTrue("Two mapping",map.size() == 2);
+ assertTrue("Two mapping", map.size() == 2);
assertEquals("Alias found", mappings.next().toString(), alias + "@" + domain);
assertEquals("Forward found", mappings.next().toString(), forward);
}
Modified: james/server/trunk/file/src/test/java/org/apache/james/vut/file/XMLVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/test/java/org/apache/james/vut/file/XMLVirtualUserTableTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/file/src/test/java/org/apache/james/vut/file/XMLVirtualUserTableTest.java (original)
+++ james/server/trunk/file/src/test/java/org/apache/james/vut/file/XMLVirtualUserTableTest.java Mon Apr 4 20:38:14 2011
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
public class XMLVirtualUserTableTest extends AbstractVirtualUserTableTest {
private DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
-
+
@Override
protected void setUp() throws Exception {
defaultConfiguration.setDelimiterParsingDisabled(true);
@@ -49,10 +49,11 @@ public class XMLVirtualUserTableTest ext
virtualUserTable.setLog(LoggerFactory.getLogger("MockLog"));
return virtualUserTable;
}
-
+
/**
- * @throws VirtualUserTableException
- * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#addMapping(java.lang.String, java.lang.String, java.lang.String, int)
+ * @throws VirtualUserTableException
+ * @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 {
@@ -61,79 +62,80 @@ public class XMLVirtualUserTableTest ext
if (mappings == null) {
mappings = new ArrayList<String>();
} else {
- removeMappingsFromConfig(user,domain,mappings);
+ removeMappingsFromConfig(user, domain, mappings);
}
-
+
if (type == ERROR_TYPE) {
mappings.add(VirtualUserTable.ERROR_PREFIX + mapping);
} else if (type == REGEX_TYPE) {
mappings.add(VirtualUserTable.REGEX_PREFIX + mapping);
} else if (type == ADDRESS_TYPE) {
mappings.add(mapping);
- } else if (type == ALIASDOMAIN_TYPE) {
+ } else if (type == ALIASDOMAIN_TYPE) {
mappings.add(VirtualUserTable.ALIASDOMAIN_PREFIX + mapping);
}
-
- if (mappings.size() > 0) {
- defaultConfiguration.addProperty("mapping",user + "@" + domain + "=" + VirtualUserTableUtil.CollectionToMapping(mappings));
+
+ if (mappings.size() > 0) {
+ defaultConfiguration.addProperty("mapping", user + "@" + domain + "=" + VirtualUserTableUtil.CollectionToMapping(mappings));
}
-
+
try {
virtualUserTable.configure(defaultConfiguration);
- } catch (Exception e) {
+ } catch (Exception e) {
if (mappings.size() > 0) {
return false;
} else {
return true;
}
}
-
+
return true;
-
+
}
/**
- * @throws VirtualUserTableException
- * @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#removeMapping(java.lang.String, java.lang.String, java.lang.String, int)
+ * @throws VirtualUserTableException
+ * @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 {
Collection<String> mappings = virtualUserTable.getUserDomainMappings(user, domain);
-
+
if (mappings == null) {
return false;
}
-
- removeMappingsFromConfig(user,domain, mappings);
-
+
+ removeMappingsFromConfig(user, domain, mappings);
+
if (type == ERROR_TYPE) {
mappings.remove(VirtualUserTable.ERROR_PREFIX + mapping);
} else if (type == REGEX_TYPE) {
mappings.remove(VirtualUserTable.REGEX_PREFIX + mapping);
} else if (type == ADDRESS_TYPE) {
- mappings.remove(mapping);
- } else if (type == ALIASDOMAIN_TYPE) {
+ mappings.remove(mapping);
+ } else if (type == ALIASDOMAIN_TYPE) {
mappings.remove(VirtualUserTable.ALIASDOMAIN_PREFIX + mapping);
}
if (mappings.size() > 0) {
- defaultConfiguration.addProperty("mapping",user + "@" + domain +"=" + VirtualUserTableUtil.CollectionToMapping(mappings));
- }
-
+ defaultConfiguration.addProperty("mapping", user + "@" + domain + "=" + VirtualUserTableUtil.CollectionToMapping(mappings));
+ }
+
try {
virtualUserTable.configure(defaultConfiguration);
- } catch (Exception e) {
- if (mappings.size() > 0) {
- return false;
- } else {
- return true;
- }
+ } catch (Exception e) {
+ if (mappings.size() > 0) {
+ return false;
+ } else {
+ return true;
+ }
}
-
+
return true;
}
-
+
@SuppressWarnings("unchecked")
private void removeMappingsFromConfig(String user, String domain, Collection<String> mappings) {
List<String> confs = defaultConfiguration.getList("mapping");
@@ -141,8 +143,8 @@ public class XMLVirtualUserTableTest ext
for (int i = 0; i < confs.size(); i++) {
String c = confs.get(i);
String mapping = user + "@" + domain + "=" + VirtualUserTableUtil.CollectionToMapping(mappings);
-
- if (!c.equalsIgnoreCase(mapping)){
+
+ if (!c.equalsIgnoreCase(mapping)) {
stored.add(c);
}
}
Modified: james/server/trunk/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java
URL: http://svn.apache.org/viewvc/james/server/trunk/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java (original)
+++ james/server/trunk/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java Mon Apr 4 20:38:14 2011
@@ -43,21 +43,21 @@ public class MockFileSystem implements F
try {
if (fileURL.startsWith("file://")) {
if (fileURL.startsWith("file://conf/")) {
- URL url = MockFileSystem.class.getClassLoader().getResource("./"+fileURL.substring(12));
+ URL url = MockFileSystem.class.getClassLoader().getResource("./" + fileURL.substring(12));
try {
- return new File(new URI(url.toString()));
- } catch (URISyntaxException e) {
- throw new FileNotFoundException("Unable to load file");
- }
+ return new File(new URI(url.toString()));
+ } catch (URISyntaxException e) {
+ throw new FileNotFoundException("Unable to load file");
+ }
// return new File("./src"+fileURL.substring(6));
} else {
return new File(fileURL.substring(FileSystem.FILE_PROTOCOL.length()));
}
} else {
- throw new UnsupportedOperationException("getFile: "+fileURL);
+ throw new UnsupportedOperationException("getFile: " + fileURL);
}
} catch (NullPointerException npe) {
- throw new FileNotFoundException("NPE on: "+fileURL);
+ throw new FileNotFoundException("NPE on: " + fileURL);
}
}
}
Modified: james/server/trunk/jcr/src/test/java/org/apache/james/user/jcr/JcrUserRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jcr/src/test/java/org/apache/james/user/jcr/JcrUserRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jcr/src/test/java/org/apache/james/user/jcr/JcrUserRepositoryTest.java (original)
+++ james/server/trunk/jcr/src/test/java/org/apache/james/user/jcr/JcrUserRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -34,7 +34,7 @@ public class JcrUserRepositoryTest exten
private static final String JACKRABBIT_HOME = "target/jackrabbit";
private RepositoryImpl repository;
-
+
protected UsersRepository getUsersRepository() throws Exception {
JCRUsersRepository repos = new JCRUsersRepository();
repos.setRepository(repository);
@@ -62,7 +62,7 @@ public class JcrUserRepositoryTest exten
for (int i = 0; i < contents.length; i++) {
delete(contents[i]);
}
- }
+ }
file.delete();
}
Modified: james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java (original)
+++ james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCDBFileMailRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.mailrepository.jdbc;
public class JDBCDBFileMailRepositoryTest extends JDBCMailRepositoryTest {
@@ -27,4 +26,3 @@ public class JDBCDBFileMailRepositoryTes
}
}
-
Modified: james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java (original)
+++ james/server/trunk/jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.mailrepository.jdbc;
import javax.sql.DataSource;
@@ -40,14 +39,14 @@ public class JDBCMailRepositoryTest exte
* @throws Exception
*/
protected MailRepository getMailRepository() throws Exception {
- MockFileSystem fs = new MockFileSystem();
+ MockFileSystem fs = new MockFileSystem();
DataSource datasource = getDataSource();
JDBCMailRepository mr = new JDBCMailRepository();
-
+
DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
- defaultConfiguration.addProperty("[@destinationURL]","db://maildb/mr/testrepo");
- defaultConfiguration.addProperty("sqlFile","file://conf/sqlResources.xml");
- defaultConfiguration.addProperty("[@type]","MAIL");
+ defaultConfiguration.addProperty("[@destinationURL]", "db://maildb/mr/testrepo");
+ defaultConfiguration.addProperty("sqlFile", "file://conf/sqlResources.xml");
+ defaultConfiguration.addProperty("[@type]", "MAIL");
mr.setFileSystem(fs);
mr.setDatasource(datasource);
mr.setLog(LoggerFactory.getLogger("MockLog"));
@@ -55,12 +54,11 @@ public class JDBCMailRepositoryTest exte
mr.init();
return mr;
}
-
+
protected String getType() {
return "db";
}
-
-
+
private BasicDataSource getDataSource() {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(EmbeddedDriver.class.getName());
@@ -71,4 +69,3 @@ public class JDBCMailRepositoryTest exte
}
}
-
Modified: james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java (original)
+++ james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -37,7 +37,7 @@ import java.util.Iterator;
import javax.sql.DataSource;
/**
- * Test basic behaviours of UsersFileRepository
+ * Test basic behaviors of UsersFileRepository
*/
public class DefaultUsersJdbcRepositoryTest extends AbstractUsersRepositoryTest {
@@ -45,7 +45,7 @@ public class DefaultUsersJdbcRepositoryT
* Create the repository to be tested.
*
* @return the user repository
- * @throws Exception
+ * @throws Exception
*/
protected UsersRepository getUsersRepository() throws Exception {
DefaultUsersJdbcRepository res = new DefaultUsersJdbcRepository();
@@ -62,19 +62,18 @@ public class DefaultUsersJdbcRepositoryT
*/
protected void configureAbstractJdbcUsersRepository(AbstractJdbcUsersRepository res, String tableString) throws Exception, ConfigurationException {
res.setFileSystem(new MockFileSystem());
- DataSource dataSource = getDataSource();
-
- res.setDatasource(dataSource );
-
+ DataSource dataSource = getDataSource();
+
+ res.setDatasource(dataSource);
+
DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder();
- configuration.addProperty("[@destinationURL]", "db://maildb/"+tableString);
- configuration.addProperty("sqlFile","file://conf/sqlResources.xml");
+ configuration.addProperty("[@destinationURL]", "db://maildb/" + tableString);
+ configuration.addProperty("sqlFile", "file://conf/sqlResources.xml");
res.setLog(LoggerFactory.getLogger("MockLog"));
res.configure(configuration);
res.init();
}
-
private BasicDataSource getDataSource() {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(EmbeddedDriver.class.getName());
@@ -83,7 +82,7 @@ public class DefaultUsersJdbcRepositoryT
ds.setPassword("james");
return ds;
}
-
+
/**
* @return
*/
Modified: james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java (original)
+++ james/server/trunk/jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java Mon Apr 4 20:38:14 2011
@@ -19,7 +19,6 @@
package org.apache.james.user.jdbc;
-
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.dbcp.BasicDataSource;
@@ -42,7 +41,7 @@ import java.util.Iterator;
import javax.sql.DataSource;
/**
- * Test basic behaviours of UsersFileRepository
+ * Test basic behaviors of UsersFileRepository
*/
public class JamesUsersJdbcRepositoryTest extends AbstractUsersRepositoryTest {
@@ -50,7 +49,7 @@ public class JamesUsersJdbcRepositoryTes
* Create the repository to be tested.
*
* @return the user repository
- * @throws Exception
+ * @throws Exception
*/
protected UsersRepository getUsersRepository() throws Exception {
JamesUsersJdbcRepository res = new JamesUsersJdbcRepository();
@@ -67,17 +66,16 @@ public class JamesUsersJdbcRepositoryTes
*/
protected void configureAbstractJdbcUsersRepository(AbstractJdbcUsersRepository res, String tableString) throws Exception, ConfigurationException {
res.setFileSystem(new MockFileSystem());
- DataSource dataSource = getDataSource();
- res.setDatasource(dataSource );
+ DataSource dataSource = getDataSource();
+ res.setDatasource(dataSource);
DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder();
- configuration.addProperty("[@destinationURL]", "db://maildb/"+tableString);
- configuration.addProperty("sqlFile","file://conf/sqlResources.xml");
+ configuration.addProperty("[@destinationURL]", "db://maildb/" + tableString);
+ configuration.addProperty("sqlFile", "file://conf/sqlResources.xml");
res.setLog(LoggerFactory.getLogger("MockLog"));
res.configure(configuration);
res.init();
}
-
private BasicDataSource getDataSource() {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(EmbeddedDriver.class.getName());
@@ -86,7 +84,7 @@ public class JamesUsersJdbcRepositoryTes
ds.setPassword("james");
return ds;
}
-
+
/**
* @return
*/
@@ -101,49 +99,45 @@ public class JamesUsersJdbcRepositoryTes
}
LifecycleUtil.dispose(this.usersRepository);
}
-
-
+
public void testVirtualUserTableImpl() throws Exception {
String username = "test";
String password = "pass";
String alias = "alias";
String domain = "localhost";
String forward = "forward@somewhere";
-
+
JamesUsersJdbcRepository repos = (JamesUsersJdbcRepository) getUsersRepository();
repos.setEnableAliases(true);
repos.setEnableForwarding(true);
- repos.addUser(username,password);
-
- JamesUser user = (JamesUser)repos.getUserByName(username);
+ repos.addUser(username, password);
+
+ JamesUser user = (JamesUser) repos.getUserByName(username);
user.setAlias(alias);
repos.updateUser(user);
-
+
Collection<String> map = ((VirtualUserTable) repos).getMappings(username, domain);
assertNull("No mapping", map);
-
+
user.setAliasing(true);
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
assertEquals("One mapping", 1, map.size());
assertEquals("Alias found", map.iterator().next().toString(), alias + "@" + domain);
-
-
+
user.setForwardingDestination(new MailAddress(forward));
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
assertTrue("One mapping", map.size() == 1);
assertEquals("Alias found", map.iterator().next().toString(), alias + "@" + domain);
-
-
+
user.setForwarding(true);
repos.updateUser(user);
map = ((VirtualUserTable) repos).getMappings(username, domain);
Iterator<String> mappings = map.iterator();
- assertTrue("Two mapping",map.size() == 2);
+ assertTrue("Two mapping", map.size() == 2);
assertEquals("Alias found", mappings.next().toString(), alias + "@" + domain);
assertEquals("Forward found", mappings.next().toString(), forward);
}
-
}
Modified: james/server/trunk/jdbc/src/test/java/org/apache/james/vut/jdbc/JDBCVirtualUserTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/test/java/org/apache/james/vut/jdbc/JDBCVirtualUserTableTest.java?rev=1088781&r1=1088780&r2=1088781&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/test/java/org/apache/james/vut/jdbc/JDBCVirtualUserTableTest.java (original)
+++ james/server/trunk/jdbc/src/test/java/org/apache/james/vut/jdbc/JDBCVirtualUserTableTest.java Mon Apr 4 20:38:14 2011
@@ -18,8 +18,6 @@
****************************************************************/
package org.apache.james.vut.jdbc;
-
-
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.derby.jdbc.EmbeddedDriver;
@@ -34,7 +32,7 @@ import org.slf4j.LoggerFactory;
* Test the JDBC Virtual User Table implementation.
*/
public class JDBCVirtualUserTableTest extends AbstractVirtualUserTableTest {
-
+
/**
* @see org.apache.james.vut.lib.AbstractVirtualUserTableTest#getVirtualUserTable()
*/
@@ -44,14 +42,13 @@ public class JDBCVirtualUserTableTest ex
virtualUserTable.setDataSource(getDataSource());
virtualUserTable.setFileSystem(new MockFileSystem());
DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
- defaultConfiguration.addProperty("[@destinationURL]","db://maildb/VirtualUserTable");
- defaultConfiguration.addProperty("sqlFile","file://conf/sqlResources.xml");
+ defaultConfiguration.addProperty("[@destinationURL]", "db://maildb/VirtualUserTable");
+ defaultConfiguration.addProperty("sqlFile", "file://conf/sqlResources.xml");
virtualUserTable.configure(defaultConfiguration);
virtualUserTable.init();
return virtualUserTable;
- }
-
-
+ }
+
private BasicDataSource getDataSource() {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(EmbeddedDriver.class.getName());
@@ -60,10 +57,12 @@ public class JDBCVirtualUserTableTest ex
ds.setPassword("james");
return ds;
}
+
/**
- * @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);
@@ -83,7 +82,8 @@ public class JDBCVirtualUserTableTest ex
}
/**
- * @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 {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org