KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > examples > website > PublisherTest


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

3 package org.jmock.examples.website;
4
5 import org.jmock.Mock;
6 import org.jmock.MockObjectTestCase;
7
8
9 public class PublisherTest extends MockObjectTestCase
10 {
11
12     public void testOneSubscriberReceivesAMessage() {
13         // setup
14
Mock mockSubscriber = mock(Subscriber.class);
15         Publisher publisher = new Publisher();
16         publisher.add((Subscriber)mockSubscriber.proxy());
17
18         Message message = new Message();
19
20         // expectations
21
mockSubscriber.expects(once()).method("receive").with(eq(message)).isVoid();
22
23         // execute
24
publisher.publish(message);
25     }
26 }
27
Popular Tags