1 3 package org.jmock.expectation; 4 5 6 public class ExpectationSegment extends AbstractExpectation 7 { 8 private String myExpectedSegment; 9 private String myActualString; 10 11 public ExpectationSegment( String name ) { 12 super(name); 13 clearActual(); 14 } 15 16 public void clearActual() { 17 myActualString = null; 18 } 19 20 public void setActual( String aString ) { 21 myActualString = aString; 22 if (shouldCheckImmediately()) { 23 verify(); 24 } 25 } 26 27 public void setExpected( String segment ) { 28 myExpectedSegment = segment; 29 setHasExpectations(); 30 } 31 32 public void setExpectNothing() { 33 myActualString = null; 34 setExpected(null); 35 } 36 37 public void verify() { 38 if (hasExpectations()) { 39 if (null == myExpectedSegment) { 40 AssertMo.assertNull("Expecting nothing", myActualString); 41 } else { 42 AssertMo.assertIncludes("Should include string segment", 43 myExpectedSegment, 44 myActualString); 45 } 46 } 47 } 48 } 49 | Popular Tags |