View Javadoc
1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.expectation; 3 4 import junit.framework.Assert; 5 import junit.framework.AssertionFailedError; 6 7 public class AssertMo extends Assert { 8 9 protected AssertMo() { 10 super(); 11 } 12 13 public static void assertEquals( 14 String description, 15 Object[] expectedArray, 16 Object[] actualArray) { 17 assertEquals( 18 description + " (different lengths)", 19 expectedArray.length, 20 actualArray.length); 21 for (int i = 0; i < expectedArray.length; i++) { 22 assertEquals( 23 description + " (element " + i + ")", 24 expectedArray[i], 25 actualArray[i]); 26 } 27 } 28 29 public static void assertExcludes( 30 String description, 31 String excludeString, 32 String targetString) { 33 assertTrue( 34 description 35 + "\nExclude String: " 36 + excludeString 37 + "\n Target String: " 38 + targetString, 39 targetString.indexOf(excludeString) == -1); 40 } 41 42 public static void assertIncludes( 43 String description, 44 String includeString, 45 String targetString) { 46 assertTrue( 47 description 48 + "\nInclude String: " 49 + includeString 50 + "\n Target String: " 51 + targetString, 52 targetString.indexOf(includeString) != -1); 53 } 54 55 public static void assertStartsWith( 56 String description, 57 String startString, 58 String targetString) { 59 assertTrue( 60 description 61 + "\n Start String: " 62 + startString 63 + "\nTarget String: " 64 + targetString, 65 targetString.startsWith(startString)); 66 } 67 68 public static void assertVerifyFails(Verifiable aVerifiable) { 69 boolean threwException = false; 70 try { 71 aVerifiable.verify(); 72 } catch (AssertionFailedError ex) { 73 threwException = true; 74 } 75 76 assertTrue("Should not have verified", threwException); 77 } 78 79 static protected void failNotEquals( 80 String message, 81 Object expected, 82 Object actual) { 83 String formatted = ""; 84 if (message != null) 85 formatted = message + " "; 86 fail( 87 formatted + "\nExpected:<" + expected + ">\nReceived:<" + actual + ">"); 88 } 89 90 public static void notImplemented(String mockName) { 91 throw new NotImplementedException("Not Implemented in " + mockName); 92 } 93 94 public static void assertFails(String message, Runnable runnable) { 95 try { 96 runnable.run(); 97 } catch (AssertionFailedError expected) { 98 return; 99 } 100 fail(message); 101 } 102 }

This page was automatically generated by Maven