1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jelly.test.xml;
18
19 import java.net.URL;
20
21 import junit.framework.TestCase;
22 import junit.framework.TestSuite;
23
24 import org.apache.commons.jelly.Jelly;
25 import org.apache.commons.jelly.JellyContext;
26 import org.apache.commons.jelly.JellyException;
27 import org.apache.commons.jelly.XMLOutput;
28
29 /***
30 * A test to confirm that Jelly scripts fail to parse if they declare tags
31 * that do not exist
32 *
33 * @author Morgan Delagrange
34 * @version $Revision: 201966 $
35 */
36 public class TestNonexistentTags extends TestCase {
37 Jelly jelly = null;
38 JellyContext context = null;
39 XMLOutput xmlOutput = null;
40
41 public TestNonexistentTags(String name) {
42 super(name);
43 }
44
45 public static TestSuite suite() throws Exception {
46 return new TestSuite(TestNonexistentTags.class);
47 }
48
49 public void setUp(String scriptName) throws Exception {
50 context = new JellyContext();
51 xmlOutput = XMLOutput.createDummyXMLOutput();
52
53 jelly = new Jelly();
54
55 String script = scriptName;
56 URL url = this.getClass().getResource(script);
57 if ( url == null ) {
58 throw new Exception(
59 "Could not find Jelly script: " + script
60 + " in package of class: " + this.getClass().getName()
61 );
62 }
63 jelly.setUrl(url);
64 }
65
66 /***
67 * A script should fail to parse if it declares tags that don't exist.
68 */
69 public void testNonexistentTags() throws Exception {
70 setUp("nonexistentTags1.jelly");
71 try {
72 jelly.compileScript();
73 fail("Scripts should throw JellyException when it declares a nonexistent tag.");
74 } catch (JellyException e) {
75 }
76 }
77
78 }