[jbpm-commits] JBoss JBPM SVN: r4877 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/task/notification and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat May 23 09:48:09 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-05-23 09:48:09 -0400 (Sat, 23 May 2009)
New Revision: 4877
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
Modified:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
JBPM-2254: task reminder example, plus amendments to JpdlExecution.getExtension
Deleted: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -1,99 +0,0 @@
-/*
- * 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.examples.task.notification;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.Message.RecipientType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-
-import org.jbpm.examples.task.assignee.Order;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class MailNotificationTest extends JbpmTestCase {
-
- Wiser wiser = new Wiser();
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // deploy process
- long deploymentDbid = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
- .deploy();
- registerDeployment(deploymentDbid);
-
- // create actors
- identityService.createUser("johndoe", "John", "Doe", "john at doe");
-
- // start mail server
- wiser.setPort(2525);
- wiser.start();
- }
-
- protected void tearDown() throws Exception {
- // stop mail server
- wiser.stop();
-
- // delete actors
- identityService.deleteUser("johndoe");
-
- super.tearDown();
- }
-
- public void testTaskNotification() throws MessagingException, IOException {
- Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
- executionService.startProcessInstanceByKey("TaskAssignee", variables);
-
- // examine produced messages
- List<WiserMessage> wiserMessages = wiser.getMessages();
- assertEquals(1, wiserMessages.size());
-
- WiserMessage wiserMessage = wiserMessages.get(0);
- MimeMessage message = wiserMessage.getMimeMessage();
- // from
- Address[] from = message.getFrom();
- assertEquals(1, from.length);
- assertEquals("noreply at jbpm.org", from[0].toString());
- // to
- Address[] expectedTo = InternetAddress.parse("john at doe");
- Address[] to = message.getRecipients(RecipientType.TO);
- assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
- // subject
- assertEquals("review", message.getSubject());
- // text
- assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
- }
-}
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java (from rev 4867, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,104 @@
+/*
+ * 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.examples.task.notification;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+import org.jbpm.examples.task.assignee.Order;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskNotificationTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // deploy process
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
+ .deploy();
+ registerDeployment(deploymentDbid);
+
+ // create actors
+ identityService.createUser("johndoe", "John", "Doe", "john at doe");
+
+ // start mail server
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+
+ // delete actors
+ identityService.deleteUser("johndoe");
+
+ super.tearDown();
+ }
+
+ public void testTaskNotification() throws MessagingException, IOException {
+ Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
+ executionService.startProcessInstanceByKey("TaskNotification", variables);
+
+ // examine produced messages
+ List<WiserMessage> wiserMessages = wiser.getMessages();
+ assertEquals(1, wiserMessages.size());
+
+ // only one message
+ WiserMessage wiserMessage = wiserMessages.get(0);
+ MimeMessage message = wiserMessage.getMimeMessage();
+
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply at jbpm.org", from[0].toString());
+
+ // to
+ Address[] expectedTo = InternetAddress.parse("john at doe");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+
+ // subject
+ assertEquals("review", message.getSubject());
+
+ // text
+ assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
+ }
+}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,135 @@
+/*
+ * 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.examples.task.reminder;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.examples.task.assignee.Order;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskReminderTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // deploy process
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/task/reminder/process.jpdl.xml")
+ .deploy();
+ registerDeployment(deploymentDbid);
+
+ // create actors
+ identityService.createUser("johndoe", "John", "Doe", "john at doe");
+
+ // start mail server
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+
+ // delete actors
+ identityService.deleteUser("johndoe");
+
+ super.tearDown();
+ }
+
+ public void testTaskReminder() throws MessagingException, IOException {
+ Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskReminder", variables);
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ // timer was produced, no messages yet
+ assertNotNull("expected job to be non-null", job);
+ assertEquals(0, wiser.getMessages().size());
+
+ managementService.executeJob(job.getDbid());
+
+ // examine produced messages
+ List<WiserMessage> wiserMessages = wiser.getMessages();
+ assertEquals(1, wiserMessages.size());
+
+ // only one message
+ WiserMessage wiserMessage = wiserMessages.get(0);
+ MimeMessage message = wiserMessage.getMimeMessage();
+
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply at jbpm.org", from[0].toString());
+
+ // to
+ Address[] expectedTo = InternetAddress.parse("john at doe");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+
+ // subject
+ assertEquals("review", message.getSubject());
+
+ // text
+ assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
+
+ // get task list
+ List<Task> taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(1, taskList.size());
+
+ // only one task
+ Task task = taskList.get(0);
+ assertEquals("review", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+
+ // submit task
+ taskService.completeTask(task.getDbid());
+
+ // timer should be gone
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+ assertNull("expected timer to be null", job);
+ }
+}
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-23 13:48:09 UTC (rev 4877)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="TaskAssignee">
+<process name="TaskNotification">
<start g="20,20,48,48">
<transition to="review"/>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="TaskReminder">
+
+ <start g="20,20,48,48">
+ <transition to="review"/>
+ </start>
+
+ <task name="review"
+ assignee="#{order.owner}"
+ g="96,16,127,52">
+ <reminder duedate="2 days" repeat="1 day"/>
+ <transition to="wait"/>
+ </task>
+
+ <state name="wait" g="255,16,88,52"/>
+
+</process>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -54,16 +54,24 @@
protected Map<String, SwimlaneImpl> swimlanes;
+ @Override
public <T> T getExtension(Class<T> extensionClass) {
if (extensionClass==null) {
throw new JbpmException("extensionClass is null");
}
- if (extensionClass == JpdlExecution.class) {
+ if (JpdlExecution.class.isAssignableFrom(extensionClass)) {
+ if (dbid == 0L) return extensionClass.cast(this);
+
Session session = Environment.getFromCurrent(Session.class);
return extensionClass.cast(session.load(JpdlExecution.class, dbid));
}
throw new JbpmException("unsupported extension "+extensionClass.getName());
}
+
+ @Override
+ protected ExecutionImpl newChildExecution() {
+ return new JpdlExecution();
+ }
// tasks ////////////////////////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -493,7 +493,7 @@
Element reminderElement = XmlUtil.element(element, "reminder");
if (reminderElement != null) {
- parseMailEvent(notificationElement, parse, scopeElement, Event.REMIND);
+ parseMailEvent(reminderElement, parse, scopeElement, Event.REMIND);
// associate timer to event
TimerDefinitionImpl timerDefinition = parseTimerDefinition(reminderElement, parse, scopeElement);
timerDefinition.setEventName(Event.REMIND);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -997,7 +997,7 @@
if (extensionClass==null) {
throw new JbpmException("extensionClass is null. and this execution doesn't support extensions");
}
- throw new JbpmException("unsuppported extension "+extensionClass.getName());
+ throw new JbpmException("unsupported extension "+extensionClass.getName());
}
/** notification of this execution being deleted. this allows for
More information about the jbpm-commits
mailing list