1
2
3 package org.virtualmock.configuration;
4
5 import java.io.IOException;
6 import java.io.InputStream;
7 import junit.framework.Test;
8 import junit.framework.TestCase;
9 import org.apache.commons.digester.Digester;
10 import org.easymock.MockControl;
11 import org.hansel.CoverageDecorator;
12 import org.xml.sax.SAXException;
13
14
15 /***
16 * Tests the basic functionality and error handling of ConfigurationDigester
17 * class.
18 *
19 * @author Chad Woolley
20 * @version $Revision: 1.14 $
21 */
22 public class ConfigDigesterTest extends TestCase {
23 ConfigDigester configDigester = null;
24 InputStream inputStream = null;
25
26 /***
27 * Set up the test
28 *
29 * @throws Exception any exception thrown during setup.
30 */
31 public void setUp() throws Exception {
32 super.setUp();
33 System.out.print("TODO: " + this.getClass() + " IS DISABLED");
34 inputStream =
35 this.getClass().getResourceAsStream("virtualmock_sample.xml");
36 }
37
38 /***
39 * Hansel support
40 *
41 * @return the decorated Test
42 */
43
44
45
46
47
48
49
50
51
52
53 /***
54 * Tear down the test
55 *
56 * @throws Exception any exception thrown during teardown.
57 */
58 public void tearDown() throws Exception {
59 super.tearDown();
60 }
61
62 /***
63 * Tests an IOException on the inputstream is handled
64 *
65 * @throws Exception Any unexpected exception
66 */
67 public void xtestIOExceptionOnInputStreamIsCorrectlyHandled()
68 throws Exception {
69 inputStream = this.getClass().getResourceAsStream("xxx");
70
71 MockControl controlDigester =
72 MockControl.createNiceControl(Digester.class);
73 Digester mockDigester = (Digester) controlDigester.getMock();
74 mockDigester.parse(inputStream);
75 controlDigester.setDefaultThrowable(new IOException("test"));
76 controlDigester.replay();
77
78 try {
79 configDigester = new ConfigDigester(inputStream, mockDigester);
80 fail("Expected exception");
81 } catch (RuntimeException e) {
82 }
83 }
84
85 /***
86 * Tests an SAXException on the inputstream is handled
87 *
88 * @throws Exception Any unexpected exception
89 */
90 public void xtestSAXExceptionOnInputStreamIsCorrectlyHandled()
91 throws Exception {
92 inputStream = this.getClass().getResourceAsStream("xxx");
93
94 MockControl controlDigester =
95 MockControl.createNiceControl(Digester.class);
96 Digester mockDigester = (Digester) controlDigester.getMock();
97 mockDigester.parse(inputStream);
98 controlDigester.setDefaultThrowable(new SAXException("test"));
99 controlDigester.replay();
100
101 try {
102 configDigester = new ConfigDigester(inputStream);
103 fail("Expected exception");
104 } catch (RuntimeException e) {
105 }
106 }
107
108 /***
109 * Tests that the sample InputStream can be read
110 */
111 public void xtestSampleInputStreamIsValid() {
112 assertNotNull("InputStream should not be null", inputStream);
113 }
114
115 public void testDummy() throws Exception {
116
117 }
118 }