[jbpm-commits] JBoss JBPM SVN: r2917 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704: jpdl/jar/src/test/java/org/jbpm/db and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 13 12:29:49 EST 2008


Author: alex.guizar at jboss.com
Date: 2008-11-13 12:29:49 -0500 (Thu, 13 Nov 2008)
New Revision: 2917

Added:
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Semaphore.java
Modified:
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/db/AbstractDbTestCase.java
Log:
removed dependencies on jdk 5 apis

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java	2008-11-13 17:00:09 UTC (rev 2916)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java	2008-11-13 17:29:49 UTC (rev 2917)
@@ -25,8 +25,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
 
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
@@ -109,7 +107,7 @@
     log.debug("waiting for " + event);
     Semaphore eventSemaphore = getEventSemaphore(event);
     try {
-      if (eventSemaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+      if (eventSemaphore.tryAcquire(timeout)) {
         log.debug("received '" + event + "' notification");
       }
       else {
@@ -143,4 +141,4 @@
       }
     }
   }
-}
\ No newline at end of file
+}

Added: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Semaphore.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Semaphore.java	                        (rev 0)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Semaphore.java	2008-11-13 17:29:49 UTC (rev 2917)
@@ -0,0 +1,44 @@
+package org.jbpm.enterprise.test;
+
+/**
+ * Trivial semaphore which borrows the interface of java.util.concurrent.Semaphore.
+ */
+class Semaphore {
+
+  private int permits;
+
+  public Semaphore(int permits) {
+    this.permits = permits;
+  }
+
+  public void release() {
+    release(1);
+  }
+
+  public synchronized void release(int permits) {
+    this.permits += permits;
+    notifyAll();
+  }
+
+  public boolean tryAcquire(long timeout) throws InterruptedException {
+    return tryAcquire(1, timeout);
+  }
+
+  public synchronized boolean tryAcquire(int permits, long timeout) throws InterruptedException {
+    long startTime = System.currentTimeMillis();
+    while (this.permits < permits && System.currentTimeMillis() - startTime < timeout) {
+      wait(timeout);
+    }
+    if (this.permits >= permits) {
+      this.permits -= permits;
+      return true;
+    }
+    return false;
+  }
+
+  public synchronized int drainPermits() {
+    int permits = this.permits;
+    this.permits = 0;
+    return permits;
+  }
+}

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/db/AbstractDbTestCase.java	2008-11-13 17:00:09 UTC (rev 2916)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/db/AbstractDbTestCase.java	2008-11-13 17:29:49 UTC (rev 2917)
@@ -67,12 +67,12 @@
 		initializeMembers();
 
 		log.debug("");
-		log.debug("### starting " + this.getClass().getCanonicalName() + "."
+		log.debug("### starting " + this.getClass().getName() + "."
 				+ getName() + " ####################################################");
 	}
 
 	public void tearDown() throws Exception {
-		log.debug("### " + this.getClass().getCanonicalName() + "." + getName()
+		log.debug("### " + this.getClass().getName() + "." + getName()
 				+ " done ####################################################");
 		resetMembers();
 		closeJbpmContext();




More information about the jbpm-commits mailing list