[jbpm-commits] JBoss JBPM SVN: r3149 - in jbpm3/trunk/modules: integration/jboss42 and 10 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Nov 28 10:12:12 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-28 10:12:12 -0500 (Fri, 28 Nov 2008)
New Revision: 3149
Added:
jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/fork-join-example.par
jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/
jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/DeploymentXMLTest.java
jbpm3/trunk/modules/integration/spec/src/test/resources/deployment/
jbpm3/trunk/modules/integration/spec/src/test/resources/deployment/simple-process.xml
Removed:
jbpm3/trunk/modules/integration/spec/src/test/resources/integration/
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/IoUtil.java
jbpm3/trunk/modules/integration/jboss42/pom.xml
jbpm3/trunk/modules/integration/jboss42/src/test/java/org/jbpm/test/integration/deployment/SimpleDeploymentTest.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/deployment/PARDeployment.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/DeploymentServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/jpdl/DialectHandlerTest.java
Log:
More deployment testing
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/IoUtil.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -26,36 +26,40 @@
import java.io.InputStream;
import java.io.OutputStream;
-import org.jbpm.JbpmException;
+public class IoUtil
+{
+ private static final int BUFFERSIZE = 4096;
-public class IoUtil {
-
- private IoUtil() {
- // hide default constructor to prevent instantiation
+ // hide default constructor
+ private IoUtil()
+ {
}
- private static final int BUFFERSIZE = 4096;
-
- public static byte[] readBytes(InputStream inputStream) throws IOException {
- byte[] bytes = null;
- if (inputStream==null) {
- throw new JbpmException("inputStream is null");
- }
+ public static byte[] readBytes(InputStream inputStream) throws IOException
+ {
+ if (inputStream == null)
+ throw new IllegalArgumentException("InputStream cannot be null");
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
transfer(inputStream, outputStream);
- bytes = outputStream.toByteArray();
+ byte[] bytes = outputStream.toByteArray();
outputStream.close();
return bytes;
}
-
- public static int transfer(InputStream in, OutputStream out) throws IOException {
+
+ public static int transfer(InputStream in, OutputStream out) throws IOException
+ {
+ if (in == null || out == null)
+ throw new IllegalArgumentException("In/OutStream cannot be null");
+
int total = 0;
byte[] buffer = new byte[BUFFERSIZE];
- int bytesRead = in.read( buffer );
- while ( bytesRead != -1 ) {
- out.write( buffer, 0, bytesRead );
+ int bytesRead = in.read(buffer);
+ while (bytesRead != -1)
+ {
+ out.write(buffer, 0, bytesRead);
total += bytesRead;
- bytesRead = in.read( buffer );
+ bytesRead = in.read(buffer);
}
return total;
}
Modified: jbpm3/trunk/modules/integration/jboss42/pom.xml
===================================================================
--- jbpm3/trunk/modules/integration/jboss42/pom.xml 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/jboss42/pom.xml 2008-11-28 15:12:12 UTC (rev 3149)
@@ -75,6 +75,12 @@
<!-- Test Dependencies -->
<dependency>
+ <groupId>org.jbpm.jbpm3</groupId>
+ <artifactId>bpm-spec-integration-jbpm3</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.client</groupId>
<artifactId>jbossall-client</artifactId>
<scope>test</scope>
Modified: jbpm3/trunk/modules/integration/jboss42/src/test/java/org/jbpm/test/integration/deployment/SimpleDeploymentTest.java
===================================================================
--- jbpm3/trunk/modules/integration/jboss42/src/test/java/org/jbpm/test/integration/deployment/SimpleDeploymentTest.java 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/jboss42/src/test/java/org/jbpm/test/integration/deployment/SimpleDeploymentTest.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -33,16 +33,26 @@
*/
public class SimpleDeploymentTest extends IntegrationTestCase
{
- String PAR_ARCHIVE = "simple/simple-process.xml";
+ String PAR_DEPLOYMENT = "simple/fork-join-example.par";
+ String XML_DEPLOYMENT = "simple/simple-process.xml";
- public void testSimpleDeploy() throws Exception
+ public void testSimpleXMLDeploy() throws Exception
{
- deploy(getResourceURL(PAR_ARCHIVE));
+ deploy(getResourceURL(XML_DEPLOYMENT));
+ }
+ public void testSimpleXMLUndeploy() throws Exception
+ {
+ undeploy(getResourceURL(XML_DEPLOYMENT));
}
- public void testSimpleUndeploy() throws Exception
+ public void _testSimplePARDeploy() throws Exception
{
- undeploy(getResourceURL(PAR_ARCHIVE));
+ deploy(getResourceURL(PAR_DEPLOYMENT));
}
+
+ public void _testSimplePARUndeploy() throws Exception
+ {
+ undeploy(getResourceURL(PAR_DEPLOYMENT));
+ }
}
Added: jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/fork-join-example.par
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/fork-join-example.par
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/deployment/PARDeployment.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/deployment/PARDeployment.java 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/deployment/PARDeployment.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -23,14 +23,16 @@
// $Id$
-import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.jbpm.util.IoUtil;
+
/**
- * An in-memory persistence service.
+ * An abstraction of a process deployment
*
* @author thomas.diesler at jboss.com
* @since 17-Sep-2008
@@ -47,37 +49,27 @@
public String getProcessDefinitionXML() throws IOException
{
- String pdXML = null;
-
- ZipInputStream zip = new ZipInputStream(pdURL.openStream());
- ZipEntry zipEntry = zip.getNextEntry();
- String entryName = zipEntry.getName();
- if (PROCESSDEFINITION_ENTRY.equals(entryName))
+ byte[] bytes = IoUtil.readBytes(pdURL.openStream());
+ System.out.println(bytes.length);
+
+ ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(bytes));
+ ZipEntry zipEntry = zipInputStream.getNextEntry();
+ while (zipEntry != null)
{
- long size = zipEntry.getSize();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- byte[] bytes = new byte[4096];
- int len = (int)Math.min(4096, size);
- while (len > 0)
+ String entryName = zipEntry.getName();
+ bytes = IoUtil.readBytes(zipInputStream);
+ if (bytes != null)
{
- int read = zip.read(bytes, 0, len);
- baos.write(bytes, 0, read);
-
- size = size - read;
- len = (int)Math.min(4096, size);
+ addAttachment(entryName, bytes);
}
-
- pdXML = new String(baos.toByteArray());
+ zipEntry = zipInputStream.getNextEntry();
}
- else
- {
- zip.skip(zipEntry.getSize());
- }
- if (pdXML == null)
+ byte[] pdBytes = (byte[])getAttachment(PROCESSDEFINITION_ENTRY);
+ if (pdBytes == null)
throw new IllegalStateException("Cannot obtain '" + PROCESSDEFINITION_ENTRY + "' from: " + pdURL);
+ String pdXML = new String(pdBytes);
return pdXML;
}
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/DeploymentServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/DeploymentServiceImpl.java 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/DeploymentServiceImpl.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -75,7 +75,7 @@
}
@Override
- public ObjectName deploy(Deployment dep)
+ public ProcessDefinition deploy(Deployment dep)
{
try
{
@@ -89,7 +89,7 @@
ObjectName key = procDef.getKey();
dep.addAttachment(ObjectName.class, "procDefKey", key);
- return key;
+ return procDef;
}
catch (IOException ex)
{
@@ -98,10 +98,10 @@
}
@Override
- public void undeploy(Deployment dep)
+ public boolean undeploy(Deployment dep)
{
ObjectName key = dep.getAttachment(ObjectName.class, "procDefKey");
ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
- pdService.unregisterProcessDefinition(key);
+ return pdService.unregisterProcessDefinition(key);
}
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-11-28 15:12:12 UTC (rev 3149)
@@ -13,8 +13,9 @@
<bean name="BPMProcessEngine" class="org.jbpm.integration.client.ProcessEngineImpl">
<property name="services">
<set elementClass="org.jboss.bpm.api.service.Service">
+ <inject bean="BPMDeploymentService"/>
+ <inject bean="BPMDialectHandlerService"/>
<inject bean="BPMIdentityService"/>
- <inject bean="BPMDialectHandlerService"/>
<inject bean="BPMProcessBuilderService"/>
<inject bean="BPMProcessDefinitionService"/>
<inject bean="BPMProcessService"/>
@@ -47,6 +48,7 @@
<bean name="BPMDialectHandlerJPDL32" class="org.jbpm.integration.jpdl32.DialectHandlerImpl" />
<!-- Other Services -->
+ <bean name="BPMDeploymentService" class="org.jbpm.integration.service.DeploymentServiceImpl" />
<bean name="BPMIdentityService" class="org.jbpm.integration.service.IdentityServiceImpl" />
<bean name="BPMProcessBuilderService" class="org.jbpm.integration.service.ProcessBuilderServiceImpl" />
<bean name="BPMProcessDefinitionService" class="org.jbpm.integration.service.ProcessDefinitionServiceImpl" />
Added: jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/DeploymentXMLTest.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/DeploymentXMLTest.java (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/DeploymentXMLTest.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.integration.deployment;
+
+// $Id$
+
+import java.net.URL;
+
+import org.jboss.bpm.api.deployment.Deployment;
+import org.jboss.bpm.api.model.Process;
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.Process.ProcessStatus;
+import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.DeploymentService;
+import org.jboss.bpm.api.test.APITestCase;
+
+/**
+ * Test simple jPDL process deployment
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Nov-2008
+ */
+public class DeploymentXMLTest extends APITestCase
+{
+ public void testSimpleXMLDeploy() throws Exception
+ {
+ URL pdURL = getResourceURL("deployment/simple-process.xml");
+
+ DeploymentService depService = getProcessEngine().getService(DeploymentService.class);
+ Deployment dep = depService.createDeployment(pdURL);
+
+ ProcessDefinition procDef = depService.deploy(dep);
+ assertNotNull("ProcDef not null", procDef);
+
+ Process proc = procDef.newInstance();
+
+ Token token = proc.startProcess();
+ assertEquals("Node name", "a", token.getCurrentNode().getName());
+
+ token.signal();
+ assertEquals("Node name", "b", token.getCurrentNode().getName());
+
+ token.signal();
+ assertEquals("Node name", "c", token.getCurrentNode().getName());
+
+ token.signal();
+ assertEquals("Node name", "end", token.getCurrentNode().getName());
+
+ assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
+
+ // Undeploy the process
+ assertTrue("Undeploy successful", depService.undeploy(dep));
+ }
+}
Property changes on: jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/deployment/DeploymentXMLTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/jpdl/DialectHandlerTest.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/jpdl/DialectHandlerTest.java 2008-11-28 15:07:23 UTC (rev 3148)
+++ jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/jpdl/DialectHandlerTest.java 2008-11-28 15:12:12 UTC (rev 3149)
@@ -44,7 +44,7 @@
{
public void testSimple() throws Exception
{
- URL pdXML = getResourceURL("integration/jpdl/simple-process.xml");
+ URL pdXML = getResourceURL("deployment/simple-process.xml");
ProcessEngine engine = Configuration.getProcessEngine();
ProcessDefinitionService pdService = engine.getService(ProcessDefinitionService.class);
Copied: jbpm3/trunk/modules/integration/spec/src/test/resources/deployment/simple-process.xml (from rev 3138, jbpm3/trunk/modules/integration/spec/src/test/resources/integration/jpdl/simple-process.xml)
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/test/resources/deployment/simple-process.xml (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/test/resources/deployment/simple-process.xml 2008-11-28 15:12:12 UTC (rev 3149)
@@ -0,0 +1,16 @@
+<process-definition name="simpleProcess" xmlns="urn:jbpm.org:jpdl-3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
+ <start-state name='start'>
+ <transition to='a' />
+ </start-state>
+ <state name='a'>
+ <transition to='b' />
+ </state>
+ <state name='b'>
+ <transition to='c' />
+ </state>
+ <state name='c'>
+ <transition to='end' />
+ </state>
+ <end-state name='end' />
+</process-definition>
More information about the jbpm-commits
mailing list