1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml.io;
18
19 import java.net.URL;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24 import junit.textui.TestRunner;
25
26 import org.apache.commons.scxml.SCXMLTestHelper;
27 import org.apache.commons.scxml.model.SCXML;
28 /***
29 * Unit tests {@link org.apache.commons.scxml.SCXMLParser}.
30 */
31 public class SCXMLParserTest extends TestCase {
32 /***
33 * Construct a new instance of SCXMLDigesterTest with
34 * the specified name
35 */
36 public SCXMLParserTest(String name) {
37 super(name);
38 }
39
40 public static Test suite() {
41 TestSuite suite = new TestSuite(SCXMLParserTest.class);
42 suite.setName("SCXML Parser Tests");
43 return suite;
44 }
45
46
47 private URL microwave03, microwave04;
48 private SCXML scxml;
49 private String scxmlAsString;
50
51 /***
52 * Set up instance variables required by this test case.
53 */
54 public void setUp() {
55 microwave03 = this.getClass().getClassLoader().
56 getResource("org/apache/commons/scxml/env/jexl/microwave-03.xml");
57 microwave04 = this.getClass().getClassLoader().
58 getResource("org/apache/commons/scxml/env/jexl/microwave-04.xml");
59 }
60
61 /***
62 * Tear down instance variables required by this test case.
63 */
64 public void tearDown() {
65 microwave03 = microwave04 = null;
66 scxml = null;
67 scxmlAsString = null;
68 }
69
70 /***
71 * Test the implementation
72 */
73 public void testSCXMLParserMicrowave03Sample() {
74 scxml = SCXMLTestHelper.parse(microwave03);
75 assertNotNull(scxml);
76 scxmlAsString = serialize(scxml);
77 assertNotNull(scxmlAsString);
78 }
79
80 public void testSCXMLParserMicrowave04Sample() {
81 scxml = SCXMLTestHelper.parse(microwave04);
82 assertNotNull(scxml);
83 scxmlAsString = serialize(scxml);
84 assertNotNull(scxmlAsString);
85 }
86
87 private String serialize(final SCXML scxml) {
88 scxmlAsString = SCXMLSerializer.serialize(scxml);
89 assertNotNull(scxmlAsString);
90 return scxmlAsString;
91 }
92
93 public static void main(String args[]) {
94 TestRunner.run(suite());
95 }
96 }
97