1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 package org.jaxen.saxpath.helpers;
65
66 import junit.framework.TestCase;
67
68 import org.jaxen.saxpath.XPathReader;
69
70 public class XPathReaderFactoryTest extends TestCase
71 {
72 public XPathReaderFactoryTest(String name)
73 {
74 super( name );
75 }
76
77 public void setUp()
78 {
79 }
80
81 public void tearDown()
82 {
83 }
84
85 public void testDefault()
86 {
87 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
88 "" );
89 try
90 {
91 XPathReader reader = XPathReaderFactory.createReader();
92
93 assertNotNull( reader );
94 }
95 catch (org.jaxen.saxpath.SAXPathException e)
96 {
97 fail( e.getMessage() );
98 }
99 }
100
101 public void testValidByProperty()
102 {
103 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
104 "org.jaxen.saxpath.helpers.MockXPathReader" );
105
106 try
107 {
108 XPathReader reader = XPathReaderFactory.createReader();
109
110 assertNotNull( reader );
111
112 assertSame( MockXPathReader.class,
113 reader.getClass() );
114 }
115 catch (org.jaxen.saxpath.SAXPathException e)
116 {
117 fail( e.getMessage() );
118 }
119 finally
120 {
121 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
122 "" );
123 }
124 }
125
126 public void testInvalidByProperty()
127 {
128 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
129 "java.lang.String" );
130
131 try
132 {
133 XPathReaderFactory.createReader();
134
135 fail( "Should have thrown SAXPathException" );
136 }
137 catch (org.jaxen.saxpath.SAXPathException e)
138 {
139
140 }
141 finally
142 {
143 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
144 "" );
145 }
146 }
147
148 public void testNonExistantByProperty()
149 {
150 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
151 "i.am.a.class.that.does.not.Exist" );
152
153 try
154 {
155 XPathReaderFactory.createReader();
156
157 fail( "Should have thrown SAXPathException" );
158 }
159 catch (org.jaxen.saxpath.SAXPathException e)
160 {
161
162 }
163 finally
164 {
165 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
166 "" );
167 }
168 }
169
170 public void testValidExplicit()
171 {
172 try
173 {
174 XPathReader reader = XPathReaderFactory.createReader( "org.jaxen.saxpath.helpers.MockXPathReader" );
175
176 assertNotNull( reader );
177
178 assertSame( MockXPathReader.class,
179 reader.getClass() );
180 }
181 catch (org.jaxen.saxpath.SAXPathException e)
182 {
183 fail( e.getMessage() );
184 }
185 }
186
187 public void testInvalidExplicit()
188 {
189 try
190 {
191 XPathReaderFactory.createReader( "java.lang.String" );
192
193 fail( "Should have thrown SAXPathException" );
194 }
195 catch (org.jaxen.saxpath.SAXPathException e)
196 {
197
198 }
199 }
200
201 public void testNonExistantExplicit()
202 {
203 try
204 {
205 XPathReaderFactory.createReader( "i.am.a.class.that.does.not.Exist" );
206
207 fail( "Should have thrown SAXPathException" );
208 }
209 catch (org.jaxen.saxpath.SAXPathException e)
210 {
211
212 }
213 }
214 }