Intercepting toString method invocation for gateway proxy (related to INT-239).

This commit is contained in:
Mark Fisher
2008-06-02 17:41:48 +00:00
parent af259f40f9
commit c28a4bc448
2 changed files with 67 additions and 7 deletions

View File

@@ -145,6 +145,32 @@ public class GatewayProxyFactoryBeanTests {
assertEquals("foobar", result.getPayload());
}
@Test
public void testServiceMustBeInterface() {
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
int count = 0;
try {
proxyFactory.setServiceInterface(TestService.class);
count++;
proxyFactory.setServiceInterface(String.class);
count++;
}
catch (IllegalArgumentException e) {
// expected
}
assertEquals(1, count);
}
@Test
public void testProxiedToStringMethod() throws Exception {
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
proxyFactory.setServiceInterface(TestService.class);
proxyFactory.afterPropertiesSet();
Object proxy = proxyFactory.getObject();
String expected = "gateway proxy for";
assertEquals(expected, proxy.toString().substring(0, expected.length()));
}
private static void startResponder(final MessageChannel requestChannel) {
new Thread(new Runnable() {