KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > workflow > test > TestForm


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  */

5
6 package org.exoplatform.services.workflow.test;
7
8 import org.exoplatform.container.PortalContainer;
9 import org.exoplatform.services.database.DatabaseService;
10 import org.exoplatform.services.exception.ExoServiceException;
11 import org.exoplatform.services.workflow.Form;
12 import org.exoplatform.services.workflow.WorkflowExecutionService;
13 import org.jbpm.JpdlException;
14 import org.jbpm.JbpmConfiguration;
15 import org.jbpm.model.definition.Definition;
16
17 import java.io.IOException JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Locale JavaDoc;
20 import java.util.ResourceBundle JavaDoc;
21
22 /**
23  * Created y the eXo platform team
24  * User: Benjamin Mestrallet
25  * Date: 17 mai 2004
26  */

27 public class TestForm extends BaseTest{
28
29   private static final String JavaDoc PROCESS_FILE = "processdefinition.xml";
30
31   public TestForm(String JavaDoc name) {
32     super(name);
33   }
34
35   protected String JavaDoc getDescription() {
36     return "test workflow forms";
37   }
38
39   public void setUp() {
40     super.setUp();
41     String JavaDoc[] files = {"forms.xml", "start.properties",
42         "evaluation.properties", "hr.properties"};
43     try {
44       deployProcess(PROCESS_FILE, files);
45     } catch (IOException JavaDoc e) {
46       e.printStackTrace();
47     } catch (JpdlException e) {
48       e.printStackTrace();
49     } catch (ExoServiceException e) {
50       e.printStackTrace();
51     }
52
53   }
54
55   public void testForms() {
56     WorkflowExecutionService executionService = workflowServiceContainer.
57         createWorkflowExecutionService();
58     Definition definition = (Definition) executionService.getAllDefinitions().get(0);
59     workflowFormsService.addForms(definition, executionService, new Locale JavaDoc("en"));
60     executionService.close();
61     Form form = workflowFormsService.getForm(definition.getId(), "start");
62     assertNotNull(form);
63     assertEquals("start", form.getStateName());
64     ResourceBundle JavaDoc rB = form.getResourceBundle();
65     assertEquals("Let's pray", rB.getString("submit"));
66     assertEquals("the amount you want your salary to be increased",
67         rB.getString("amount.asked.title"));
68
69     List JavaDoc map = form.getSubmitButtons();
70     assertTrue(map.isEmpty());
71
72     List JavaDoc variableFormats = form.getVariableFormats();
73     assertTrue(!variableFormats.isEmpty());
74   }
75 }
76
Popular Tags