KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > ExpectationList


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