1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.scxml.env;
17
18 import org.apache.commons.scxml.model.State;
19 import org.apache.commons.scxml.model.Transition;
20 import org.apache.commons.scxml.model.TransitionTarget;
21
22 import junit.framework.Test;
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25
26 public class LogUtilsTest extends TestCase {
27
28 public LogUtilsTest(String testName) {
29 super(testName);
30 }
31
32 public static Test suite() {
33 return new TestSuite(LogUtilsTest.class);
34 }
35
36 public static void main(String args[]) {
37 String[] testCaseName = {LogUtilsTest.class.getName()};
38 junit.textui.TestRunner.main(testCaseName);
39 }
40
41 public void testGetTTPathParentNull() {
42 TransitionTarget target = new State();
43 target.setId("ID");
44
45 assertEquals("/ID", LogUtils.getTTPath(target));
46 }
47
48 public void testGetTTPathParent() {
49 TransitionTarget target = new State();
50 target.setId("ID");
51
52 TransitionTarget parent1 = new State();
53 parent1.setId("parent1");
54
55 TransitionTarget parent2 = new State();
56 parent2.setId("parent2");
57
58 parent1.setParent(parent2);
59 target.setParent(parent1);
60
61 assertEquals("/parent2/parent1/ID", LogUtils.getTTPath(target));
62 }
63
64 public void testTransToString() {
65 TransitionTarget targetTo = new State();
66 targetTo.setId("TO");
67
68 TransitionTarget targetFrom = new State();
69 targetFrom.setId("FROM");
70
71 Transition transition = new Transition();
72 transition.setCond("condition");
73 transition.setEvent("event happened");
74
75 assertEquals( "transition (event = event happened, cond = condition, from = /FROM, to = /TO)",
76 LogUtils.transToString(targetFrom, targetTo, transition));
77 }
78
79 }