当前位置: 首页>>代码示例>>Java>>正文


Java HeaderExchangeHandler类代码示例

本文整理汇总了Java中com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler的典型用法代码示例。如果您正苦于以下问题:Java HeaderExchangeHandler类的具体用法?Java HeaderExchangeHandler怎么用?Java HeaderExchangeHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HeaderExchangeHandler类属于com.alibaba.dubbo.remoting.exchange.support.header包,在下文中一共展示了HeaderExchangeHandler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_received_request_oneway

import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler; //导入依赖的package包/类
@Test
public void test_received_request_oneway() throws RemotingException{
    final Channel mchannel = new MockedChannel();
    
    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);
    
    ExchangeHandler exhandler = new MockedExchangeHandler(){
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:HeaderExchangeHandlerTest.java

示例2: test_received_request_twoway_error_reqeustBroken

import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler; //导入依赖的package包/类
@Test
public void test_received_request_twoway_error_reqeustBroken() throws RemotingException{
    final Request request = new Request();
    request.setTwoWay(true);
    request.setData(new BizException());
    request.setBroken(true);
    
    final AtomicInteger count = new AtomicInteger(0);
    final Channel mchannel = new MockedChannel(){
        @Override
        public void send(Object message) throws RemotingException {
            Response res = (Response)message;
            Assert.assertEquals(request.getId(), res.getId());
            Assert.assertEquals(request.getVersion(), res.getVersion());
            Assert.assertEquals(Response.BAD_REQUEST, res.getStatus());
            Assert.assertNull(res.getResult());
            Assert.assertTrue(res.getErrorMessage().contains(BizException.class.getName()));
            count.incrementAndGet();
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler());
    hexhandler.received(mchannel, request);
    Assert.assertEquals(1, count.get());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:HeaderExchangeHandlerTest.java

示例3: test_received_request_oneway

import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler; //导入依赖的package包/类
@Test
public void test_received_request_oneway() throws RemotingException {
    final Channel mchannel = new MockedChannel();

    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);

    ExchangeHandler exhandler = new MockedExchangeHandler() {
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:18,代码来源:HeaderExchangeHandlerTest.java

示例4: test_received_request_twoway_error_reqeustBroken

import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler; //导入依赖的package包/类
@Test
public void test_received_request_twoway_error_reqeustBroken() throws RemotingException {
    final Request request = new Request();
    request.setTwoWay(true);
    request.setData(new BizException());
    request.setBroken(true);

    final AtomicInteger count = new AtomicInteger(0);
    final Channel mchannel = new MockedChannel() {
        @Override
        public void send(Object message) throws RemotingException {
            Response res = (Response) message;
            Assert.assertEquals(request.getId(), res.getId());
            Assert.assertEquals(request.getVersion(), res.getVersion());
            Assert.assertEquals(Response.BAD_REQUEST, res.getStatus());
            Assert.assertNull(res.getResult());
            Assert.assertTrue(res.getErrorMessage().contains(BizException.class.getName()));
            count.incrementAndGet();
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler());
    hexhandler.received(mchannel, request);
    Assert.assertEquals(1, count.get());
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:25,代码来源:HeaderExchangeHandlerTest.java

示例5: test_received_request_event_readonly

import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler; //导入依赖的package包/类
@Test
public void test_received_request_event_readonly() throws RemotingException{
    final Request request = new Request();
    request.setTwoWay(true);
    request.setEvent(Request.READONLY_EVENT);
    
    final Channel mchannel = new MockedChannel();
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler());
    hexhandler.received(mchannel, request);
    Assert.assertTrue(mchannel.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:HeaderExchangeHandlerTest.java


注:本文中的com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。