KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > expectation > ExpectationList


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package org.jmock.expectation;
4
5 import java.util.ArrayList JavaDoc;
6 import java.util.Collection JavaDoc;
7 import junit.framework.Assert;
8
9
10 public class ExpectationList extends AbstractExpectationCollection
11 {
12     protected ArrayList JavaDoc myExpectedItems = new ArrayList JavaDoc();
13     protected ArrayList JavaDoc myActualItems = new ArrayList JavaDoc();
14
15     public ExpectationList( String JavaDoc name ) {
16         super(name);
17     }
18
19     protected void checkImmediateValues( Object JavaDoc actualItem ) {
20         int size = myActualItems.size();
21         Assert.assertTrue(myName
22                           + " had different sizes\nExpected Size:"
23                           + myExpectedItems.size()
24                           + "\nReceived size: "
25                           + size
26                           + " when adding:"
27                           + actualItem,
28                           myExpectedItems.size() >= size);
29         assertEquals(myName + " added item does not match",
30                      myExpectedItems.get(size - 1),
31                      actualItem);
32     }
33
34     protected Collection JavaDoc getActualCollection() {
35         return myActualItems;
36     }
37
38     protected Collection JavaDoc getExpectedCollection() {
39         return myExpectedItems;
40     }
41 }
42
Popular Tags