01: /* ****************************************************************************
02: * Schema_Test.java
03: *
04: * ****************************************************************************/
05:
06: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
07: * Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
08: * Use is subject to license terms. *
09: * J_LZ_COPYRIGHT_END *********************************************************/
10:
11: package org.openlaszlo.js2doc;
12:
13: import java.io.*;
14: import java.util.*;
15: import junit.framework.*;
16: import org.custommonkey.xmlunit.*;
17:
18: public class Schema_Test extends XMLTestCase {
19:
20: public Schema_Test(String name) {
21: super (name);
22: }
23:
24: public void setUp() {
25: }
26:
27: public void testSchema() {
28: String[] tests = {
29: // Each case is input, expected output
30: // "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" is automatically prepended to input
31: // output is "true"/"false" depending on whether fragment should validate
32:
33: "<js2doc/>",
34: "true",
35:
36: "<js2doc></js2doc>",
37: "true",
38:
39: "<js2doc><property id=\"foo\" name=\"foo\"><doc><text>this is the subject</text><tag name=\"field1\"><text>foo</text></tag></doc></property></js2doc>",
40: "true",
41:
42: "<js2doc><property id=\"foo\" name=\"foo\"><doc><tag name=\"field1\"><text>foo</text></tag><text>this is the subject</text></doc></property></js2doc>",
43: "true",
44:
45: "<js2doc><property id=\"foo\" name=\"foo\"><doc><tag name=\"field1\"><text>foo</text></tag><text>this <i>is</i> the subject</text></doc></property></js2doc>",
46: "true",
47:
48: "<js2doc><property id=\"foo\" name=\"foo\" value=\"10\"/></js2doc>",
49: "true",
50:
51: "<js2doc><property id=\"foo\" name=\"foo\"><object/></property></js2doc>",
52: "true",
53:
54: "<js2doc><property id=\"foo\" name=\"foo\"><object><property id=\"bar\" name=\"bar\"/></object></property></js2doc>",
55: "true",
56:
57: "<js2doc><property id=\"foo\" name=\"foo\"><function/></property></js2doc>",
58: "true",
59:
60: "<js2doc><property id=\"foo\" name=\"foo\"><class><property id=\"bar\" name=\"bar\"><function/></property></class></property></js2doc>",
61: "true",
62:
63: "<js2doc><unit path=\"foo\" id=\"foo\"/></js2doc>",
64: "true",
65:
66: "<js2doc><unit path=\"foo/bar.js\" id=\"foo.bar.js\"/><property id=\"foo\" name=\"foo\" unitid=\"foo.bar.js\"/></js2doc>",
67: "true",
68:
69: };
70:
71: for (Iterator iter = Arrays.asList(tests).iterator(); iter
72: .hasNext();) {
73: String source = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
74: + (String) iter.next();
75: assertTrue(iter.hasNext());
76: String result = (String) iter.next();
77: assertTrue(result == "true" || result == "false");
78: boolean shouldPass = (result == "true") ? true : false;
79: }
80: }
81:
82: }
|