[jbpm-commits] JBoss JBPM SVN: r3262 - 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 05:42:35 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-12-08 05:42:35 -0500 (Mon, 08 Dec 2008)
New Revision: 3262
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:
Rollback -r3258: 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 10:34:37 UTC (rev 3261)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java 2008-12-08 10:42:35 UTC (rev 3262)
@@ -7,6 +7,8 @@
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;
@@ -20,10 +22,12 @@
public class MailTest extends AbstractJbpmTestCase
{
+ private static Log log = LogFactory.getLog(MailTest.class);
+
private static final int SMTP_PORT = 23583;
private static SimpleSmtpServer server;
- private JbpmContext jbpmContext;
+ JbpmContext jbpmContext;
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
@@ -61,19 +65,21 @@
super.tearDown();
}
- public static SimpleSmtpServer startSmtpServer(int port)
+ 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 10:34:37 UTC (rev 3261)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java 2008-12-08 10:42:35 UTC (rev 3262)
@@ -4,10 +4,8 @@
import java.util.Iterator;
import java.util.List;
-import junit.extensions.TestSetup;
-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;
@@ -30,6 +28,8 @@
public class TaskMailTest extends AbstractJbpmTestCase
{
+ private static Log log = LogFactory.getLog(TaskMailTest.class);
+
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
" <jbpm-context>" +
@@ -40,30 +40,13 @@
"</jbpm-configuration>"
);
- private static final int SMTP_PORT = 23583;
-
- private static SimpleSmtpServer server;
- private JbpmContext jbpmContext;
+ SimpleSmtpServer server = null;
+ JbpmContext jbpmContext = null;
- 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();
@@ -72,6 +55,15 @@
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