Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package au.com.loftinspace;
- import com.googlecode.instinct.marker.annotate.Subject;
- import com.googlecode.instinct.marker.annotate.Mock;
- import com.googlecode.instinct.marker.annotate.Specification;
- import com.googlecode.instinct.marker.annotate.BeforeSpecification;
- import static com.googlecode.instinct.expect.Expect.expect;
- import com.googlecode.instinct.integrate.junit4.InstinctRunner;
- import java.util.List;
- import java.util.LinkedList;
- import java.util.ArrayList;
- import org.jmock.Expectations;
- import org.junit.runner.RunWith;
- @RunWith(InstinctRunner.class)
- public class AListUserAdaptor {
- @Subject ListUserAdaptor listUserAdaptor;
- @Mock ListUser mockListUser;
- @BeforeSpecification
- public void setUp() {
- listUserAdaptor = new ListUserAdaptor();
- listUserAdaptor.setListUser(mockListUser);
- }
- @Specification
- public void shouldUseArrayListsOnListUser() {
- /*
- It might be expected that this would fail, but it does not. Type checking on the List happens at
- compile time. The runtime type of the list is not checked as aNonNull resolves to ANYTHING
- */
- expect.that(new Expectations() {{
- one(mockListUser).useAList(with(aNonNull(ArrayList.class)));
- }});
- listUserAdaptor.useAList();
- }
- private class ListUserAdaptor {
- public ListUserAdaptor(){}
- private ListUser listUser;
- public void setListUser(ListUser listUser) {
- this.listUser = listUser;
- }
- public void useAList() {
- listUser.useAList(new LinkedList());
- }
- }
- private class ListUser {
- public void useAList(List list) {}
- }
- }
Add Comment
Please, Sign In to add comment