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

This page was automatically generated by Maven