Browse files

Extracted some common string handling out of the tests

  • Loading branch information...
1 parent c08fe77 commit 24d965a17eecc8bb643cc0bffe90524420fee11b @rjo1970 committed Feb 16, 2011
View
2 build.xml
@@ -127,7 +127,7 @@ limitations under the License.
<formatter type="xml"/>
<batchtest fork="yes" todir="${testcompiledir}">
<fileset dir="${testsrcdir}">
- <include name="**/*.java"/>
+ <include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
View
6 src/com/dumbster/smtp/MailMessageImpl.java
@@ -35,13 +35,11 @@ public MailMessageImpl() {
body = new StringBuffer();
}
- @Override
public Iterator<String> getHeaderNames() {
Set<String> nameSet = headers.keySet();
return nameSet.iterator();
}
- @Override
public String[] getHeaderValues(String name) {
List<String> values = headers.get(name);
if (values == null) {
@@ -51,7 +49,6 @@ public MailMessageImpl() {
}
}
- @Override
public String getFirstHeaderValue(String name) {
List<String> values = headers.get(name);
if (values == null) {
@@ -62,12 +59,10 @@ public String getFirstHeaderValue(String name) {
}
}
- @Override
public String getBody() {
return body.toString();
}
- @Override
public void addHeader(String name, String value) {
List<String> valueList = headers.get(name);
if (valueList == null) {
@@ -77,7 +72,6 @@ public void addHeader(String name, String value) {
headers.put(name, valueList);
}
- @Override
public void appendBody(String line) {
body.append(line);
}
View
9 test-src/com/dumbster/smtp/MailMessageTest.java
@@ -30,12 +30,9 @@ public void testAddHeader() {
@Test
public void testLongSubjectHeader() {
- StringBuffer b = new StringBuffer();
- for (int i =0; i<500; i++) {
- b.append("X");
- }
- message.addHeader("Subject", b.toString());
- assertEquals("Subject: "+b+"\n\n\n", message.toString());
+ String longSubject = StringUtil.longString(500);
+ message.addHeader("Subject", longSubject);
+ assertEquals("Subject: "+longSubject+"\n\n\n", message.toString());
}
@Test
View
7 test-src/com/dumbster/smtp/SimpleSmtpServerTest.java
@@ -73,12 +73,9 @@ public void testSend() {
@Test
public void testSendWithLongSubject() {
- StringBuffer b = new StringBuffer();
- for(int i=0; i<500; i++)
- b.append("X");
- String longSubject = b.toString();
+ String longSubject = StringUtil.longString(500);
try {
- sendMessage(SMTP_PORT, From, b.toString(), Body, To);
+ sendMessage(SMTP_PORT, From, longSubject, Body, To);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception: " + e);
View
10 test-src/com/dumbster/smtp/StringUtil.java
@@ -0,0 +1,10 @@
+package com.dumbster.smtp;
+
+public class StringUtil {
+ public static String longString(int size) {
+ StringBuffer b = new StringBuffer();
+ for(int i=0; i<size; i++)
+ b.append("X");
+ return b.toString();
+ }
+}

0 comments on commit 24d965a

Please sign in to comment.