1 5 6 package org.exoplatform.services.workflow.test; 7 8 import java.io.IOException ; 9 import java.io.InputStream ; 10 import java.net.URL ; 11 12 import org.exoplatform.container.PortalContainer; 13 import org.exoplatform.services.exception.ExoServiceException; 14 import org.exoplatform.services.workflow.*; 15 import org.exoplatform.test.BasicTestCase; 16 import org.jbpm.JpdlException; 17 import org.jbpm.par.ArchiveBuilder; 18 19 20 21 26 public abstract class BaseTest extends BasicTestCase { 27 28 protected static final String PROCESS_PATH = "file:./src/conf/processes/"; 29 protected WorkflowServiceContainer workflowServiceContainer; 30 protected WorkflowFormsService workflowFormsService; 31 32 public BaseTest(String name) { 33 super(name); 34 } 35 36 public void setUp() { 37 workflowServiceContainer = (WorkflowServiceContainer) PortalContainer. 38 getInstance().getComponentInstanceOfType(WorkflowServiceContainer.class); 39 workflowFormsService = (WorkflowFormsService) PortalContainer. 40 getInstance().getComponentInstanceOfType(WorkflowFormsService.class); 41 } 42 43 protected void deployProcess(String process, String [] files) throws IOException , JpdlException, 44 ExoServiceException { 45 URL url = new URL (PROCESS_PATH + process); 46 InputStream is = url.openStream(); 47 ArchiveBuilder archiveBuilder = new ArchiveBuilder(is); 48 49 if (files != null) { 50 for (int i = 0; i < files.length; i++) { 51 String file = files[i]; 52 url = new URL (PROCESS_PATH + file); 53 archiveBuilder.add(file, url.openStream()); 54 } 55 } 56 WorkflowDefinitionService definitionService = workflowServiceContainer. 57 createWorkflowDefinitionService(); 58 definitionService.deployProcessArchive(archiveBuilder.getJarInputStream()); 59 definitionService.close(); 60 } 61 62 } 63 | Popular Tags |