[werkflow-user] Small fix.

Tomasz Skutnik <[email protected]> Wed, 27 Aug 2003 15:31:35 +0200
Newsgroups gmane.comp.java.werkflow
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------030904070006050705000105
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

I've just started learing werkflow, and found bug in duplicate proces
deployment checking. Here's patch that fixes it - unit test included. It
also improves DeploymenException error message to include also package id.

Bye.

Scooter.

- --

Tomasz Skutnik, R&D Director, www.e-point.pl
tel +48 (22) 853 48 30, mob +48 501 555 705, fax +48 (22) 853 48 30
e-point S.A., ul. Filona 16, 02-658 Warsaw, Poland
PGP/GPG public key: http://scooter.ext.e-point.pl/tomasz.skutnik.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/TLK0ZH/nE/TPGGQRAowMAJ981CrpdWydbkOrHAxywVtpHmiwOgCfTtxN
fsoUYgXs1eo2QKH8FENmUNE=
=LCX/
-----END PGP SIGNATURE-----

--------------030904070006050705000105
Content-Type: text/plain;
 name="patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch.txt"

? junit982451936.properties
Index: src/java/main/org/codehaus/werkflow/admin/DeploymentException.java
===================================================================
RCS file: /scm/cvspublic/werkflow/werkflow-core/src/java/main/org/codehaus/werkflow/admin/DeploymentException.java,v
retrieving revision 1.2
diff -u -r1.2 DeploymentException.java
--- src/java/main/org/codehaus/werkflow/admin/DeploymentException.java	8 Aug 2003 13:35:52 -0000	1.2
+++ src/java/main/org/codehaus/werkflow/admin/DeploymentException.java	27 Aug 2003 13:30:10 -0000
@@ -110,6 +110,6 @@
      */
     public String getMessage()
     {
-        return "process exception: " + getProcess().getId();
+        return "package: " + getProcess().getPackageId() +", process: " + getProcess().getId();
     }
 }
Index: src/java/main/org/codehaus/werkflow/core/DeploymentManager.java
===================================================================
RCS file: /scm/cvspublic/werkflow/werkflow-core/src/java/main/org/codehaus/werkflow/core/DeploymentManager.java,v
retrieving revision 1.3
diff -u -r1.3 DeploymentManager.java
--- src/java/main/org/codehaus/werkflow/core/DeploymentManager.java	13 Aug 2003 15:48:40 -0000	1.3
+++ src/java/main/org/codehaus/werkflow/core/DeploymentManager.java	27 Aug 2003 13:30:10 -0000
@@ -94,7 +94,10 @@
     void deployProcess(ProcessDefinition processDef)
         throws DeploymentException
     {
-        if ( this.deployments.containsKey( processDef.getId() ) )
+        DeploymentKey deploymentKey = new DeploymentKey( processDef.getPackageId(),
+                                                         processDef.getId() );
+
+        if ( this.deployments.containsKey( deploymentKey ) )
         {
             throw new DuplicateProcessException( processDef );
         }
@@ -110,9 +113,7 @@
         {
             deployment.initialize();
 
-            this.deployments.put( new DeploymentKey( processDef.getPackageId(),
-                                                     processDef.getId() ),
-                                  deployment );
+            this.deployments.put( deploymentKey , deployment );
         }
         catch (Exception e)
         {
Index: src/java/test/org/codehaus/werkflow/core/DeploymentManagerTest.java
===================================================================
RCS file: /scm/cvspublic/werkflow/werkflow-core/src/java/test/org/codehaus/werkflow/core/DeploymentManagerTest.java,v
retrieving revision 1.3
diff -u -r1.3 DeploymentManagerTest.java
--- src/java/test/org/codehaus/werkflow/core/DeploymentManagerTest.java	13 Aug 2003 15:48:42 -0000	1.3
+++ src/java/test/org/codehaus/werkflow/core/DeploymentManagerTest.java	27 Aug 2003 13:30:10 -0000
@@ -47,6 +47,9 @@
  */
 
 import org.codehaus.werkflow.WerkflowTestCase;
+import org.codehaus.werkflow.admin.DuplicateProcessException;
+import org.codehaus.werkflow.definition.ProcessDefinition;
+import org.codehaus.werkflow.definition.petri.DefaultNet;
 import org.codehaus.werkflow.service.messaging.MessagingManager;
 import org.codehaus.werkflow.service.messaging.simple.SimpleMessagingManager;
 import org.codehaus.werkflow.service.persistence.PersistenceManager;
@@ -65,6 +68,19 @@
         DeploymentManager deploymentManager = new DeploymentManager( executor,
                                                                      persistManager,
                                                                      messagingManager );
+
+        ProcessDefinition processDef = new ProcessDefinition( "the.package",
+                                                              "the.process",
+                                                              new DefaultNet(),
+                                                              ProcessDefinition.InitiationType.MESSAGE );
+
+        deploymentManager.deployProcess(processDef);
+
+        try {
+            deploymentManager.deployProcess(processDef);
+            fail("Duplicated process deployment succeeded");
+        } catch (DuplicateProcessException ok_ignore) {
+        }
 
         /*
         ProcessDefinition processDef = new ProcessDefinition( "the.package",

--------------030904070006050705000105--