Created
December 30, 2010 15:54
-
-
Save anpieber/759918 to your computer and use it in GitHub Desktop.
specification for proxyhelper
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
@Test | |
public void testMethodCallPointingToToStringMethod_ShouldReturnOriginalValue() throws Exception { | |
Object originalObject = new Object(); | |
Object[] args = null; | |
Method methodMock = mock(Method.class); | |
when(methodMock.getName()).thenReturn("toString"); | |
when(methodMock.invoke(originalObject, args)).thenReturn("TestValue"); | |
ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args); | |
assertTrue(proxyObjectMethodMirror.isMethodObjectMethod()); | |
assertEquals("TestValue",proxyObjectMethodMirror.executeMethod()); | |
} | |
@Test | |
public void testMethodCallPointingToWaitMethod_ShouldCallOriginalWaitMethod() throws Exception { | |
Object originalObject = new Object(); | |
Object[] args = new Object[]{ 12 }; | |
Method methodMock = mock(Method.class); | |
when(methodMock.getName()).thenReturn("toString"); | |
ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args); | |
assertTrue(proxyObjectMethodMirror.isMethodObjectMethod()); | |
proxyObjectMethodMirror.executeMethod(args); | |
verify(methodMock).invoke(originalObject, args); | |
} | |
@Test | |
public void testMethodCallPointingToNonObjectMethod_shouldReturnFalseOnIsMethodObjectMethod() throws Exception { | |
Object originalObject = new Object(); | |
Object[] args = null; | |
Method methodMock = mock(Method.class); | |
when(methodMock.getName()).thenReturn("anythingElse"); | |
ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args); | |
assertFalse(proxyObjectMethodMirror.isMethodObjectMethod()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment