KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > jpdl > xml > StartStateXmlTest


1 package org.jbpm.jpdl.xml;
2
3 import org.dom4j.*;
4 import org.jbpm.graph.def.*;
5 import org.jbpm.graph.node.StartState;
6
7 public class StartStateXmlTest extends AbstractXmlTestCase {
8
9   public void testParseStartState() {
10     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
11       "<process-definition>" +
12       " <start-state />" +
13       "</process-definition>"
14     );
15     assertNotNull(processDefinition.getStartState());
16     assertSame(processDefinition.getStartState(), processDefinition.getNodes().get(0));
17   }
18
19   public void testParseStartStateName() {
20     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
21       "<process-definition>" +
22       " <start-state name='start'/>" +
23       "</process-definition>"
24     );
25     assertEquals("start", processDefinition.getStartState().getName());
26   }
27
28   public void testWriteStartState() throws Exception JavaDoc {
29     ProcessDefinition processDefinition = new ProcessDefinition();
30     processDefinition.setStartState( new StartState() );
31     Element element = AbstractXmlTestCase.toXmlAndParse( processDefinition, "/process-definition/start-state[1]" );
32     assertNotNull(element);
33     assertEquals("start-state", element.getName());
34     assertEquals(0, element.attributeCount());
35   }
36
37   public void testWriteStartStateName() throws Exception JavaDoc {
38     ProcessDefinition processDefinition = new ProcessDefinition();
39     processDefinition.setStartState( new StartState("mystartstate") );
40     Element element = AbstractXmlTestCase.toXmlAndParse( processDefinition, "/process-definition/start-state[1]" );
41     assertEquals("start-state", element.getName());
42     assertEquals(1, element.attributeCount());
43     assertEquals("mystartstate", element.attributeValue("name"));
44   }
45
46
47 }
48
Popular Tags