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