Created
August 25, 2008 10:58
-
-
Save Synesso/7060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment