KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jmock.examples.website;
2
3 import java.util.List JavaDoc;
4 import org.jmock.core.Stub;
5 import org.jmock.core.Invocation;
6
7
8 public class AddToListStub implements Stub
9 {
10     Object JavaDoc element;
11
12     public AddToListStub( Object JavaDoc element ) {
13         this.element = element;
14     }
15
16     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
17         return buffer.append("adds <"+element+"> to a list");
18     }
19
20     public Object JavaDoc invoke( Invocation invocation ) throws Throwable JavaDoc {
21         ((List JavaDoc)invocation.parameterValues.get(0)).add(element);
22         return null;
23     }
24 }
25
Popular Tags