package org.hamcrest;

import junit.framework.TestCase;

public class TypeSafeMatcherTest extends TestCase {
    private final Matcher<String> matcher = new TypeSafeMatcherSubclass();

    public static class TypeSafeMatcherSubclass extends TypeSafeMatcher<String> {
        @Override
        public boolean matchesSafely(String item) {
            return false;
        }

        @Override
        public void describeMismatchSafely(String item, Description mismatchDescription) {
          mismatchDescription.appendText("The mismatch");
        }

        @Override
        public void describeTo(Description description) {
        }

    }
    
    public void testCanDetermineMatcherTypeFromProtectedMatchesSafelyMethod() {
        assertFalse(matcher.matches(null));
        assertFalse(matcher.matches(10));
    }
    
    public void testDescribesMismatches() {
      assertMismatchDescription("was null", null);
      assertMismatchDescription("was a java.lang.Integer (<3>)", new Integer(3));
      assertMismatchDescription("The mismatch", "a string");
    }

    private void assertMismatchDescription(String expectedDescription, Object actual) {
      StringDescription description = new StringDescription();
      matcher.describeMismatch(actual, description);
      assertEquals(expectedDescription, description.toString());
    }
}

@@ -23,16 +23,23 @@
 %0Aimport 
+static 
 junit.fr
@@ -46,24 +46,132 @@
 amework.
+Assert.assertFalse;%0Aimport static org.hamcrest.AbstractMatcherTest.assertMismatchDescription;%0A%0Aimport org.junit.
 Test
-Case
 ;%0A%0Apubli
@@ -172,16 +172,22 @@
 %0Apublic 
+final 
 class Ty
@@ -208,25 +208,8 @@
 est 
-extends TestCase 
 %7B%0A  
@@ -735,31 +735,32 @@
       %7D%0A
-%0A
     %7D%0A
-    
 %0A   
+ @Test
  public 
@@ -767,14 +767,14 @@
 void
- testC
+%0A    c
 anDe
@@ -924,16 +924,69 @@
   %7D%0A
+%0A
     
-%0A   
+@SuppressWarnings(%7B %22unchecked%22, %22rawtypes%22 %7D)%0A    @Test
  pub
@@ -997,14 +997,14 @@
 void
- testD
+%0A    d
 escr
@@ -1065,16 +1065,25 @@
 s null%22,
+ matcher,
  null);%0A
@@ -1146,16 +1146,34 @@
  (%3C3%3E)%22,
+ (Matcher)matcher,
  new Int
@@ -1230,16 +1230,25 @@
 match%22, 
+matcher, 
 %22a strin
@@ -1253,284 +1253,8 @@
 ing%22
-);%0A    %7D%0A%0A    private void assertMismatchDescription(String expectedDescription, Object actual) %7B%0A      StringDescription description = new StringDescription();%0A      matcher.describeMismatch(actual, description);%0A      assertEquals(expectedDescription, description.toString()
 );%0A 

convert JUnit3 test to JUnit4