Replace EasyMock with Mockito in test sources
Issue: SPR-10126
This commit is contained in:
committed by
Chris Beams
parent
cbf6991d47
commit
d66c733ef4
@@ -23,8 +23,10 @@ import java.rmi.RemoteException;
|
||||
import javax.transaction.TransactionRolledbackException;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
import test.aop.MethodCounter;
|
||||
|
||||
@@ -47,12 +49,10 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
Object ret = new Object();
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
expect(mi.proceed()).andReturn(ret);
|
||||
replay(mi);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.proceed()).willReturn(ret);
|
||||
assertEquals(ret, ti.invoke(mi));
|
||||
assertEquals(0, th.getCalls());
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,9 +61,8 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
assertEquals(2, ti.getHandlerMethodCount());
|
||||
Exception ex = new Exception();
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
expect(mi.proceed()).andThrow(ex);
|
||||
replay(mi);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.proceed()).willThrow(ex);
|
||||
try {
|
||||
ti.invoke(mi);
|
||||
fail();
|
||||
@@ -72,7 +71,6 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
assertEquals(ex, caught);
|
||||
}
|
||||
assertEquals(0, th.getCalls());
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,12 +78,10 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
FileNotFoundException ex = new FileNotFoundException();
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
expect(mi.getMethod()).andReturn(Object.class.getMethod("hashCode", (Class[]) null));
|
||||
expect(mi.getArguments()).andReturn(null);
|
||||
expect(mi.getThis()).andReturn(new Object());
|
||||
expect(mi.proceed()).andThrow(ex);
|
||||
replay(mi);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(Object.class.getMethod("hashCode", (Class[]) null));
|
||||
given(mi.getThis()).willReturn(new Object());
|
||||
given(mi.proceed()).willThrow(ex);
|
||||
try {
|
||||
ti.invoke(mi);
|
||||
fail();
|
||||
@@ -95,7 +91,6 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
assertEquals(1, th.getCalls());
|
||||
assertEquals(1, th.getCalls("ioException"));
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,9 +99,8 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
// Extends RemoteException
|
||||
TransactionRolledbackException ex = new TransactionRolledbackException();
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
expect(mi.proceed()).andThrow(ex);
|
||||
replay(mi);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.proceed()).willThrow(ex);
|
||||
try {
|
||||
ti.invoke(mi);
|
||||
fail();
|
||||
@@ -116,7 +110,6 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
assertEquals(1, th.getCalls());
|
||||
assertEquals(1, th.getCalls("remoteException"));
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,9 +128,8 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
// Extends RemoteException
|
||||
TransactionRolledbackException ex = new TransactionRolledbackException();
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
expect(mi.proceed()).andThrow(ex);
|
||||
replay(mi);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.proceed()).willThrow(ex);
|
||||
try {
|
||||
ti.invoke(mi);
|
||||
fail();
|
||||
@@ -147,7 +139,6 @@ public final class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
assertEquals(1, th.getCalls());
|
||||
assertEquals(1, th.getCalls("remoteException"));
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -83,47 +88,32 @@ public final class CustomizableTraceInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
|
||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||
|
||||
expect(log.isTraceEnabled()).andReturn(true);
|
||||
expect(methodInvocation.getMethod()).andReturn(toString).times(4);
|
||||
expect(methodInvocation.getThis()).andReturn(this).times(2);
|
||||
log.trace(isA(String.class));
|
||||
expect(methodInvocation.proceed()).andReturn(null);
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(methodInvocation);
|
||||
replay(log);
|
||||
Log log = mock(Log.class);
|
||||
given(log.isTraceEnabled()).willReturn(true);
|
||||
|
||||
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
|
||||
interceptor.invoke(methodInvocation);
|
||||
|
||||
verify(log);
|
||||
verify(methodInvocation);
|
||||
verify(log, times(2)).trace(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
|
||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||
|
||||
expect(log.isTraceEnabled()).andReturn(true);
|
||||
expect(methodInvocation.getMethod()).andReturn(toString).times(4);
|
||||
expect(methodInvocation.getThis()).andReturn(this).times(2);
|
||||
log.trace(isA(String.class));
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
expect(methodInvocation.proceed()).andThrow(exception);
|
||||
log.trace(isA(String.class), eq(exception));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
given(methodInvocation.proceed()).willThrow(exception);
|
||||
|
||||
replay(log);
|
||||
replay(methodInvocation);
|
||||
Log log = mock(Log.class);
|
||||
given(log.isTraceEnabled()).willReturn(true);
|
||||
|
||||
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
|
||||
try {
|
||||
@@ -133,29 +123,22 @@ public final class CustomizableTraceInterceptorTests {
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
|
||||
verify(log);
|
||||
verify(methodInvocation);
|
||||
verify(log).trace(anyString());
|
||||
verify(log).trace(anyString(), eq(exception));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
|
||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[0]);
|
||||
Object[] arguments = new Object[]{"$ One \\$", new Long(2)};
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", new Long(2)});
|
||||
given(methodInvocation.proceed()).willReturn("Hello!");
|
||||
|
||||
expect(log.isTraceEnabled()).andReturn(true);
|
||||
expect(methodInvocation.getMethod()).andReturn(toString).times(7);
|
||||
expect(methodInvocation.getThis()).andReturn(this).times(2);
|
||||
expect(methodInvocation.getArguments()).andReturn(arguments).times(2);
|
||||
log.trace(isA(String.class));
|
||||
expect(methodInvocation.proceed()).andReturn("Hello!");
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(methodInvocation);
|
||||
replay(log);
|
||||
Log log = mock(Log.class);
|
||||
given(log.isTraceEnabled()).willReturn(true);
|
||||
|
||||
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
|
||||
interceptor.setEnterMessage(new StringBuffer()
|
||||
@@ -174,8 +157,7 @@ public final class CustomizableTraceInterceptorTests {
|
||||
.append("' this long.").toString());
|
||||
interceptor.invoke(methodInvocation);
|
||||
|
||||
verify(log);
|
||||
verify(methodInvocation);
|
||||
verify(log, times(2)).trace(anyString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -33,40 +38,29 @@ public final class DebugInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
|
||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
expect(log.isTraceEnabled()).andReturn(true);
|
||||
log.trace(isA(String.class));
|
||||
expect(methodInvocation.proceed()).andReturn(null);
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(methodInvocation);
|
||||
replay(log);
|
||||
Log log = mock(Log.class);
|
||||
given(log.isTraceEnabled()).willReturn(true);
|
||||
|
||||
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
||||
interceptor.invoke(methodInvocation);
|
||||
checkCallCountTotal(interceptor);
|
||||
|
||||
verify(methodInvocation);
|
||||
verify(log);
|
||||
verify(log, times(2)).trace(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
|
||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
expect(log.isTraceEnabled()).andReturn(true);
|
||||
log.trace(isA(String.class));
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
expect(methodInvocation.proceed()).andThrow(exception);
|
||||
log.trace(isA(String.class), eq(exception));
|
||||
given(methodInvocation.proceed()).willThrow(exception);
|
||||
|
||||
replay(methodInvocation);
|
||||
replay(log);
|
||||
Log log = mock(Log.class);
|
||||
given(log.isTraceEnabled()).willReturn(true);
|
||||
|
||||
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
||||
try {
|
||||
@@ -76,8 +70,8 @@ public final class DebugInterceptorTests {
|
||||
}
|
||||
checkCallCountTotal(interceptor);
|
||||
|
||||
verify(methodInvocation);
|
||||
verify(log);
|
||||
verify(log).trace(anyString());
|
||||
verify(log).trace(anyString(), eq(exception));
|
||||
}
|
||||
|
||||
private void checkCallCountTotal(DebugInterceptor interceptor) {
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -48,35 +49,24 @@ public final class PerformanceMonitorInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[0]);
|
||||
|
||||
expect(mi.getMethod()).andReturn(toString);
|
||||
expect(mi.proceed()).andReturn(null);
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(mi, log);
|
||||
Log log = mock(Log.class);
|
||||
|
||||
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
|
||||
interceptor.invokeUnderTrace(mi, log);
|
||||
|
||||
verify(mi, log);
|
||||
verify(log).trace(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[0]);
|
||||
|
||||
expect(mi.getMethod()).andReturn(toString);
|
||||
expect(mi.proceed()).andThrow(new IllegalArgumentException());
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(mi, log);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
given(mi.proceed()).willThrow(new IllegalArgumentException());
|
||||
Log log = mock(Log.class);
|
||||
|
||||
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
|
||||
try {
|
||||
@@ -86,7 +76,7 @@ public final class PerformanceMonitorInterceptorTests {
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
|
||||
verify(mi, log);
|
||||
verify(log).trace(anyString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -35,39 +40,27 @@ public final class SimpleTraceInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||
|
||||
expect(mi.getMethod()).andReturn(toString);
|
||||
expect(mi.getThis()).andReturn(this);
|
||||
log.trace(isA(String.class));
|
||||
expect(mi.proceed()).andReturn(null);
|
||||
log.trace(isA(String.class));
|
||||
|
||||
replay(mi, log);
|
||||
Log log = mock(Log.class);
|
||||
|
||||
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
||||
interceptor.invokeUnderTrace(mi, log);
|
||||
|
||||
verify(mi, log);
|
||||
verify(log, times(2)).trace(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
Log log = createMock(Log.class);
|
||||
MethodInvocation mi = createMock(MethodInvocation.class);
|
||||
|
||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||
|
||||
expect(mi.getMethod()).andReturn(toString);
|
||||
expect(mi.getThis()).andReturn(this);
|
||||
log.trace(isA(String.class));
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
expect(mi.proceed()).andThrow(exception);
|
||||
log.trace(isA(String.class));
|
||||
given(mi.proceed()).willThrow(exception);
|
||||
|
||||
replay(mi, log);
|
||||
Log log = mock(Log.class);
|
||||
|
||||
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
||||
|
||||
@@ -77,7 +70,8 @@ public final class SimpleTraceInterceptorTests {
|
||||
} catch (IllegalArgumentException expected) {
|
||||
}
|
||||
|
||||
verify(mi, log);
|
||||
verify(log).trace(anyString());
|
||||
verify(log).trace(anyString(), eq(exception));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.aop.scope;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
@@ -52,14 +52,9 @@ public final class DefaultScopedObjectTests {
|
||||
testBadTargetBeanName(" ");
|
||||
}
|
||||
|
||||
|
||||
private static void testBadTargetBeanName(final String badTargetBeanName) {
|
||||
ConfigurableBeanFactory factory = createMock(ConfigurableBeanFactory.class);
|
||||
replay(factory);
|
||||
|
||||
ConfigurableBeanFactory factory = mock(ConfigurableBeanFactory.class);
|
||||
new DefaultScopedObject(factory, badTargetBeanName);
|
||||
|
||||
verify(factory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -56,17 +57,14 @@ public final class DelegatingIntroductionInterceptorTests {
|
||||
assertTrue(! (raw instanceof TimeStamped));
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
TimeStamped ts = createMock(TimeStamped.class);
|
||||
TimeStamped ts = mock(TimeStamped.class);
|
||||
long timestamp = 111L;
|
||||
expect(ts.getTimeStamp()).andReturn(timestamp);
|
||||
replay(ts);
|
||||
given(ts.getTimeStamp()).willReturn(timestamp);
|
||||
|
||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
||||
|
||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||
assertTrue(tsp.getTimeStamp() == timestamp);
|
||||
|
||||
verify(ts);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,17 +73,14 @@ public final class DelegatingIntroductionInterceptorTests {
|
||||
assertTrue(! (raw instanceof SubTimeStamped));
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
TimeStamped ts = createMock(SubTimeStamped.class);
|
||||
TimeStamped ts = mock(SubTimeStamped.class);
|
||||
long timestamp = 111L;
|
||||
expect(ts.getTimeStamp()).andReturn(timestamp);
|
||||
replay(ts);
|
||||
given(ts.getTimeStamp()).willReturn(timestamp);
|
||||
|
||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), SubTimeStamped.class));
|
||||
|
||||
SubTimeStamped tsp = (SubTimeStamped) factory.getProxy();
|
||||
assertTrue(tsp.getTimeStamp() == timestamp);
|
||||
|
||||
verify(ts);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,18 +89,15 @@ public final class DelegatingIntroductionInterceptorTests {
|
||||
assertTrue(! (raw instanceof TimeStamped));
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
TimeStamped ts = createMock(SubTimeStamped.class);
|
||||
TimeStamped ts = mock(SubTimeStamped.class);
|
||||
long timestamp = 111L;
|
||||
expect(ts.getTimeStamp()).andReturn(timestamp);
|
||||
replay(ts);
|
||||
given(ts.getTimeStamp()).willReturn(timestamp);
|
||||
|
||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class));
|
||||
|
||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||
assertTrue(!(tsp instanceof SubTimeStamped));
|
||||
assertTrue(tsp.getTimeStamp() == timestamp);
|
||||
|
||||
verify(ts);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user