1 package com.macvu.tiles.xmlDefinition;
2
3
4
5 import junit.framework.TestCase;
6
7
8
9 import java.io.InputStream;
10
11 import java.io.BufferedInputStream;
12
13 import java.io.IOException;
14
15
16
17 import org.xml.sax.SAXException;
18
19 import com.macvu.tiles.CacheInformation;
20
21
22
23 /***
24
25 * Created by IntelliJ IDEA.
26
27 * User: MVu
28
29 * Date: Mar 23, 2004
30
31 * Time: 3:38:29 PM
32
33 * To change this template use File | Settings | File Templates.
34
35 */
36
37 public class XmlCacheParserTest extends TestCase {
38
39 public XmlCacheParserTest(String s) {
40
41 super(s);
42
43 }
44
45
46
47 public void testXmlCacheParser() {
48
49 String filename = "testDef.xml";
50
51 XmlCacheParser parser = new XmlCacheParser();
52
53
54
55 InputStream input = null;
56
57 input = new BufferedInputStream(parser.getClass().getResourceAsStream(filename));
58
59
60
61 try {
62
63 parser.setValidating(false);
64
65 parser.setDetailLevel(2);
66
67 XmlCacheDefinitionSet definitions = new XmlCacheDefinitionSet();
68
69 parser.parse(input, definitions);
70
71
72
73 XmlCacheDefinition def = definitions.getDefinition("teacher.plan");
74
75 assertNotNull("teacher.plan exist", def);
76
77 CacheInformation info = def.getCacheInformation();
78
79 assertNotNull("Info is not null", info);
80
81
82
83
84
85 } catch (IOException e) {
86
87 fail("Unexpected IO Exception: " + e.getMessage());
88
89 } catch (SAXException e) {
90
91 fail("Unexpected SAX Exception: " + e.getMessage());
92
93 }
94
95 }
96
97 }
98