|
|
|
@ -8,13 +8,13 @@ import junit.framework.Assert; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Ignore; |
|
|
|
import org.junit.Ignore; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.mock.staticmock.JUnitStaticEntityMockingControl; |
|
|
|
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl; |
|
|
|
import org.springframework.mock.staticmock.MockStaticEntityMethods; |
|
|
|
import org.springframework.mock.staticmock.MockStaticEntityMethods; |
|
|
|
|
|
|
|
|
|
|
|
//Used because verification failures occur after method returns,
|
|
|
|
//Used because verification failures occur after method returns,
|
|
|
|
//so we can't test for them in the test case itself
|
|
|
|
//so we can't test for them in the test case itself
|
|
|
|
@MockStaticEntityMethods |
|
|
|
@MockStaticEntityMethods |
|
|
|
@Ignore // This isn't meant for direct testing; rather it is driven from JUnintStaticEntityMockingControlTest
|
|
|
|
@Ignore // This isn't meant for direct testing; rather it is driven from AnnotationDrivenStaticEntityMockingControl
|
|
|
|
public class Delegate { |
|
|
|
public class Delegate { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -22,8 +22,8 @@ public class Delegate { |
|
|
|
long id = 13; |
|
|
|
long id = 13; |
|
|
|
Person found = new Person(); |
|
|
|
Person found = new Person(); |
|
|
|
Person.findPerson(id); |
|
|
|
Person.findPerson(id); |
|
|
|
JUnitStaticEntityMockingControl.expectReturn(found); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id + 1)); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id + 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -32,8 +32,8 @@ public class Delegate { |
|
|
|
long id = 13; |
|
|
|
long id = 13; |
|
|
|
Person found = new Person(); |
|
|
|
Person found = new Person(); |
|
|
|
Person.findPerson(id); |
|
|
|
Person.findPerson(id); |
|
|
|
JUnitStaticEntityMockingControl.expectThrow(new PersistenceException()); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.expectThrow(new PersistenceException()); |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id + 1)); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id + 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -42,10 +42,10 @@ public class Delegate { |
|
|
|
long id = 13; |
|
|
|
long id = 13; |
|
|
|
Person found = new Person(); |
|
|
|
Person found = new Person(); |
|
|
|
Person.findPerson(id); |
|
|
|
Person.findPerson(id); |
|
|
|
JUnitStaticEntityMockingControl.expectReturn(found); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
|
|
|
Person.countPeople(); |
|
|
|
Person.countPeople(); |
|
|
|
JUnitStaticEntityMockingControl.expectReturn(25); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.expectReturn(25); |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id)); |
|
|
|
Assert.assertEquals(found, Person.findPerson(id)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -57,19 +57,19 @@ public class Delegate { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void doesntEverSetReturn() { |
|
|
|
public void doesntEverSetReturn() { |
|
|
|
Person.countPeople(); |
|
|
|
Person.countPeople(); |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void rejectUnexpectedCall() { |
|
|
|
public void rejectUnexpectedCall() { |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
Person.countPeople(); |
|
|
|
Person.countPeople(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected=RemoteException.class) |
|
|
|
@Test(expected=RemoteException.class) |
|
|
|
public void testVerificationFailsEvenWhenTestFailsInExpectedManner() throws RemoteException { |
|
|
|
public void testVerificationFailsEvenWhenTestFailsInExpectedManner() throws RemoteException { |
|
|
|
Person.countPeople(); |
|
|
|
Person.countPeople(); |
|
|
|
JUnitStaticEntityMockingControl.playback(); |
|
|
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
|
|
// No calls to allow verification failure
|
|
|
|
// No calls to allow verification failure
|
|
|
|
throw new RemoteException(); |
|
|
|
throw new RemoteException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|