Search in sources :

Example 1 with MyException

use of com.alibaba.dubbo.rpc.protocol.hessian.HessianServiceImpl.MyException in project dubbo by alibaba.

the class HessianProtocolTest method testCustomException.

@Test
public void testCustomException() {
    HessianServiceImpl server = new HessianServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    try {
        client.customException();
        fail();
    } catch (MyException expected) {
    }
    invoker.destroy();
    exporter.unexport();
}
Also used : MyException(com.alibaba.dubbo.rpc.protocol.hessian.HessianServiceImpl.MyException) ProxyFactory(com.alibaba.dubbo.rpc.ProxyFactory) Protocol(com.alibaba.dubbo.rpc.Protocol) URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Aggregations

URL (com.alibaba.dubbo.common.URL)1 Protocol (com.alibaba.dubbo.rpc.Protocol)1 ProxyFactory (com.alibaba.dubbo.rpc.ProxyFactory)1 MyException (com.alibaba.dubbo.rpc.protocol.hessian.HessianServiceImpl.MyException)1 Test (org.junit.Test)1