[jbpm-commits] JBoss JBPM SVN: r6529 - in jbpm4/trunk/modules: pvm/src/test/java/org/jbpm/pvm/internal/wire and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jul 23 22:20:57 EDT 2010
Author: rebody
Date: 2010-07-23 22:20:57 -0400 (Fri, 23 Jul 2010)
New Revision: 6529
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/MailTest.java
Log:
correct refBinding parse error message and related testcase.
provide a testcase for custom MailProducer by http://community.jboss.org/message/554222#554222
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java 2010-07-23 16:47:23 UTC (rev 6528)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java 2010-07-24 02:20:57 UTC (rev 6529)
@@ -48,7 +48,7 @@
descriptor.setType(element.getAttribute("type"));
} else {
- parse.addProblem("ref must have object attribute: "+XmlUtil.toString(element), element);
+ parse.addProblem("ref must have object or type attribute: "+XmlUtil.toString(element), element);
}
return descriptor;
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2010-07-23 16:47:23 UTC (rev 6528)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2010-07-24 02:20:57 UTC (rev 6529)
@@ -58,13 +58,13 @@
);
assertNotNull(problems);
assertEquals(1, problems.size());
- assertTextPresent("ref must have object attribute: ", problems.get(0).getMsg());
+ assertTextPresent("ref must have object or type attribute: ", problems.get(0).getMsg());
}
public void testReferenceInList() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='o' class='"+Object.class.getName()+"' />" +
+ " <object name='o' class='" + Object.class.getName() + "' />" +
" <list name='l'>" +
" <ref object='o' />" +
" </list>" +
@@ -83,7 +83,7 @@
public void testReferenceInMap() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='o' class='"+Object.class.getName()+"' />" +
+ " <object name='o' class='" + Object.class.getName() + "' />" +
" <map name='m'>" +
" <entry>" +
" <key>" +
@@ -109,7 +109,7 @@
public void testReferenceInSet() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='o' class='"+Object.class.getName()+"' />" +
+ " <object name='o' class='" + Object.class.getName() + "' />" +
" <set name='s'>" +
" <ref object='o' />" +
" </set>" +
@@ -151,7 +151,7 @@
public void testConstructorArgument() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='x' class='"+X.class.getName()+"'>" +
+ " <object name='x' class='" + X.class.getName() + "'>" +
" <constructor>" +
" <arg><ref object='AMS' /></arg>" +
" </constructor>" +
@@ -167,7 +167,7 @@
public void testFieldArgument() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='x' class='"+X.class.getName()+"'>" +
+ " <object name='x' class='" + X.class.getName() + "'>" +
" <field name='fieldValue'><ref object='AMS' /></field>" +
" </object>" +
" <string name='AMS' value='xxx' />" +
@@ -181,7 +181,7 @@
public void testPropertyArgument() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='x' class='"+X.class.getName()+"'>" +
+ " <object name='x' class='" + X.class.getName() + "'>" +
" <property name='p'><ref object='AMS' /></property>" +
" </object>" +
" <string name='AMS' value='xxx' />" +
@@ -195,7 +195,7 @@
public void testInvokeArgument() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <object name='x' class='"+X.class.getName()+"'>" +
+ " <object name='x' class='" + X.class.getName() + "'>" +
" <invoke method='invoke'>" +
" <arg><ref object='AMS' /></arg>" +
" <arg><ref object='HAM' /></arg>" +
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/MailTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/MailTest.java 2010-07-23 16:47:23 UTC (rev 6528)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/MailTest.java 2010-07-24 02:20:57 UTC (rev 6529)
@@ -1,72 +1,129 @@
-/*
- * 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.activity.mail;
-
-import java.util.List;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.test.JbpmTestCase;
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-
-/**
- * @author Tom Baeyens
- */
-public class MailTest extends JbpmTestCase {
-
- private Wiser wiser;
-
- protected void setUp() throws Exception {
- super.setUp();
- // start mail server
- wiser = new Wiser();
- wiser.setPort(2525);
- wiser.start();
- }
-
- protected void tearDown() throws Exception {
- // stop mail server
- wiser.stop();
- super.tearDown();
- }
-
- public void testMailToPlainAddress() {
- deployJpdlXmlString("<process name='plainaddress' xmlns='http://jbpm.org/4.3/jpdl'>"
- + " <start>"
- + " <transition to='mailtestmail' />"
- + " </start>"
- + " <mail name='mailtestmail'>"
- + " <to addresses='jos at rubensstraat' />"
- + " <subject>mail</subject>"
- + " <text>youhoooo</text>"
- + " <transition to='end' />"
- + " </mail>"
- + " <end name='end'/>"
- + "</process>");
- ProcessInstance processInstance = executionService
- .startProcessInstanceByKey("plainaddress");
- assertProcessInstanceEnded(processInstance);
-
- List<WiserMessage> messages = wiser.getMessages();
- assertEquals(1, messages.size());
- }
-}
+/*
+ * 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.activity.mail;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import javax.mail.Message;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.test.JbpmTestCase;
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+/**
+ * @author Tom Baeyens
+ * @author Huisheng Xu
+ */
+public class MailTest extends JbpmTestCase {
+
+ private Wiser wiser;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // start mail server
+ wiser = new Wiser();
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+ super.tearDown();
+ }
+
+ public void testMailToPlainAddress() {
+ deployJpdlXmlString("<process name='plainaddress' xmlns='http://jbpm.org/4.4/jpdl'>"
+ + " <start>"
+ + " <transition to='mailtestmail' />"
+ + " </start>"
+ + " <mail name='mailtestmail'>"
+ + " <to addresses='jos at rubensstraat' />"
+ + " <subject>mail</subject>"
+ + " <text>youhoooo</text>"
+ + " <transition to='end' />"
+ + " </mail>"
+ + " <end name='end'/>"
+ + "</process>");
+ ProcessInstance processInstance = executionService
+ .startProcessInstanceByKey("plainaddress");
+ assertProcessInstanceEnded(processInstance);
+
+ List<WiserMessage> messages = wiser.getMessages();
+ assertEquals(1, messages.size());
+ }
+
+ public void testMailWithFactory() {
+ deployJpdlXmlString("<process name='mail_with_factory' xmlns='http://jbpm.org/4.4/jpdl'>"
+ + " <start>"
+ + " <transition to='send mail' />"
+ + " </start>"
+ + " <mail name='send mail' class='" + AuditMailProducer.class.getName() + "'>"
+ + " <property name='template'>"
+ + " <object method='getTemplate'>"
+ + " <factory><ref type='org.jbpm.pvm.internal.email.impl.MailTemplateRegistry'/></factory>"
+ + " <arg><string value='task-notification'/></arg>"
+ + " </object>"
+ + " </property>"
+ + " <property name='auditGroup'><string value='thinkpol'/></property>"
+ + " <transition to='wait' />"
+ + " </mail>"
+ + " <state name='wait'>"
+ + " <transition to='end'/>"
+ + " </state>"
+ + " <end name='end'/>"
+ + "</process>");
+ ProcessInstance processInstance = executionService
+ .startProcessInstanceByKey("mail_with_factory");
+
+ assertNotNull(executionService.getVariable(processInstance.getId(), "mailTemplate"));
+ }
+
+ public static class AuditMailProducer implements MailProducer {
+
+ private static final Log log = Log.getLog(AuditMailProducer.class.getName());
+
+ private MailTemplate mailTemplate;
+ private String auditGroup;
+ public Collection<Message> produce(Execution execution) {
+ log.info("MailTemplate : " + mailTemplate + ", auditGroup : " + auditGroup);
+
+ ((ExecutionImpl) execution).setVariable("mailTemplate", mailTemplate);
+
+ return Collections.EMPTY_SET;
+ }
+ public void setTemplate(MailTemplate mailTemplate) {
+ this.mailTemplate = mailTemplate;
+ }
+ public void setAuditGroup(String auditGroup) {
+ this.auditGroup = auditGroup;
+ }
+ }
+}
+
More information about the jbpm-commits
mailing list