1   // Copyright (c) 2003, Chad Woolley, All rights reserved.
2   
3   package org.virtualmock.matcher;
4   
5   import junit.framework.Test;
6   import junit.framework.TestCase;
7   import org.hansel.CoverageDecorator;
8   import org.virtualmock.matcher.ArgMatcher;
9   import org.virtualmock.matcher.EqualsMatcher;
10  
11  
12  /***
13   * Tests the EqualsMatcher class
14   *
15   * @author Chad Woolley
16   * @version $Revision: 1.1 $
17   */
18  public class EqualsMatcherTest extends TestCase {
19      ArgMatcher matcher = null;
20  
21      /***
22       * Test constructor
23       *
24       * @param testTitle title of the test
25       */
26      public EqualsMatcherTest(String testTitle) {
27          super(testTitle);
28      }
29  
30      /***
31       * Hansel support
32       *
33       * @return the decorated Test
34       */
35      public static Test suite() {
36          CoverageDecorator cd = new CoverageDecorator(EqualsMatcherTest.class,
37                  new Class[] { EqualsMatcher.class });
38          cd.setDisplayStatistics(true);
39  
40          return cd;
41      }
42  
43      /***
44       * Set up the test
45       *
46       * @throws Exception any exception thrown during setup.
47       */
48      public void setUp() throws Exception {
49          super.setUp();
50          matcher = new EqualsMatcher();
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       * Test the matches method
64       */
65      public void testMatches() {
66          assertTrue(matcher.matches("something", "something"));
67      }
68  
69      /***
70       * Test the matches method works when both args are null
71       */
72      public void testMatchesWorksForBothArgsNull() {
73          assertTrue(matcher.matches(null, null));
74      }
75  
76      /***
77       * Test the matches method works when first arg is null
78       */
79      public void testMatchesWorksForFirstArgNull() {
80          assertFalse(matcher.matches(null, "something"));
81      }
82  
83      /***
84       * Test the matches method works when second arg is null
85       */
86      public void testMatchesWorksForSecondArgNull() {
87          assertFalse(matcher.matches("something", null));
88      }
89  }