/ViaThinkSoft Java Utils/test/de/viathinksoft/utils/mail/address/EMailPreprocessorTest.java |
---|
0,0 → 1,33 |
package de.viathinksoft.utils.mail.address; |
import static org.junit.Assert.*; |
import java.net.IDN; |
import org.junit.Test; |
public class EMailPreprocessorTest { |
private static final String ExamplePunycode = "xn--zckzah"; // Japanese IDN |
// Test TLD |
private static final String ExampleUnicode = IDN.toUnicode(ExamplePunycode); |
@Test |
public void preprocessTrimTest() { |
// Check that trim() works |
assertEquals( |
"test@test.de", |
EMailPreprocessor |
.preprocess(" \t \n\t\n\r test@test.de \t \n\r\n \r ")); |
} |
@Test |
public void preprocessIDNTest() { |
// Check that IDN addresses are decoded |
assertEquals("test@" + ExamplePunycode + "." + ExamplePunycode, |
EMailPreprocessor.preprocess(" \t \n\t\n\r test@" |
+ ExampleUnicode + "." + ExampleUnicode |
+ " \t \n\r\n \r ")); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/ViaThinkSoft Java Utils/test/de/viathinksoft/utils/mail/address/EMailAddressTest.java |
---|
10,8 → 10,7 |
public class EMailAddressTest { |
// Japanese IDN Test TLD |
private static final String ExamplePunycode = "xn--zckzah"; |
private static final String ExamplePunycode = "xn--zckzah"; // Japanese IDN Test TLD |
private static final String ExampleUnicode = IDN.toUnicode(ExamplePunycode); |
@Test |
97,10 → 96,8 |
assertEquals(ExamplePunycode + ".jp", a.getDomainPartPunycode()); |
assertEquals("jp", a.getTldUnicode()); |
assertEquals("jp", a.getTldPunycode()); |
assertEquals("local@" + ExampleUnicode + ".jp", a |
.getMailAddressUnicode()); |
assertEquals("local@" + ExamplePunycode + ".jp", a |
.getMailAddressPunycodedDomain()); |
assertEquals("local@"+ExampleUnicode+".jp", a.getMailAddressUnicode()); |
assertEquals("local@"+ExamplePunycode+".jp", a.getMailAddressPunycodedDomain()); |
EMailAddress.USE_UNICODE_AS_STANDARD = true; |
assertEquals("local@" + ExampleUnicode + ".jp", a.toString()); |
EMailAddress.USE_UNICODE_AS_STANDARD = false; |
113,10 → 110,8 |
assertEquals("example." + ExamplePunycode, a.getDomainPartPunycode()); |
assertEquals(ExampleUnicode, a.getTldUnicode()); |
assertEquals(ExamplePunycode, a.getTldPunycode()); |
assertEquals("local@example." + ExampleUnicode, a |
.getMailAddressUnicode()); |
assertEquals("local@example." + ExamplePunycode, a |
.getMailAddressPunycodedDomain()); |
assertEquals("local@example."+ExampleUnicode, a.getMailAddressUnicode()); |
assertEquals("local@example."+ExamplePunycode, a.getMailAddressPunycodedDomain()); |
EMailAddress.USE_UNICODE_AS_STANDARD = true; |
assertEquals("local@example." + ExampleUnicode, a.toString()); |
EMailAddress.USE_UNICODE_AS_STANDARD = false; |
151,8 → 146,7 |
assertEquals(b.getDomainPartPunycode(), a.getDomainPartPunycode()); |
assertEquals(b.getDomainPartUnicode(), a.getDomainPartUnicode()); |
assertEquals(b.getLocalPart(), a.getLocalPart()); |
assertEquals(b.getMailAddressPunycodedDomain(), a |
.getMailAddressPunycodedDomain()); |
assertEquals(b.getMailAddressPunycodedDomain(), a.getMailAddressPunycodedDomain()); |
assertEquals(b.getMailAddressUnicode(), a.getMailAddressUnicode()); |
assertEquals(b.getTldPunycode(), a.getTldPunycode()); |
assertEquals(b.getTldUnicode(), a.getTldUnicode()); |
171,21 → 165,4 |
assertTrue(a.equals(b)); |
assertTrue(b.equals(a)); |
} |
@Test |
public void preprocessTrimTest() { |
// Check that trim() works |
assertEquals( |
"test@test.de", |
EMailAddress |
.preprocess(" \t \n\t\n\r test@test.de \t \n\r\n \r ")); |
} |
@Test |
public void preprocessIDNTest() { |
// Check that IDN addresses are decoded |
assertEquals("test@" + ExamplePunycode + "." + ExamplePunycode, |
EMailAddress.preprocess(" \t \n\t\n\r test@" + ExampleUnicode |
+ "." + ExampleUnicode + " \t \n\r\n \r ")); |
} |
} |
/ViaThinkSoft Java Utils/test/de/viathinksoft/utils/mail/syntaxchecker/MailSyntaxCheckerTest.java |
---|
18,7 → 18,6 |
import de.viathinksoft.utils.mail.address.EMailAddress; |
@Deprecated |
public class MailSyntaxCheckerTest { |
static int errorCount; |
/ViaThinkSoft Java Utils/todo.txt |
---|
1,3 → 1,2 |
Mail Tests: Um Codeduplizierung zu vermeiden, eine Art Interface erstellen... |
Testabdeckung verbessern. |
RawMailSender mit JNDI erweitern |
/ViaThinkSoft Java Utils/src/de/viathinksoft/utils/mail/address/EMailAddress.java |
---|
312,20 → 312,4 |
} |
return (!IDN.toUnicode(str).equals(str)); |
} |
/** |
* This function "preproceses" an email address. Therefore following steps |
* will be performed: 1. The email address will be trimmed (in case of user |
* inputs) 2. E-Mail-Addresses with internationalized domain names will be |
* converted into ASCII compatible punycode (the local part will be left as |
* it is!) |
* |
* @author Daniel Marschall |
* |
*/ |
public static String preprocess(String eMailAddress) { |
EMailAddress email = new EMailAddress(eMailAddress); |
return email.getMailAddressPunycodedDomain(); |
} |
} |
/ViaThinkSoft Java Utils/src/de/viathinksoft/utils/mail/address/EMailPreprocessor.java |
---|
0,0 → 1,24 |
package de.viathinksoft.utils.mail.address; |
/** |
* This class contains a function which "preproceses an email address. Following |
* steps will be performed: 1. The email address will be trimmed (in case of |
* user inputs) 2. E-Mail-Addresses with internationalized domain names will be |
* converted into ASCII compatible punycode (the local part will be left as it |
* is!) |
* |
* @author Daniel Marschall |
* |
*/ |
public class EMailPreprocessor { |
public static String preprocess(String eMailAddress) { |
EMailAddress email = new EMailAddress(eMailAddress); |
return email.getMailAddressPunycodedDomain(); |
} |
private EMailPreprocessor() { |
} |
} |
/ViaThinkSoft Java Utils/src/de/viathinksoft/utils/mail/syntaxchecker/MailSyntaxChecker.java |
---|
14,7 → 14,6 |
* @version 0.1 |
* |
*/ |
@Deprecated |
public class MailSyntaxChecker { |
private static final String REGEX_IP = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; |