You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/12/04 19:51:57 UTC
svn commit: r1417113 - in
/commons/proper/email/trunk/src/test/java/org/apache/commons/mail:
BaseEmailTestCase.java EmailLiveTest.java EmailTest.java
MultiPartEmailTest.java util/MimeMessageParserTest.java
Author: sebb
Date: Tue Dec 4 18:51:55 2012
New Revision: 1417113
URL: http://svn.apache.org/viewvc?rev=1417113&view=rev
Log:
Fix most generics issues in test classes
Modified:
commons/proper/email/trunk/src/test/java/org/apache/commons/mail/BaseEmailTestCase.java
commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java
commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java
commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java
commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java
Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/BaseEmailTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/BaseEmailTestCase.java?rev=1417113&r1=1417112&r2=1417113&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/BaseEmailTestCase.java (original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/BaseEmailTestCase.java Tue Dec 4 18:51:55 2012
@@ -159,7 +159,7 @@ public abstract class BaseEmailTestCase
*/
public String getMessageAsString(int intMsgNo)
{
- List receivedMessages = fakeMailServer.getMessages();
+ List<?> receivedMessages = fakeMailServer.getMessages();
assertTrue("mail server didn't get enough messages", receivedMessages.size() >= intMsgNo);
WiserMessage emailMessage = (WiserMessage) receivedMessages.get(intMsgNo);
@@ -416,7 +416,7 @@ public abstract class BaseEmailTestCase
MimeMessage message = wiserMessage.getMimeMessage();
// Serialize the headers
- for (Enumeration headers = message.getAllHeaders(); headers
+ for (Enumeration<?> headers = message.getAllHeaders(); headers
.hasMoreElements();)
{
Header header = (Header) headers.nextElement();
Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java?rev=1417113&r1=1417112&r2=1417113&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java (original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java Tue Dec 4 18:51:55 2012
@@ -92,9 +92,9 @@ public class EmailLiveTest extends BaseE
* @return the new instance
* @throws Exception creating the Email instance failed
*/
- private Email create(Class clazz) throws Exception {
+ private Email create(Class<? extends Email> clazz) throws Exception {
- Email email = (Email) clazz.newInstance();
+ Email email = clazz.newInstance();
email.setStartTLSEnabled(EmailConfiguration.MAIL_USE_STARTTLS);
email.setStartTLSRequired(EmailConfiguration.MAIL_STARTTLS_REQUIRED);
@@ -315,7 +315,7 @@ public class EmailLiveTest extends BaseE
*/
public void testSendingEmailsInBatch() throws Exception
{
- List emails = new ArrayList();
+ List<SimpleEmail> emails = new ArrayList<SimpleEmail>();
// we need to instantiate an email to provide the mail session - a bit ugly
Session session = create(SimpleEmail.class).getMailSession();
@@ -339,7 +339,7 @@ public class EmailLiveTest extends BaseE
for(int i=0; i<emails.size(); i++)
{
- Email personalizedEmail = (Email) emails.get(i);
+ Email personalizedEmail = emails.get(i);
MimeMessage mimeMessage = personalizedEmail.getMimeMessage();
Transport.send(mimeMessage);
System.out.println("Successfully sent the following email : " + mimeMessage.getMessageID());
Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java?rev=1417113&r1=1417112&r2=1417113&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java (original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java Tue Dec 4 18:51:55 2012
@@ -288,7 +288,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -348,7 +348,7 @@ public class EmailTest extends BaseEmail
"someone_here@work-address.com.au"
};
String[] testEmailNames = {"Name1", "", null};
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "Name1"));
arrExpected.add(
new InternetAddress(
@@ -398,7 +398,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -430,7 +430,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -460,7 +460,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
String testCharset = Email.ISO_8859_1;
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(
new InternetAddress(
"me@home.com",
@@ -500,7 +500,7 @@ public class EmailTest extends BaseEmail
String[] testEmailNames = {"Name1", "", null};
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "Name1"));
arrExpected.add(
new InternetAddress(
@@ -549,7 +549,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
// Test Success
// ====================================================================
- List testEmailValid2 = new ArrayList();
+ List<InternetAddress> testEmailValid2 = new ArrayList<InternetAddress>();
testEmailValid2.add(new InternetAddress("me@home.com", "Name1"));
testEmailValid2.add(
new InternetAddress(
@@ -586,7 +586,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
try
{
- this.email.setTo(new ArrayList());
+ this.email.setTo(new ArrayList<InternetAddress>());
fail("Should have thrown an exception");
}
catch (EmailException e)
@@ -605,7 +605,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -637,7 +637,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -667,7 +667,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
String testCharset = Email.ISO_8859_1;
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(
new InternetAddress(
"me@home.com",
@@ -707,7 +707,7 @@ public class EmailTest extends BaseEmail
String[] testEmailNames = {"Name1", "", null};
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "Name1"));
arrExpected.add(
new InternetAddress(
@@ -755,7 +755,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
// Test Success
// ====================================================================
- List testEmailValid2 = new ArrayList();
+ List<String> testEmailValid2 = new ArrayList<String>();
testEmailValid2.add("Name1 <me...@home.com>");
testEmailValid2.add("\"joe.doe@apache.org\" <jo...@apache.org>");
testEmailValid2.add(
@@ -782,7 +782,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
try
{
- this.email.setCc(new ArrayList());
+ this.email.setCc(new ArrayList<String>());
fail("Should have thrown an exception");
}
catch (EmailException e)
@@ -801,7 +801,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -835,7 +835,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress("joe.doe@apache.org", "joe.doe@apache.org"));
@@ -864,7 +864,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
String testCharset = Email.ISO_8859_1;
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(
new InternetAddress(
"me@home.com",
@@ -907,7 +907,7 @@ public class EmailTest extends BaseEmail
String[] testEmailNames = {"Name1", "", null};
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "Name1"));
arrExpected.add(
new InternetAddress(
@@ -958,7 +958,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
// Test Success
// ====================================================================
- List testInetEmailValid = new ArrayList();
+ List<InternetAddress> testInetEmailValid = new ArrayList<InternetAddress>();
testInetEmailValid.add(new InternetAddress("me@home.com", "Name1"));
testInetEmailValid.add(
new InternetAddress(
@@ -990,7 +990,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
try
{
- this.email.setBcc(new ArrayList());
+ this.email.setBcc(new ArrayList<InternetAddress>());
fail("Should have thrown an exception");
}
catch (EmailException e)
@@ -1009,7 +1009,7 @@ public class EmailTest extends BaseEmail
// Test Success
// ====================================================================
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "me@home.com"));
arrExpected.add(
new InternetAddress(
@@ -1044,7 +1044,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
String testCharset = Email.ISO_8859_1;
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(
new InternetAddress(
"me@home.com",
@@ -1086,7 +1086,7 @@ public class EmailTest extends BaseEmail
String[] testEmailNames = {"Name1", "", null};
- List arrExpected = new ArrayList();
+ List<InternetAddress> arrExpected = new ArrayList<InternetAddress>();
arrExpected.add(new InternetAddress("me@home.com", "Name1"));
arrExpected.add(
new InternetAddress(
@@ -1134,16 +1134,16 @@ public class EmailTest extends BaseEmail
// ====================================================================
// Test Success
// ====================================================================
- Map ht = new Hashtable();
+ Map<String, String> ht = new Hashtable<String, String>();
ht.put("X-Priority", "1");
ht.put("Disposition-Notification-To", "me@home.com");
ht.put("X-Mailer", "Sendmail");
- for (Iterator items = ht.entrySet().iterator(); items.hasNext();)
+ for (Iterator<Map.Entry<String, String>> items = ht.entrySet().iterator(); items.hasNext();)
{
- Map.Entry entry = (Map.Entry) items.next();
- String strName = (String) entry.getKey();
- String strValue = (String) entry.getValue();
+ Map.Entry<String, String> entry = items.next();
+ String strName = entry.getKey();
+ String strValue = entry.getValue();
this.email.addHeader(strName, strValue);
}
@@ -1157,19 +1157,19 @@ public class EmailTest extends BaseEmail
// ====================================================================
// Test Exceptions
// ====================================================================
- Map htBad = new Hashtable();
+ Map<String, String> htBad = new Hashtable<String, String>();
htBad.put("X-Mailer", "");
htBad.put("X-Priority", "");
htBad.put("", "me@home.com");
- Map arrExpected = new Hashtable();
- for (Iterator items = htBad.entrySet().iterator(); items.hasNext();)
+ Map<?, ?> arrExpected = new Hashtable<Object, Object>();
+ for (Iterator<Map.Entry<String, String>> items = htBad.entrySet().iterator(); items.hasNext();)
{
- Map.Entry element = (Map.Entry) items.next();
+ Map.Entry<String, String> element = items.next();
try
{
- String strName = (String) element.getKey();
- String strValue = (String) element.getValue();
+ String strName = element.getKey();
+ String strValue = element.getValue();
this.email.addHeader(strName, strValue);
fail("Should have thrown an exception");
@@ -1189,7 +1189,7 @@ public class EmailTest extends BaseEmail
/** */
public void testSetHeaders()
{
- Map ht = new Hashtable();
+ Map<String, String> ht = new Hashtable<String, String>();
ht.put("X-Priority", "1");
ht.put("Disposition-Notification-To", "me@home.com");
ht.put("X-Mailer", "Sendmail");
@@ -1214,10 +1214,10 @@ public class EmailTest extends BaseEmail
// Test Exceptions
// ====================================================================
// first test
- Map htBad = new Hashtable();
+ Map<String, String> htBad = new Hashtable<String, String>();
htBad.put("X-Mailer", "");
- Map arrExpected = new Hashtable();
+ Map<?, ?> arrExpected = new Hashtable<Object, Object>();
try
{
@@ -1236,7 +1236,7 @@ public class EmailTest extends BaseEmail
// ====================================================================
// second test
- htBad = new Hashtable();
+ htBad = new Hashtable<String, String>();
htBad.put("", "me@home.com");
try
@@ -1402,7 +1402,7 @@ public class EmailTest extends BaseEmail
*/
public void testToInternetAddressArray() throws EmailException, UnsupportedEncodingException
{
- List testInetEmailValid = new ArrayList();
+ List<InternetAddress> testInetEmailValid = new ArrayList<InternetAddress>();
testInetEmailValid.add(new InternetAddress("me@home.com", "Name1"));
testInetEmailValid.add(
Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java?rev=1417113&r1=1417112&r2=1417113&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java (original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java Tue Dec 4 18:51:55 2012
@@ -143,7 +143,7 @@ public class MultiPartEmailTest extends
testEmail.setMsg("Test Message");
- Map ht = new HashMap();
+ Map<String, String> ht = new HashMap<String, String>();
ht.put("X-Priority", "2");
ht.put("Disposition-Notification-To", this.strTestMailFrom);
ht.put("X-Mailer", "Sendmail");
Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java?rev=1417113&r1=1417112&r2=1417113&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java (original)
+++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java Tue Dec 4 18:51:55 2012
@@ -113,7 +113,7 @@ public class MimeMessageParserTest
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getFrom());
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getReplyTo());
assertTrue(mimeMessageParser.hasAttachments());
- List attachmentList = mimeMessageParser.getAttachmentList();
+ List<?> attachmentList = mimeMessageParser.getAttachmentList();
assertTrue(attachmentList.size() == 2);
dataSource = mimeMessageParser.findAttachmentByName("Wasserlilien.jpg");
@@ -153,7 +153,7 @@ public class MimeMessageParserTest
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getFrom());
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getReplyTo());
assertTrue(mimeMessageParser.hasAttachments());
- List attachmentList = mimeMessageParser.getAttachmentList();
+ List<?> attachmentList = mimeMessageParser.getAttachmentList();
assertTrue(attachmentList.size() == 1);
dataSource = (DataSource) attachmentList.get(0);
@@ -190,7 +190,7 @@ public class MimeMessageParserTest
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getFrom());
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getReplyTo());
assertTrue(mimeMessageParser.hasAttachments());
- List attachmentList = mimeMessageParser.getAttachmentList();
+ List<?> attachmentList = mimeMessageParser.getAttachmentList();
assertTrue(attachmentList.size() == 1);
dataSource = mimeMessageParser.findAttachmentByName("Kunde 100029 Auftrag 3600.pdf");