当前位置:主页 > 澳门威尼l斯人网址正文

澳门威尼l斯人网址_一起听吧网进入

03月18日作者:黑曼巴


第一步:jpdl.xml文件

${task.name}

Your move request is approved!

Employee name ${employeeName} and request details

${requestDetails}

Your move request is rejected!

Employee name ${employeeName} and request details ${requestDetails}

第二步:

jbpm.mial.properties设置设置设备摆设摆设文件,设置设置设备摆设摆设邮件属性

mail.smtp.hostlocalhost

mail.smtp.port 2525

mail.fromshusanzhan@163.com

##mail.smtps.starttls.enable=true

##mail.smtps.auth=true

##mail.smtp.port=465

#mail.transport.protocol=smtps

#mail.from=myemail@gmail.com

#mail.user=myemail

##mail.smtp.quitwait=false

#mail.debug=true

第三步:

jbpm.mail.template.example.xml设置设置设备摆设摆设邮件模板等

rectify ${newspaper}

${newspaper} ${date} ${details}

${task.name}

${task.name}

其它设置设置设备摆设摆设文件不用改动

第四 测试法度榜样java法度榜样:

package com.mail.notification;

import java.io.IOException;

import java.util.Arrays;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import javax.jms.MessageEOFException;

import javax.mail.Address;

import javax.mail.Message;

import javax.mail.MessagingException;

import javax.mail.internet.MimeMessage.RecipientType;

import org.jboss.util.platform.PID;

import org.jbpm.api.Execution;

import org.jbpm.api.ProcessInstance;

import org.jbpm.api.task.Task;

import org.jbpm.pvm.internal.email.impl.MailSessionImpl;

import org.jbpm.pvm.internal.email.spi.MailSession;

import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;

import org.jbpm.test.JbpmTestCase;

import org.subethamail.wiser.Wiser;

import org.subethamail.wiser.WiserMessage;

public class NotificationTest extends JbpmTestCase {

Wiser wiser=new Wiser();

protected void setUp() throws Exception{

super.setUp();

String deploymentId=repositoryService.createDeployment().

addResourceFromClasspath("com/mail/notification/move.jpdl.xml").deploy();

registerDeployment(deploymentId);

wiser.setPort(2525);

wiser.start();

}

protected void tearDown()throws Exception {

wiser.stop();

super.tearDown();

}

public void testNotificationTest() throws MessageEOFException,IOException, MessagingException{

Map variables=new HashMap();

String lmEmail="shusanzhan24@163.com";

String rqLoginName="shusanzhan";

String employeeName="zhangsan";

String requestDetails="Must to do id";

String toEail="shusanzhan2010@163.com";

variables.put("lmEmail", lmEmail);

variables.put("reqLoginName", rqLoginName);

variables.put("employeeName", employeeName);

variables.put("requestDetails", requestDetails);

variables.put("toEmail",toEail);

Pro澳门威尼l斯人网址cessInstance processInstance=executionService.startProcessInstanceByKey("moves", variables);

String piId=processInstance.getId();

List listTasks=taskService.findPersonalTasks("sanshu");

assertEquals(1, listTasks.size());

List listWiserMessages=wiser.getMessages();

assertEquals(2, listWiserMessages.size());

processInstance=executionService.findProcessInstanceById(piId);

assertEquals(true, processInstance.isActive("Request_New_Move"));

if(processInstance.isActive("Request_New_Move")){

taskService.completeTask(listTasks.get(0).getId());

}

assertEquals(true,processInstance.isActive("Request_New_Move"));

for(WiserMessage wisMessage:listWiserMessages){

Message message=wisMessage.getMimeMessage();

Address[] from=message.getFrom();

assertEquals(1, from.length);

assertEquals("shusanzhan@163.com",from[0].toString());

Address[] to=message.getRecipients(Recipient澳门威尼l斯人网址Type.TO);

assertEquals(1, to.length);

assertEquals("shusanzhan2010@163.com",to[0].toString());

Address[] cc=message.getRecipients(RecipientType.CC);

assertEquals(1,cc.length);

assertEquals("shusanzhan24@163.com",cc[0].toString());

String subject=message.getSubject();

assertEquals("Request_New_Move", subject);

String text=message.getContent().toString();

System.out.println("=================>Text content :"+text);

}

processInstance=executionService.findProcessInstanceById澳门威尼l斯人网址(piId);

listTasks=taskService.findPersonalTasks(rqLoginName);

assertEquals(1, listTasks.size());

assertEquals(true, processInstance.isActive("Line_Manager_review"澳门威尼l斯人网址));

if(processInstance.isActive("Line_Manager_review")){

taskService.completeTask(listTasks.get(0).getId(),"approve");

}

assertEquals(true,processInstance.isActive("Line_Manager_review"));

System.out.println("=========>"+processInstance.getExecution("Send_approval_email"));

listWiserMessages=wiser.getMessages();

assertEquals(4, listWiserMessages.size());//4是全部流程中所发的信息

for(int i=2;i"+text);

}

assertEquals(true, processInstance.isActive("Line_Manager_review"));

//assertEquals(true, processInstance.isEnded());

//Execution execution=executionService.findExecutionById(listTasks.get(0).getId());

//if(execution.getProcessInstance().isActive("Request_New_Move")){

//taskService.completeTask(listTasks.get(0).getId());

//}

}

}

转自:http://shusanzhan.java澳门威尼l斯人网址eye.com/blog/604321

最近关注

热点内容

更多