Search in sources :

Example 1 with SofaRouteException

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));
    }
}
Also used : SofaRouteException(com.alipay.sofa.rpc.core.exception.SofaRouteException) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) HelloService(com.alipay.sofa.rpc.test.HelloService) ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) SofaRouteException(com.alipay.sofa.rpc.core.exception.SofaRouteException) ActivelyDestroyTest(com.alipay.sofa.rpc.test.ActivelyDestroyTest) Test(org.junit.Test)

Aggregations

ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)1 ConsumerConfig (com.alipay.sofa.rpc.config.ConsumerConfig)1 SofaRouteException (com.alipay.sofa.rpc.core.exception.SofaRouteException)1 ActivelyDestroyTest (com.alipay.sofa.rpc.test.ActivelyDestroyTest)1 HelloService (com.alipay.sofa.rpc.test.HelloService)1 Test (org.junit.Test)1