View Javadoc

1   // Copyright (c) 2003, Chad Woolley, All rights reserved.
2   
3   package org.virtualmock.configuration;
4   
5   import java.io.InputStream;
6   import java.util.List;
7   import javax.xml.parsers.SAXParserFactory;
8   import junit.framework.Test;
9   import junit.framework.TestCase;
10  import junit.framework.TestResult;
11  
12  import org.hansel.CoverageDecorator;
13  
14  
15  /***
16   * Tests that ExcludedClassesParser retrieves the correct data.
17   *
18   * @author Chad Woolley
19   * @version $Revision: 1.1 $
20   */
21  public class ExcludedClassesParserDataTest extends TestCase {
22      ExcludedClassesHandler handler = null;
23      ExcludedClassesParser parser = null;
24      InputStream inputStream = null;
25      SAXParserFactory factory = null;
26  
27      /***
28       * Set up the test
29       *
30       * @throws Exception any exception thrown during setup.
31       */
32      public void setUp() throws Exception {
33          super.setUp();
34          inputStream =
35              this.getClass().getResourceAsStream("virtualmock_sample.xml");
36          handler = new ExcludedClassesHandler();
37          factory = SAXParserFactory.newInstance();
38      }
39  
40  //    /***
41  //     * Hansel support
42  //     *
43  //     * @return the decorated Test
44  //     */
45  //    public static Test suite() {
46  ////        CoverageDecorator cd =
47  ////            new CoverageDecorator(ExcludedClassesParserDataTest.class,
48  ////                new Class[] {
49  ////                    ExcludedClassesParser.class, ExcludedClassesHandler.class
50  ////                });
51  ////        cd.setDisplayStatistics(true);
52  ////
53  ////        return cd;
54  //    }
55  
56      /***
57       * Tear down the test.
58       *
59       * @throws Exception any exception thrown during teardown.
60       */
61      public void tearDown() throws Exception {
62          super.tearDown();
63      }
64  
65      /***
66       * Tests that a single RuleConfig can be parsed out of the InputStream.
67       */
68      public void testCanParseSingleRuleConfig() {
69          parser = new ExcludedClassesParser(inputStream, handler, factory);
70  
71          List classExclusionPatterns = parser.getClassExclusionPatterns();
72          assertNotNull(classExclusionPatterns);
73      }
74  
75      /***
76       * Tests that the sample InputStream can be read.
77       */
78      public void testSampleInputStreamIsValid() {
79          assertNotNull("InputStream should not be null", inputStream);
80      }
81  }