KickJava   Java API By Example, From Geeks To Geeks.

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


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

3 package org.jmock.expectation;
4
5 import java.util.Collection JavaDoc;
6 import java.util.HashSet JavaDoc;
7
8
9 public class ExpectationSet extends AbstractExpectationCollection
10 {
11     private HashSet JavaDoc myExpectedItems = new HashSet JavaDoc();
12     private HashSet JavaDoc myActualItems = new HashSet JavaDoc();
13
14     public ExpectationSet( String JavaDoc name ) {
15         super(name);
16     }
17
18     protected void checkImmediateValues( Object JavaDoc actualItem ) {
19         AssertMo.assertTrue(myName + " received an unexpected item\nUnexpected:" + actualItem,
20                             new HashSet JavaDoc(myExpectedItems).contains(actualItem));
21     }
22
23     protected Collection JavaDoc getActualCollection() {
24         return myActualItems;
25     }
26
27     protected Collection JavaDoc getExpectedCollection() {
28         return myExpectedItems;
29     }
30
31     public void verify() {
32         assertEquals("did not receive the expected collection items.",
33                      new HashSet JavaDoc(getExpectedCollection()),
34                      new HashSet JavaDoc(getActualCollection()));
35     }
36
37 }
38
Popular Tags