本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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());
}
示例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));
}