[jbpm-commits] JBoss JBPM SVN: r3258 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Dec 8 03:17:45 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-12-08 03:17:44 -0500 (Mon, 08 Dec 2008)
New Revision: 3258
Modified:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java
Log:
Share code for SimpleMailServer creation
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java 2008-12-08 08:09:11 UTC (rev 3257)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java 2008-12-08 08:17:44 UTC (rev 3258)
@@ -7,8 +7,6 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
@@ -22,12 +20,10 @@
public class MailTest extends AbstractJbpmTestCase
{
- private static Log log = LogFactory.getLog(MailTest.class);
-
private static final int SMTP_PORT = 23583;
private static SimpleSmtpServer server;
- JbpmContext jbpmContext;
+ private JbpmContext jbpmContext;
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
@@ -65,21 +61,19 @@
super.tearDown();
}
- static SimpleSmtpServer startSmtpServer(int port)
+ public static SimpleSmtpServer startSmtpServer(int port)
{
/*
* SimpleSmtpServer.start(int) blocks the calling thread until the server socket is created. If the socket is
* created too quickly (seems to happen on Linux and Mac) then the notification is sent too early and the calling
* thread blocks forever.
- */
- // return SimpleSmtpServer.start(port);
- /*
+ *
* The code below corresponds to SimpleSmtpServer.start(int) except that the thread start has been moved inside of
* the synchronized block.
*/
SimpleSmtpServer server = new SimpleSmtpServer(port);
Thread serverThread = new Thread(server);
-
+
// Block until the server socket is created
synchronized (server)
{
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java 2008-12-08 08:09:11 UTC (rev 3257)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java 2008-12-08 08:17:44 UTC (rev 3258)
@@ -4,8 +4,10 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
@@ -28,8 +30,6 @@
public class TaskMailTest extends AbstractJbpmTestCase
{
- private static Log log = LogFactory.getLog(TaskMailTest.class);
-
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
" <jbpm-context>" +
@@ -40,13 +40,30 @@
"</jbpm-configuration>"
);
- SimpleSmtpServer server = null;
- JbpmContext jbpmContext = null;
+ private static final int SMTP_PORT = 23583;
+
+ private static SimpleSmtpServer server;
+ private JbpmContext jbpmContext;
+ public static Test suite()
+ {
+ return new TestSetup(new TestSuite(MailTest.class))
+ {
+ protected void setUp() throws Exception
+ {
+ server = MailTest.startSmtpServer(SMTP_PORT);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ server.stop();
+ }
+ };
+ }
+
protected void setUp() throws Exception
{
super.setUp();
- server = MailTest.startSmtpServer(23583);
TestSchedulerService testSchedulerService = (TestSchedulerService) jbpmConfiguration.getServiceFactory("scheduler");
testSchedulerService.reset();
jbpmContext = jbpmConfiguration.createJbpmContext();
@@ -55,15 +72,6 @@
protected void tearDown() throws Exception
{
jbpmContext.close();
- try
- {
- server.stop();
- }
- catch (RuntimeException rte)
- {
- // This is an intermittent issue that we can safely ignore
- log.error("Cannot stop server: " + rte);
- }
super.tearDown();
}
More information about the jbpm-commits
mailing list