1   // Copyright (c) 2003, Chad Woolley, All rights reserved.
2   
3   package org.virtualmock.configuration;
4   
5   import java.util.List;
6   import junit.framework.Test;
7   import junit.framework.TestCase;
8   import org.hansel.CoverageDecorator;
9   
10  
11  /***
12   * Tests the VMConfig class
13   *
14   * @author Chad Woolley
15   * @version $Revision: 1.5 $
16   */
17  public class VMConfigTest extends TestCase {
18      VMConfig vmConfig = null;
19  
20      /***
21       * Set up the test
22       *
23       * @throws Exception any exception thrown during setup.
24       */
25      public void setUp() throws Exception {
26          super.setUp();
27          vmConfig = new VMConfig();
28      }
29  
30      /***
31       * Hansel support
32       *
33       * @return the decorated Test
34       */
35      public static Test suite() {
36          CoverageDecorator cd =
37              new CoverageDecorator(VMConfigTest.class,
38                  new Class[] {VMConfig.class});
39          cd.setDisplayStatistics(true);
40  
41          return cd;
42      }
43  
44      /***
45       * Tear down the test
46       *
47       * @throws Exception any exception thrown during teardown.
48       */
49      public void tearDown() throws Exception {
50          super.tearDown();
51      }
52  
53      /***
54       * Tests the addClassExclusionPattern and getClassExclusionPatterns methods
55       */
56      public void testCanAddClassExclusionPattern() {
57          String classExclusionPattern = "XXX";
58  
59          vmConfig.addClassExclusionPattern(classExclusionPattern);
60  
61          List classExclusionPatterns = vmConfig.getClassExclusionPatterns();
62          assertEquals(classExclusionPattern, classExclusionPatterns.get(0));
63      }
64  
65      /***
66       * Tests the addCoreRuleConfig and getRuleConfigs methods
67       */
68      public void testCanAddRuleConfig() {
69          RuleConfig ruleConfig = new RuleConfig();
70  
71          vmConfig.addRuleConfig(ruleConfig);
72  
73          List ruleConfigs = vmConfig.getRuleConfigs();
74          assertEquals(ruleConfig, ruleConfigs.get(0));
75      }
76  }