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 se...@apache.org on 2003/01/27 03:15:32 UTC
cvs commit: jakarta-james/tests/src/java/org/apache/james/testing BaseTest.java DeliveryTests.java EndToEnd.java Main.java MultiThreadDeliveryPounder.java POP3Hammering.java POP3Test.java ProtocolSimulator.java ProtocolSimulatorOptions.java SMTPDeliveryWorker.java SMTPTest.java SimpleTests.java TestMethod.java
serge 2003/01/26 18:15:32
Modified: tests/src/java/org/apache/james/testing BaseTest.java
DeliveryTests.java EndToEnd.java Main.java
MultiThreadDeliveryPounder.java POP3Hammering.java
POP3Test.java ProtocolSimulator.java
ProtocolSimulatorOptions.java
SMTPDeliveryWorker.java SMTPTest.java
SimpleTests.java TestMethod.java
Log:
Fixed several compilation issues (not all), and did some code formatting clean-ups.
Revision Changes Path
1.4 +13 -13 jakarta-james/tests/src/java/org/apache/james/testing/BaseTest.java
Index: BaseTest.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/BaseTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseTest.java 15 Oct 2002 04:36:31 -0000 1.3
+++ BaseTest.java 27 Jan 2003 02:15:31 -0000 1.4
@@ -7,12 +7,12 @@
*/
package org.apache.james.testing;
-import junit.framework.TestCase;
+
import junit.framework.TestCase;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-/**
+
/**
* Base Test class. Can run a set of method tests.
*/
public class BaseTest extends TestCase implements Configurable {
@@ -40,13 +40,13 @@
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
public void configure(Configuration configuration)
- throws ConfigurationException {
+ throws ConfigurationException {
// list of test methods
Configuration testseq = configuration.getChild("testsequence");
- showStat = testseq.getAttributeAsBoolean("showStat", true);
+
showStat = testseq.getAttributeAsBoolean("showStat", true);
Configuration[] testconf = testseq.getChildren("testmethod");
- testMethod = new TestMethod[testconf.length];
- for ( int i = 0 ; i < testMethod.length ; i++ ) {
+
testMethod = new TestMethod[testconf.length];
+ for (int i = 0; i < testMethod.length; i++) {
testMethod[i] = new TestMethod(testconf[i].getValue());
}
}
@@ -65,26 +65,26 @@
* Displays statistics if the showStat configuration param was true.
*/
protected final void runTest() throws Throwable {
- for ( int i = 0 ; i < testMethod.length ; i++ ) {
+ for (int i = 0; i < testMethod.length; i++) {
testMethod[i].invoke(this);
- if ( showStat ) {
- System.out.println("stat: "+getName()+", "+testMethod[i]);
+ if (showStat) {
+ System.out.println("stat: " + getName() + ", " + testMethod[i]);
}
}
}
// ------------ helper methods ----------------------
- /**
+ /**
* @param conf Test configuration
* @param name Child name
* @return String values of child elements
*/
- protected String[] getChildrenValues(Configuration conf,String name) throws ConfigurationException {
+ protected String[] getChildrenValues(Configuration conf, String name) throws ConfigurationException {
Configuration[] childconf = conf.getChildren(name);
String[] val = new String[childconf.length];
- for ( int i = 0 ; i < childconf.length ; i++ )
- val[i] = childconf[i].getValue();
+
for (int i = 0; i < childconf.length; i++) {
+ val[i] = childconf[i].getValue();
}
return val;
}
}
1.2 +33 -45 jakarta-james/tests/src/java/org/apache/james/testing/DeliveryTests.java
Index: DeliveryTests.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/DeliveryTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeliveryTests.java 6 Jan 2003 14:07:44 -0000 1.1
+++ DeliveryTests.java 27 Jan 2003 02:15:31 -0000 1.2
@@ -1,63 +1,51 @@
/**
* DeliveryTests.java
- *
+ *
* Copyright (C) 06-Jan-2003 The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
- *
- * Danny Angus
+ * the LICENSE file.
*/
package org.apache.james.testing;
-import java.io.IOException;
+
import java.io.IOException;
import java.net.SocketException;
import org.apache.commons.net.smtp.SMTPClient;
import junit.framework.TestCase;
-/**
- * @author <A href="mailto:danny@apache.org">Danny Angus</a>
- *
- * $Id$
- */
-public class DeliveryTests extends TestCase {
- /**
- * Constructor for DeliveryTests.
- * @param arg0
- */
-
- public DeliveryTests(String arg0) {
- super(arg0);
- }
-
+
/**
*
* $Id$
*/
+public class DeliveryTests extends TestCase {
/**
* Constructor for DeliveryTests.
* @param arg0
*/
+
+ public DeliveryTests(String arg0) {
super(arg0);
}
+
public void testSpam() {
- String spamMail="Subject: spam test\nFrom: postmaster@localhost\nTo: noone@localhost\n\nTHIS IS A TEST";
+ String spamMail = "Subject: spam test\nFrom: postmaster@localhost\nTo: noone@localhost\n\nTHIS IS A TEST";
SMTPClient client = new SMTPClient();
- try {
- client.connect("127.0.0.1", 25);
- client.sendSimpleMessage("postmaster@localhost", "noone@localhost", spamMail);
- client.disconnect();
- } catch (SocketException e) {
- assert(false);
- } catch (IOException e) {
- assert(false);
- }
- assert(true);
+
try {
+ client.connect("127.0.0.1", 25);
+ client.sendSimpleMessage("postmaster@localhost", "noone@localhost", spamMail);
+ client.disconnect();
+ } catch (SocketException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+ assertTrue(true);
}
- public void testOutgoing(){
- String outgoingMail="Subject: outgoing test\nFrom: postmaster@localhost\nTo: noone@mailet.org\n\nTHIS IS A TEST";
- SMTPClient client = new SMTPClient();
- try {
- client.connect("127.0.0.1", 25);
- client.sendSimpleMessage("postmaster@localhost", "noone@mailet.org", outgoingMail);
-
- client.disconnect();
- } catch (SocketException e) {
- assert(false);
- } catch (IOException e) {
- assert(false);
- }
- assert(true);
+
public void testOutgoing() {
+ String outgoingMail = "Subject: outgoing test\nFrom: postmaster@localhost\nTo: noone@mailet.org\n\nTHIS IS A TEST";
+ SMTPClient client = new SMTPClient();
+
try {
+ client.connect("127.0.0.1", 25);
+ client.sendSimpleMessage("postmaster@localhost", "noone@mailet.org", outgoingMail);
+
+ client.disconnect();
+ } catch (SocketException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+ assertTrue(true);
}
}
1.4 +32 -39 jakarta-james/tests/src/java/org/apache/james/testing/EndToEnd.java
Index: EndToEnd.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/EndToEnd.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EndToEnd.java 14 Oct 2002 16:14:54 -0000 1.3
+++ EndToEnd.java 27 Jan 2003 02:15:31 -0000 1.4
@@ -1,16 +1,15 @@
/**
- * RemoteManagerEndToEnd.java
- *
+ * EndToEnd.java
+ *
* Copyright (C) 27-Sep-2002 The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
- *
- * Danny Angus
+ * the LICENSE file.
*/
package org.apache.james.testing;
-import java.io.BufferedInputStream;
+
+
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -24,11 +23,10 @@
import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.telnet.TelnetClient;
import examples.IOUtil;
-/**
+
/**
* A class to do end to end load SMTP testing on James.
*
- * @author <A href="mailto:danny@apache.org">Danny Angus</a>
- *
+ *
* $Id$
*/
public class EndToEnd extends TestCase {
@@ -41,7 +39,7 @@
/**
* The size of messages generated by this test case.
*/
- private int messageSize = 1024*10;
+ private int messageSize = 1024 * 10;
/**
* The number of still-active worker threads.
@@ -58,14 +56,14 @@
* to begin the test.
*/
private String[] script1 =
- { "root", "root", "help", "adduser test test", "listusers", "quit" };
+ { "root", "root", "help", "adduser test test", "listusers", "quit" };
/**
* A set of commands to issue to the James RemoteManager interface
* to clean up after the test.
*/
private String[] script2 =
- { "root", "root", "listusers", "deluser test", "listusers", "quit" };
+ { "root", "root", "listusers", "deluser test", "listusers", "quit" };
/**
* Whether all the worker threads have finished.
@@ -102,7 +100,7 @@
TelnetClient client = new TelnetClient();
BufferedReader in;
OutputStreamWriter out;
- try {
+
try {
client.setDefaultTimeout(500);
client.connect("127.0.0.1", 4555);
runTelnetScript(client, script1);
@@ -112,8 +110,7 @@
client.connect("127.0.0.1", 4555);
runTelnetScript(client, script2);
client.disconnect();
-
-
+
} catch (SocketException e) {
e.printStackTrace();
assertTrue(false);
@@ -126,9 +123,9 @@
private void runTelnetScript(TelnetClient client, String[] script) throws IOException {
BufferedReader in;
OutputStreamWriter out;
- in = new BufferedReader(new InputStreamReader(client.getInputStream()));
+
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
OutputStream oo = client.getOutputStream();
- out = new OutputStreamWriter(oo);
+
out = new OutputStreamWriter(oo);
print(in, System.out);
for (int i = 0; i < script.length; i++) {
out.write(script[i] + "\n");
@@ -138,8 +135,7 @@
}
}
- private void echo(OutputStreamWriter out) {
- }
+ private void echo(OutputStreamWriter out) {}
/**
* Helper method to print data from the input reader into a
@@ -150,15 +146,14 @@
*/
private String print(BufferedReader in, OutputStream output) {
String outString = "";
- try {
+
try {
String readString = in.readLine();
- while (readString != null) {
+
while (readString != null) {
outString += readString + "\n";
readString = in.readLine();
}
- } catch (IOException e) {
- //e.printStackTrace();
- //assertTrue(false);
+ } catch (IOException e) {// e.printStackTrace();
+ // assertTrue(false);
}
System.out.println(outString);
return outString + "==";
@@ -171,15 +166,15 @@
private void SMTPTest() {
start = new Date();
StringBuffer mail1 = new StringBuffer();
- mail1.append(
- "Subject: test\nFrom: postmaster@localhost\nTo: test@localhost\n\nTHIS IS A TEST");
+
mail1.append(
+ "Subject: test\nFrom: postmaster@localhost\nTo: test@localhost\n\nTHIS IS A TEST");
for (int kb = 0; kb < messageSize; kb++) {
mail1.append("m");
}
String mail = mail1.toString();
SMTPDeliveryWorker[] workers = new SMTPDeliveryWorker[numWorkers];
Thread[] threads = new Thread[workers.length];
- for (int i = 0; i < workers.length; i++) {
+
for (int i = 0; i < workers.length; i++) {
workers[i] = new SMTPDeliveryWorker(new SMTPClient(), mail, this);
workers[i].setWorkerid(i);
threads[i] = new Thread((SMTPDeliveryWorker) workers[i]);
@@ -189,22 +184,21 @@
((Thread) threads[i]).start();
workingWorkers++;
}
- while (!finished) {
- // TODO: Shouldn't this busy loop be replaced with an
- // appropriate timed wait?
+ while (!finished) {// TODO: Shouldn't this busy loop be replaced with an
+ // appropriate timed wait?
}
-
+
long time = (new Date()).getTime() - start.getTime();
- System.err.println("time total " + (int) time);
+
System.err.println("time total " + (int) time);
}
/**
* End to end test of POP3 functionality.
*/
private void POP3Test() {
- try {
+ try {
POP3Client pclient = new POP3Client();
- pclient.connect("127.0.0.1", 110);
+
pclient.connect("127.0.0.1", 110);
System.out.println(pclient.getReplyString());
pclient.login("test", "test");
System.out.println(pclient.getReplyString());
@@ -222,7 +216,6 @@
}
}
-
/**
* Record that a particular worker thread has finished.
*
@@ -233,9 +226,9 @@
System.out.println("workers still working.." + workingWorkers);
if (workingWorkers == 0) {
long time = (new Date()).getTime() - start.getTime();
- System.err.println("time to deliver set " + (int) (time/1000));
- //System.err.println("messages per second " + (int)(1000/(time/1000)));
- //System.err.println("data rate="+((messageSize*1000)/(time/1000)));
+
System.err.println("time to deliver set " + (int) (time / 1000));
+ // System.err.println("messages per second " + (int)(1000/(time/1000)));
+ // System.err.println("data rate="+((messageSize*1000)/(time/1000)));
finished = true;
}
}
1.4 +9 -9 jakarta-james/tests/src/java/org/apache/james/testing/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/Main.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Main.java 7 Jan 2003 11:29:54 -0000 1.3
+++ Main.java 27 Jan 2003 02:15:31 -0000 1.4
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import java.io.File;
+
import java.io.File;
import java.lang.reflect.Constructor;
import junit.extensions.ActiveTestSuite;
@@ -20,7 +20,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-/**
+
/**
* Run tests.
* - Reads test configuration file, constructs test suite
* - initiates tests, reports result.
@@ -42,7 +42,7 @@
Configuration alltestconf = builder.buildFromFile(testconfFile);
Configuration[] testconf = alltestconf.getChildren("test");
TestSuite alltests = new TestSuite();
- for ( int i = 0 ; i < testconf.length ; i++ ) {
+
for (int i = 0; i < testconf.length; i++) {
Configuration conf = testconf[i];
String clsname = conf.getAttribute("class");
String name = conf.getAttribute("name");
@@ -51,18 +51,18 @@
Class clazz = Class.forName(clsname);
Constructor cstr = clazz.getConstructor(new Class[] { String.class });
- Test test = (Test)cstr.newInstance(new Object[] {name});
- if ( test instanceof Configurable ) {
- ((Configurable)test).configure(conf);
+ Test test = (Test) cstr.newInstance(new Object[] {name});
+
if (test instanceof Configurable) {
+ ((Configurable) test).configure(conf);
}
if (repetition > 1) {
- test = new RepeatedTest(test,repetition);
+ test = new RepeatedTest(test, repetition);
}
- if ( async ) {
+ if (async) {
TestSuite ts = new ActiveTestSuite();
- ts.addTest(test);
+
ts.addTest(test);
test = ts;
}
alltests.addTest(test);
1.6 +13 -20 jakarta-james/tests/src/java/org/apache/james/testing/MultiThreadDeliveryPounder.java
Index: MultiThreadDeliveryPounder.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/MultiThreadDeliveryPounder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MultiThreadDeliveryPounder.java 14 Oct 2002 06:44:22 -0000 1.5
+++ MultiThreadDeliveryPounder.java 27 Jan 2003 02:15:31 -0000 1.6
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import javax.mail.Message;
+
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
@@ -17,10 +17,9 @@
import java.util.Properties;
import java.util.Vector;
-/**
+
/**
* Creates numerous threads
*
- * @author Serge Knystautas <se...@lokitech.com>
*/
public class MultiThreadDeliveryPounder extends Thread {
@@ -60,32 +59,26 @@
try {
Properties prop = new Properties();
Session session = Session.getDefaultInstance(prop, null);
- // Transport transport = session.getTransport("smtp");
+
// Transport transport = session.getTransport("smtp");
for (int i = 0; i < loops; i++) {
MimeMessage msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress(user + "@localhost"));
+
msg.setFrom(new InternetAddress(user + "@localhost"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(user + "@localhost"));
msg.setContent(body + i, "text/plain");
Transport.send(msg);
StringBuffer outputBuffer =
- new StringBuffer(256)
- .append("Sent message : ")
- .append(msg.getContent())
- .append(" from: ")
- .append(msg.getFrom()[0])
- .append(" To: ")
- .append(msg.getAllRecipients()[0]);
- System.out.println(outputBuffer.toString());
+ new StringBuffer(256).append("Sent message : ").append(msg.getContent()).append(" from: ").append(msg.getFrom()[0]).append(" To: ").append(msg.getAllRecipients()[0]);
+
System.out.println(outputBuffer.toString());
}
} catch (Throwable e) {
e.printStackTrace();
- //System.exit(1);
+ // System.exit(1);
}
}
/**
- * Executes the test, creating a number of worker threads, each of whom
+ * Executes the test, creating a number of worker threads, each of whom
* will loop a fixed number of times, sending emails to the specified user
* on each loop.
*
@@ -104,15 +97,15 @@
Collection threads = new Vector();
long start = System.currentTimeMillis();
- for (int i = 0; i < threadCount; i++) {
+
for (int i = 0; i < threadCount; i++) {
threads.add(new MultiThreadDeliveryPounder(loops, user));
}
- for (Iterator i = threads.iterator(); i.hasNext(); ) {
- Thread t = (Thread)i.next();
- t.join();
+ for (Iterator i = threads.iterator(); i.hasNext();) {
+ Thread t = (Thread) i.next();
+
t.join();
}
long end = System.currentTimeMillis();
- System.out.println((end - start) + " milliseconds");
+
System.out.println((end - start) + " milliseconds");
}
}
1.6 +13 -17 jakarta-james/tests/src/java/org/apache/james/testing/POP3Hammering.java
Index: POP3Hammering.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/POP3Hammering.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- POP3Hammering.java 7 Jan 2003 11:29:54 -0000 1.5
+++ POP3Hammering.java 27 Jan 2003 02:15:31 -0000 1.6
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import java.util.Properties;
+
import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Folder;
@@ -19,11 +19,10 @@
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
-/**
+
/**
* Program that can be run multiple times to recreate the
* "stuck file" issue in Windows.
*
- * @author Prasanna Uppaladadium <pr...@vayusphere.com>
*/
public class POP3Hammering {
@@ -43,7 +42,6 @@
*/
private String password;
-
/**
* The prefix for the test message body. The body will correspond
* to this string with a number appended.
@@ -75,18 +73,16 @@
void sendMail() {
try {
Properties prop = new Properties();
- prop.put("java.smtp.host", mailHost);
+
prop.put("java.smtp.host", mailHost);
Session session = Session.getDefaultInstance(prop, null);
// Transport transport = session.getTransport("smtp");
MimeMessage msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress(user + "@localhost"));
+
msg.setFrom(new InternetAddress(user + "@localhost"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(user + "@localhost"));
msg.setContent(body + ++mailNumber, "text/plain");
Transport.send(msg);
// transport.close();
- System.out.println("Sent message : " + msg.getContent() +
- " from: " + msg.getFrom()[0] + " To: " +
- msg.getAllRecipients()[0]);
+ System.out.println("Sent message : " + msg.getContent() + " from: " + msg.getFrom()[0] + " To: " + msg.getAllRecipients()[0]);
} catch (Throwable e) {
e.printStackTrace();
System.exit(0);
@@ -101,16 +97,16 @@
void receiveMail(boolean delete) {
Store store = null;
Folder folder = null;
- try {
+
try {
Properties prop = new Properties();
- prop.put("java.smtp.host", mailHost);
+
prop.put("java.smtp.host", mailHost);
Session session = Session.getDefaultInstance(prop, null);
- store = session.getStore("pop3");
+
store = session.getStore("pop3");
store.connect(mailHost, user, password);
folder = store.getFolder("INBOX");
- if(folder == null || !folder.exists()) {
+ if (folder == null || !folder.exists()) {
System.out.println("This folder does not exist.");
return;
}
@@ -118,14 +114,14 @@
folder.open(Folder.READ_WRITE);
Message[] msgs = folder.getMessages();
- System.out.println("Received " + msgs.length + " messages for " + user);
+
System.out.println("Received " + msgs.length + " messages for " + user);
Message msg = msgs[0];
- System.out.println("From: " + msg.getFrom()[0].toString());
+
System.out.println("From: " + msg.getFrom()[0].toString());
System.out.println("To: " + msg.getRecipients(Message.RecipientType.TO)[0]);
System.out.println("-------------------");
System.out.println(msg.getContent().toString());
- if(delete) {
+ if (delete) {
msg.setFlag(Flags.Flag.DELETED, true);
System.out.println("Deleted.");
}
@@ -161,7 +157,7 @@
*/
public static void main(String[] args) throws Throwable {
POP3Hammering tester = new POP3Hammering(args[0], args[1], args[2]);
- tester.sendMail();
+
tester.sendMail();
tester.sendMail();
tester.receiveMail(true);
1.3 +14 -15 jakarta-james/tests/src/java/org/apache/james/testing/POP3Test.java
Index: POP3Test.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/POP3Test.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- POP3Test.java 14 Oct 2002 06:44:22 -0000 1.2
+++ POP3Test.java 27 Jan 2003 02:15:31 -0000 1.3
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import java.io.InputStream;
+
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import javax.mail.internet.MimeMessage;
@@ -18,9 +18,8 @@
import org.apache.commons.net.pop3.POP3;
import org.apache.commons.net.pop3.POP3Client;
import org.apache.commons.net.pop3.POP3MessageInfo;
-import org.apache.james.fetchpop.ReaderInputStream;
-/**
+
/**
* Fetch mail. Can be configured and extended to test specific POP3
* operations.
*/
@@ -53,8 +52,8 @@
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
- public void configure(Configuration configuration)
- throws ConfigurationException {
+ public void configure(Configuration configuration)
+ throws ConfigurationException {
this.host = configuration.getChild("host").getValue();
this.username = configuration.getChild("username").getValue();
this.password = configuration.getChild("password").getValue();
@@ -120,8 +119,8 @@
* Fetches all messages from the POP3 server.
*/
public void fetchMsgs() throws Exception {
- for ( int i = 0 ; i < msg.length ; i++ ) {
- fetchMsg(msg[i],false);
+ for (int i = 0; i < msg.length; i++) {
+ fetchMsg(msg[i], false);
}
}
@@ -130,8 +129,8 @@
* to disk.
*/
public void fetchAndSaveMsgs() throws Exception {
- for ( int i = 0 ; i < msg.length ; i++ ) {
- fetchMsg(msg[i],true);
+ for (int i = 0; i < msg.length; i++) {
+ fetchMsg(msg[i], true);
}
}
@@ -139,7 +138,7 @@
* Deletes all the messages from the server.
*/
public void deleteMsgs() throws Exception {
- for ( int i = 0 ; i < msg.length ; i++ ) {
+ for (int i = 0; i < msg.length; i++) {
client.deleteMessage(msg[i].number);
}
}
@@ -151,14 +150,14 @@
* @param msg the information for the particular message to retrieve
* @param save whether the message is saved to a file.
*/
- private void fetchMsg(POP3MessageInfo msg,boolean save) throws Exception {
+ private void fetchMsg(POP3MessageInfo msg, boolean save) throws Exception {
InputStream in = new ReaderInputStream(client.retrieveMessage(msg.number));
- try {
+
try {
MimeMessage message = new MimeMessage(null, in);
- if ( save ) {
+
if (save) {
OutputStream out = new FileOutputStream
- ("pop3test-"+host+"-"+username+"."+(saveMsgCounter++)+".eml");
- try {
+ ("pop3test-" + host + "-" + username + "." + (saveMsgCounter++) + ".eml");
+
try {
message.writeTo(out);
} finally {
IOUtil.shutdownStream(out);
1.7 +112 -106 jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulator.java
Index: ProtocolSimulator.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProtocolSimulator.java 26 Oct 2002 00:15:34 -0000 1.6
+++ ProtocolSimulator.java 27 Jan 2003 02:15:31 -0000 1.7
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import java.io.BufferedOutputStream;
+
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -24,7 +24,7 @@
import org.apache.oro.text.perl.Perl5Util;
import org.apache.james.util.InternetPrintWriter;
-/**
+
/**
* <pre>
* Simulates protocol sessions. Connects to a protocol server. Test
* reads template and sends data or reads data from server and
@@ -36,7 +36,7 @@
* - Each template line is treated as a seprate unit.
* - 'C: ' indicates client side communication that is communication
* from this test to remote server.
- * - 'S: ' indicates server response.
+ * - 'S: ' indicates server response.
* - Client side communication is obtained from template file and is
* sent as is to the server.
* - Expected Server side responses are read from template. Expected
@@ -60,14 +60,16 @@
*/
public class ProtocolSimulator {
- /** starts test run */
+ /**
+ * starts test run
+ */
public static void main(String[] args) throws Exception {
ProtocolSimulatorOptions params = ProtocolSimulatorOptions.getOptions(args);
- if ( params == null )
- return;
+
if (params == null) {
+ return;
}
new ProtocolSimulator(params).start();
}
-
+
// -------- constants shared by protocol simulators -----------
private static final String COMMENT_TAG = "#";
private static final String CLIENT_TAG = "C: ";
@@ -75,164 +77,168 @@
private static final int CLIENT_TAG_LEN = CLIENT_TAG.length();
private static final int SERVER_TAG_LEN = SERVER_TAG.length();
-
private final ProtocolSimulatorOptions params;
private final Perl5Util perl = new Perl5Util();
- /** @params options Options to control Protocol Simulator run */
+ /**
+ * @params options Options to control Protocol Simulator run
+ */
public ProtocolSimulator(ProtocolSimulatorOptions options) {
this.params = options;
}
- /** start simulation run */
+ /**
+ * start simulation run
+ */
public void start() throws IOException, InterruptedException {
- System.out.println("Testing Against Server "+params.host+":"+params.port);
- System.out.println("Simulation Template: "+params.template);
- System.out.println("Number Of Workers="+params.workers+
- ", Iterations Per Worker="+params.iterations);
+ System.out.println("Testing Against Server " + params.host + ":" + params.port);
+ System.out.println("Simulation Template: " + params.template);
+ System.out.println("Number Of Workers=" + params.workers + ", Iterations Per Worker=" + params.iterations);
// create protocol simulation commands and fire simulation.
Command simulation = getSimulationCmd(params.template);
- runSimulation(simulation);
+
runSimulation(simulation);
}
-
+
// ---- methods to fire off simulation ---------
- /** Starts simulation threads. Blocks till simulation threads are done. */
- private void runSimulation(final Command simulation)
- throws InterruptedException
- {
+ /**
+ * Starts simulation threads. Blocks till simulation threads are done.
+ */
+ private void runSimulation(final Command simulation)
+ throws InterruptedException {
Thread[] t = new Thread[params.workers];
- for ( int i = 0 ; i < t.length ; i++ ) {
+
for (int i = 0; i < t.length; i++) {
final int workerID = i;
- t[i] = new Thread("protocol-simulator-"+workerID) {
- public void run() {
- try {
- for ( int i = 0 ; i < params.iterations ; i++ )
- runSingleSimulation(simulation);
- } catch(Throwable t) {
- System.out.println("Terminating "+workerID+" Reason="+t.toString());
- t.printStackTrace();
- }
+
t[i] = new Thread("protocol-simulator-" + workerID) {
+ public void run() {
+ try {
+ for (int i = 0; i < params.iterations; i++) {
+ runSingleSimulation(simulation);
}
+ } catch (Throwable t) {
+ System.out.println("Terminating " + workerID + " Reason=" + t.toString());
+ t.printStackTrace();
}
- };
+ }
+ };
}
- for ( int i = 0 ; i < t.length ; i++ )
- t[i].start();
- for ( int i = 0 ; i < t.length ; i++ )
- t[i].join();
+ for (int i = 0; i < t.length; i++) {
+ t[i].start();
}
+ for (int i = 0; i < t.length; i++) {
+ t[i].join();
}
}
- /** run single simulation. called per thread per interation */
+ /**
+ * run single simulation. called per thread per interation
+ */
private void runSingleSimulation(Command simulation) throws Throwable {
Socket sock = null;
- try {
- sock = new Socket(params.host,params.port);
- InputStream inp = sock.getInputStream();
+
try {
+ sock = new Socket(params.host, params.port);
+ InputStream inp = sock.getInputStream();
OutputStream out = sock.getOutputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inp));
- PrintWriter writer = new InternetPrintWriter(new BufferedOutputStream(out),true);
- simulation.execute(reader,writer);
+ PrintWriter writer = new InternetPrintWriter(new BufferedOutputStream(out), true);
+
simulation.execute(reader, writer);
} finally {
- if ( sock != null )
- try { sock.close(); } catch(Throwable t) { }
+ if (sock != null) {
+ try {
sock.close();
} catch (Throwable t) {}
}
}
}
-
+
// --------- helper methods --------------
-
- /** read template and convert into single protocol interaction command
+
+ /**
+ * read template and convert into single protocol interaction command
*/
private Command getSimulationCmd(String template)
- throws IOException
- {
+ throws IOException {
BufferedReader templateReader = new BufferedReader(new FileReader(template));
- try {
+
try {
return getSimulationCmd(templateReader);
} finally {
// try your best to cleanup.
- try { templateReader.close(); } catch(Throwable t) { }
+ try {
templateReader.close();
} catch (Throwable t) {}
}
}
- /** read template and convert into a single protocol interaction command.
+ /**
+ * read template and convert into a single protocol interaction command.
*/
private Command getSimulationCmd(BufferedReader templateReader)
- throws IOException
- {
+ throws IOException {
// convert template lines into Protocol interaction commands.
final List list = new ArrayList();
- while ( true ) {
+
while (true) {
final String templateLine = templateReader.readLine();
- if ( templateLine == null )
- break;
+
if (templateLine == null) {
+ break;
}
// ignore empty lines.
- if ( templateLine.trim().length() == 0 )
- list.add(new NOOPCmd());
- else if ( templateLine.startsWith(COMMENT_TAG) )
- list.add(new NOOPCmd());
- else if ( templateLine.startsWith(CLIENT_TAG) ) {
+ if (templateLine.trim().length() == 0) {
+ list.add(new NOOPCmd());
} else if (templateLine.startsWith(COMMENT_TAG)) {
+ list.add(new NOOPCmd());
} else if (templateLine.startsWith(CLIENT_TAG)) {
list.add(new Command() {
- // just send the client data
- public void execute(BufferedReader reader,PrintWriter writer)
- throws Throwable
- {
- writer.println(templateLine.substring(CLIENT_TAG_LEN));
- }
- });
- } else if ( templateLine.startsWith(SERVER_TAG) ) {
+ // just send the client data
+ public void execute(BufferedReader reader, PrintWriter writer)
+ throws Throwable {
+ writer.println(templateLine.substring(CLIENT_TAG_LEN));
+ }
+ }
);
+ } else if (templateLine.startsWith(SERVER_TAG)) {
list.add(new Command() {
- // read server line and validate
- public void execute(BufferedReader reader,PrintWriter writer)
- throws Throwable
- {
- String line = reader.readLine();
- String pattern = templateLine.substring(SERVER_TAG_LEN);
- System.out.println(pattern+":"+line);
- pattern = "m/"+pattern+"/";
- if ( line == null || !perl.match(pattern,line) )
- throw new IOException
- ("Protocol Failure: got=["+line+"] expected=["+templateLine+"]");
- }
- });
- } else
- throw new IOException("Invalid template line: "+templateLine);
+ // read server line and validate
+ public void execute(BufferedReader reader, PrintWriter writer)
+ throws Throwable {
+ String line = reader.readLine();
+ String pattern = templateLine.substring(SERVER_TAG_LEN);
+
System.out.println(pattern + ":" + line);
+ pattern = "m/" + pattern + "/";
+ if (line == null || !perl.match(pattern, line)) {
+ throw new IOException
+ ("Protocol Failure: got=[" + line + "] expected=[" + templateLine + "]");
}
+ }
+ }
);
+ } else {
+ throw new IOException("Invalid template line: " + templateLine);
}
}
-
+
// aggregate all commands into a single simulation command
Command simulation = new Command() {
- public void execute(BufferedReader reader,PrintWriter writer)
- throws Throwable
- {
- for ( int i = 0 ; i < list.size() ; i++ ) {
- Command cmd = (Command)list.get(i);
- try {
- cmd.execute(reader,writer);
- } catch(Throwable t) {
- System.out.println("Failed on line: "+i);
- throw t;
- }
+ public void execute(BufferedReader reader, PrintWriter writer)
+ throws Throwable {
+ for (int i = 0; i < list.size(); i++) {
+ Command cmd = (Command) list.get(i);
+
try {
+ cmd.execute(reader, writer);
+ } catch (Throwable t) {
+ System.out.println("Failed on line: " + i);
+ throw t;
}
}
- };
- return simulation;
+ }
+ };
+
return simulation;
}
// ----- helper abstractions -------
- /** represents a single protocol interaction */
+ /**
+ * represents a single protocol interaction
+ */
private interface Command {
- /**
- * do something. Either write to or read from and validate
+
/**
+ * do something. Either write to or read from and validate
* @param reader Input from protocol server
- * @param writer Output to protocol Server
+ * @param writer Output to protocol Server
*/
- public abstract void execute(BufferedReader reader,PrintWriter writer) throws Throwable;
+ public abstract void execute(BufferedReader reader, PrintWriter writer) throws Throwable;
}
- /** do nothing */
+
/**
+ * do nothing
+ */
private static class NOOPCmd implements Command {
- public void execute(BufferedReader reader,PrintWriter writer)
- throws Throwable { }
+ public void execute(BufferedReader reader, PrintWriter writer)
+ throws Throwable {}
}
}
1.2 +37 -40 jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulatorOptions.java
Index: ProtocolSimulatorOptions.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulatorOptions.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProtocolSimulatorOptions.java 19 Oct 2002 19:58:17 -0000 1.1
+++ ProtocolSimulatorOptions.java 27 Jan 2003 02:15:31 -0000 1.2
@@ -7,12 +7,12 @@
*/
package org.apache.james.testing;
-import org.apache.avalon.excalibur.cli.CLArgsParser;
+
import org.apache.avalon.excalibur.cli.CLArgsParser;
import org.apache.avalon.excalibur.cli.CLOption;
import org.apache.avalon.excalibur.cli.CLOptionDescriptor;
import org.apache.avalon.excalibur.cli.CLUtil;
-/**
+
/**
* Process Protocol Simulator Options. This is required input to
* Protocol Simulator
*/
@@ -24,7 +24,7 @@
final int iterations;
final int workers;
- /**
+ /**
* @param host server host to connect to
* @param port server port to connect to
* @param template Protocol simulation template file
@@ -32,9 +32,8 @@
* @param workers number of parallel threads
*/
public ProtocolSimulatorOptions(String host, int port,
- String template,
- int iterations,int workers)
- {
+ String template,
+ int iterations, int workers) {
this.host = host;
this.port = port;
this.template = template;
@@ -54,40 +53,39 @@
private static final CLOptionDescriptor[] OPTIONS = {
new CLOptionDescriptor("server",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- OptionTag.HOST,
- "Remote Server Host To Test Against"),
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ OptionTag.HOST,
+ "Remote Server Host To Test Against"),
new CLOptionDescriptor("port",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- OptionTag.PORT,
- "Remote Server Port To Test Against"),
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ OptionTag.PORT,
+ "Remote Server Port To Test Against"),
new CLOptionDescriptor("template",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- OptionTag.TEMPLATE,
- "Protocol Session Template"),
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ OptionTag.TEMPLATE,
+ "Protocol Session Template"),
new CLOptionDescriptor("workers",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- OptionTag.WORKERS,
- "Number Of Concurrent Simulations. Default Is 1."),
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ OptionTag.WORKERS,
+ "Number Of Concurrent Simulations. Default Is 1."),
new CLOptionDescriptor("iterations",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- OptionTag.ITERATIONS,
- "Number Of Protocol Simulations Iterations Per Worker. Default Is 1."),
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ OptionTag.ITERATIONS,
+ "Number Of Protocol Simulations Iterations Per Worker. Default Is 1."),
new CLOptionDescriptor("help",
- CLOptionDescriptor.ARGUMENT_OPTIONAL,
- OptionTag.HELP,
- "Usage Help"),
+ CLOptionDescriptor.ARGUMENT_OPTIONAL,
+ OptionTag.HELP,
+ "Usage Help"),
};
-
- /**
+ /**
* parse command line options
* @return Options or null if there has been parsing error
*/
static ProtocolSimulatorOptions getOptions(String[] args) {
// parse options.
- CLArgsParser parser = new CLArgsParser( args, OPTIONS );
- if( parser.getErrorString() != null ) {
+ CLArgsParser parser = new CLArgsParser(args, OPTIONS);
+
if (parser.getErrorString() != null) {
System.out.println("Error: " + parser.getErrorString());
System.out.println("try --help option");
return null;
@@ -102,38 +100,37 @@
int workers = 1;
// collect options
- CLOption[] option = (CLOption[])parser.getArguments()
- .toArray(new CLOption[0]);
- for( int i = 0; i < option.length; i++ ) {
+ CLOption[] option = (CLOption[]) parser.getArguments().toArray(new CLOption[0]);
+
for (int i = 0; i < option.length; i++) {
CLOption opt = option[i];
- switch(opt.getId()) {
+
switch (opt.getId()) {
case OptionTag.HELP:
help = true;
break;
- case OptionTag.HOST:
+
case OptionTag.HOST:
host = opt.getArgument();
break;
- case OptionTag.PORT:
+
case OptionTag.PORT:
port = Integer.parseInt(opt.getArgument());
break;
- case OptionTag.TEMPLATE:
+
case OptionTag.TEMPLATE:
template = opt.getArgument();
break;
- case OptionTag.ITERATIONS:
+
case OptionTag.ITERATIONS:
iterations = Integer.parseInt(opt.getArgument());
break;
- case OptionTag.WORKERS:
+
case OptionTag.WORKERS:
workers = Integer.parseInt(opt.getArgument());
break;
- default:
+
default:
help = true;
break;
}
}
- if ( host == null || port == -1 || template == null || help ) {
+ if (host == null || port == -1 || template == null || help) {
System.out.println(CLUtil.describeOptions(OPTIONS));
return null;
}
- return new ProtocolSimulatorOptions(host,port,template,iterations,workers);
+ return new ProtocolSimulatorOptions(host, port, template, iterations, workers);
}
}
1.4 +14 -16 jakarta-james/tests/src/java/org/apache/james/testing/SMTPDeliveryWorker.java
Index: SMTPDeliveryWorker.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/SMTPDeliveryWorker.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SMTPDeliveryWorker.java 14 Oct 2002 16:14:55 -0000 1.3
+++ SMTPDeliveryWorker.java 27 Jan 2003 02:15:31 -0000 1.4
@@ -3,52 +3,50 @@
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
+ * the LICENSE file.
*/
package org.apache.james.testing;
-import java.io.IOException;
+
import java.io.IOException;
import org.apache.commons.net.smtp.SMTPClient;
-/**
+
/**
* SMTPDeliveryWorker.java
*
* A worker thread that is part of the SMTP delivery end to end testing.
*
- * @author <A href="mailto:danny@apache.org">Danny Angus</a>
- *
* $Id$
*/
public class SMTPDeliveryWorker implements Runnable {
private SMTPClient client;
- /**
+
/**
* The test of the mail message to send.
*/
private String mail;
- /**
+
/**
* The worker id. Primarily used for identification by the class
* managing the threads.
*/
private int workerid;
- /**
+
/**
* The EndToEnd test case that spawned this thread.
*/
EndToEnd boss;
- /**
+
/**
* Constructor for SMTPDeliveryWorker.
*
- * @param client the SMTP client being used by this test to
+ * @param client the SMTP client being used by this test to
*/
public SMTPDeliveryWorker(SMTPClient client, String mail, EndToEnd boss) {
this.boss = boss;
this.client = client;
this.mail = mail;
}
- /**
+
/**
* @see java.lang.Runnable#run()
*/
public void run() {
try {
for (int run = 0; run < 100; run++) {
- //move the connect and disconnect out of the loop to reuse
+ // move the connect and disconnect out of the loop to reuse
// the connection for all mail
client.connect("127.0.0.1", 25);
client.sendSimpleMessage("postmaster@localhost", "test@localhost", mail);
@@ -56,7 +54,7 @@
client.disconnect();
}
String[] outs = client.getReplyStrings();
- for (int i = 0; i < outs.length; i++) {
+
for (int i = 0; i < outs.length; i++) {
System.out.println(outs[i]);
}
} catch (IOException e) {
@@ -64,7 +62,7 @@
}
boss.finished(workerid);
}
- /**
+
/**
* Set the worker id for this worker thread.
*
* @param workerid the worker thread id
@@ -72,7 +70,7 @@
public void setWorkerid(int workerid) {
this.workerid = workerid;
}
- /**
+
/**
* Get the worker id for this worker thread.
*
* @return the worker thread id
1.3 +37 -37 jakarta-james/tests/src/java/org/apache/james/testing/SMTPTest.java
Index: SMTPTest.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/SMTPTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SMTPTest.java 7 Jan 2003 11:06:39 -0000 1.2
+++ SMTPTest.java 27 Jan 2003 02:15:31 -0000 1.3
@@ -7,7 +7,7 @@
*/
package org.apache.james.testing;
-import java.io.PrintStream;
+
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
@@ -19,7 +19,7 @@
import org.apache.commons.net.smtp.SMTPClient;
import org.apache.mailet.dates.RFC822DateFormat;
-/**
+
/**
* Send email. Can be configured and extended to test specific SMTP
* operations.
*/
@@ -42,13 +42,13 @@
/** mail from */
private String from;
- /** mail to */
+
/** mail to */
private String[] to;
- /** send mail msg copy to */
+
/** send mail msg copy to */
private String[] cc;
- /** send mail msg blind copy to */
+
/** send mail msg blind copy to */
private String[] bcc;
- /** mail message */
+
/** mail message */
private String mailMsg;
/**
@@ -64,17 +64,17 @@
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
public void configure(Configuration configuration)
- throws ConfigurationException {
+ throws ConfigurationException {
this.host = configuration.getChild("host").getValue();
this.username = configuration.getChild("username").getValue(null);
this.password = configuration.getChild("password").getValue(null);
this.from = configuration.getChild("from").getValue();
- this.to = getChildrenValues(configuration,"to");
- this.cc = getChildrenValues(configuration,"cc");
- this.bcc = getChildrenValues(configuration,"bcc");
+ this.to = getChildrenValues(configuration, "to");
+ this.cc = getChildrenValues(configuration, "cc");
+ this.bcc = getChildrenValues(configuration, "bcc");
int msgSize = configuration.getChild("msgsize").getValueAsInteger(1000);
String subject = configuration.getChild("subject").getValue("");
- this.mailMsg = createMailMsg(subject,msgSize);
+
this.mailMsg = createMailMsg(subject, msgSize);
super.configure(configuration);
}
@@ -110,56 +110,56 @@
client.connect(host);
// HBNOTE: extend this to do to, cc, bcc.
client.sendSimpleMessage("postmaster@localhost", to[0], mailMsg);
- System.out.println("msgs sent="+(++msgSentCounter));
- } catch( Throwable t) {
- System.out.println("msg send failures="+(++failureCounter));
+ System.out.println("msgs sent=" + (++msgSentCounter));
+ } catch (Throwable t) {
+ System.out.println("msg send failures=" + (++failureCounter));
} finally {
try {
client.disconnect();
- } catch(Throwable t) { }
+ } catch (Throwable t) {}
}
}
// ------ helper methods ------
- /**
+ /**
* @param arr of strings
* @param sep separator character.
* @return concatenates a an array of strings.
*/
- private String toString(String[] arr,char sep) {
+ private String toString(String[] arr, char sep) {
StringBuffer buf = new StringBuffer();
- for ( int i = 0 ; i < arr.length ; i++ ) {
- if ( i > 0 )
- buf.append(sep);
+
for (int i = 0; i < arr.length; i++) {
+ if (i > 0) {
+ buf.append(sep);
}
buf.append(arr[i]);
}
return buf.toString();
}
- private String createMailMsg(String subject,int msgSize) {
+
private String createMailMsg(String subject, int msgSize) {
StringWriter str = new StringWriter();
final char[] CRLF = new char[] { '\r', '\n' };
PrintWriter prt = new PrintWriter(str) {
- public void println() {
- write(CRLF,0,CRLF.length);
- flush();
- }
- };
- prt.println("From: "+from);
- String to = toString(this.to,';');
- if ( to.length() > 0 )
- prt.println("To: "+to);
- String cc = toString(this.cc,';');
- if ( cc.length() > 0 )
- prt.println("CC: "+cc);
- prt.println("Subject: "+subject);
- prt.println("Date: "+RFC822DateFormat.toString(new Date()));
+ public void println() {
+ write(CRLF, 0, CRLF.length);
+ flush();
+ }
+ };
+
prt.println("From: " + from);
+ String to = toString(this.to, ';');
+
if (to.length() > 0) {
+ prt.println("To: " + to);
}
+ String cc = toString(this.cc, ';');
+
if (cc.length() > 0) {
+ prt.println("CC: " + cc);
}
+ prt.println("Subject: " + subject);
+ prt.println("Date: " + RFC822DateFormat.toString(new Date()));
prt.println("MIME-Version: 1.0");
prt.println("Content-Type: text/plain; charset=\"iso-8859-1\"");
prt.println();
char[] ca = new char[msgSize];
- for (int i = 0; i < msgSize; i++)
- ca[i] = 'm';
+
for (int i = 0; i < msgSize; i++) {
+ ca[i] = 'm';
}
prt.print(new String(ca));
prt.flush();
return str.toString();
1.2 +8 -21 jakarta-james/tests/src/java/org/apache/james/testing/SimpleTests.java
Index: SimpleTests.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/SimpleTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleTests.java 6 Jan 2003 14:07:44 -0000 1.1
+++ SimpleTests.java 27 Jan 2003 02:15:31 -0000 1.2
@@ -1,31 +1,18 @@
/**
* AllTests.java
- *
+ *
* Copyright (C) 06-Jan-2003 The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
+ * the LICENSE file.
*
- * Danny Angus
- */
-package org.apache.james.testing;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-/**
- * @author <A href="mailto:danny@apache.org">Danny Angus</a>
- *
- * $Id$
- */
+ */
package org.apache.james.testing;
+
import junit.framework.Test;
import junit.framework.TestSuite;
/**
*
* $Id$
*/
public class SimpleTests {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SimpleTests.class);
- }
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.apache.james.testing");
- //$JUnit-BEGIN$
- suite.addTest(new TestSuite(DeliveryTests.class));
- //$JUnit-END$
+ public static void main(String[] args) {
junit.textui.TestRunner.run(SimpleTests.class);
}
+ public static Test suite() {
TestSuite suite = new TestSuite("Test for org.apache.james.testing");
+ // $JUnit-BEGIN$
suite.addTest(new TestSuite(DeliveryTests.class));
// $JUnit-END$
return suite;
}
-}
+}
\ No newline at end of file
1.4 +9 -16 jakarta-james/tests/src/java/org/apache/james/testing/TestMethod.java
Index: TestMethod.java
===================================================================
RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/TestMethod.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestMethod.java 19 Oct 2002 23:00:45 -0000 1.3
+++ TestMethod.java 27 Jan 2003 02:15:31 -0000 1.4
@@ -7,9 +7,9 @@
*/
package org.apache.james.testing;
-import java.lang.reflect.Method;
+
import java.lang.reflect.Method;
-/**
+
/**
* A test class to test a single method call.
*/
class TestMethod {
@@ -55,14 +55,14 @@
* to be tested should be invoked.
*/
void invoke(Object obj) throws Exception {
- Method m = obj.getClass().getMethod(name,new Class[0]);
- attempts++;
+ Method m = obj.getClass().getMethod(name, new Class[0]);
+
attempts++;
long st = System.currentTimeMillis();
- try {
- m.invoke(obj,new Object[0]);
+
try {
+ m.invoke(obj, new Object[0]);
success++;
} finally {
- timeTaken = (int)(System.currentTimeMillis() - st);
+ timeTaken = (int) (System.currentTimeMillis() - st);
}
}
@@ -74,14 +74,7 @@
*/
public String toString() {
StringBuffer theStringBuffer =
- new StringBuffer(128)
- .append(name)
- .append(", ")
- .append(timeTaken)
- .append(", ")
- .append(success)
- .append(", ")
- .append(attempts);
- return theStringBuffer.toString();
+ new StringBuffer(128).append(name).append(", ").append(timeTaken).append(", ").append(success).append(", ").append(attempts);
+
return theStringBuffer.toString();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>