[jbpm-commits] JBoss JBPM SVN: r2589 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Oct 22 20:31:05 EDT 2008


Author: alex.guizar at jboss.com
Date: 2008-10-22 20:31:05 -0400 (Wed, 22 Oct 2008)
New Revision: 2589

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:
workaround for dumbster hanging during smtp server start under linux (f9) - see http://markmail.org/message/fdw3lwu22qwuuo7d for details

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-10-22 18:56:22 UTC (rev 2588)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/MailTest.java	2008-10-23 00:31:05 UTC (rev 2589)
@@ -37,10 +37,33 @@
   protected void setUp() throws Exception
   {
     super.setUp();
-    server = SimpleSmtpServer.start(23583);
+    server = startSmtpServer(23583);
     jbpmContext = jbpmConfiguration.createJbpmContext();
   }
 
+  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) {
+      serverThread.start();
+      try {
+        server.wait(10 * 1000);
+      } catch (InterruptedException e) {
+        // Ignore don't care.
+      }
+    }
+    return server;
+  }
+
   protected void tearDown() throws Exception
   {
     jbpmContext.close();

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-10-22 18:56:22 UTC (rev 2588)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mail/TaskMailTest.java	2008-10-23 00:31:05 UTC (rev 2589)
@@ -42,7 +42,7 @@
   protected void setUp() throws Exception
   {
     super.setUp();
-    server = SimpleSmtpServer.start(23583);
+    server = MailTest.startSmtpServer(23583);
     jbpmContext = jbpmConfiguration.createJbpmContext();
   }
 




More information about the jbpm-commits mailing list