use of com.alipay.sofa.rpc.core.exception.SofaRouteException in project sofa-rpc by sofastack.
the class BoltExceptionTest method testAll.
@Test
public void testAll() {
final String directUrl = "bolt://127.0.0.1:12300";
final ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setDirectUrl(directUrl).setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT).setBootstrap("bolt").setApplication(new ApplicationConfig().setAppName("clientApp")).setReconnectPeriod(1000);
HelloService helloService = consumerConfig.refer();
// 关闭后再调用一个抛异常
try {
helloService.sayHello("xx", 22);
} catch (Exception e) {
// 应该抛出异常
Assert.assertTrue(e instanceof SofaRouteException);
Assert.assertTrue(e.getMessage().contains(directUrl));
}
}
Aggregations