ThriftProtocol extends AbstractProxyProtocol { public ThriftProtocol() { super(TException.class, RpcException.class); } ThriftProtocol();  ThriftProtocol(Class<?>... exceptions); @Override int getDefaultPort(); static final int DEFAULT_PORT; static final String NAME; static final String THRIFT_IFACE; static final String THRIFT_PROCESSOR; static final String THRIFT_CLIENT; }
@Test public void testThriftProtocol() throws TException { DemoServiceImpl server = new DemoServiceImpl(); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); int port = NetUtils.getAvailablePort(); URL url = URL.valueOf(org.apache.dubbo.rpc.protocol.nativethrift.ThriftProtocol.NAME + ": Exporter<DemoService.Iface> exporter = protocol.export(proxyFactory.getInvoker(server, DemoService.Iface.class, url)); Invoker<DemoService.Iface> invoker = protocol.refer(DemoService.Iface.class, url); DemoService.Iface client = proxyFactory.getProxy(invoker); String result = client.sayHello("haha"); Assertions.assertTrue(server.isCalled()); Assertions.assertEquals("Hello, haha", result); invoker.destroy(); exporter.unexport(); }