()
| 530 | } |
| 531 | |
| 532 | @Test |
| 533 | public void wrap() throws Exception { |
| 534 | final SecureRpcHelper helper = mock(SecureRpcHelper.class); |
| 535 | Whitebox.setInternalState(region_client, "secure_rpc_helper", helper); |
| 536 | doAnswer(new Answer<ChannelBuffer>() { |
| 537 | @Override |
| 538 | public ChannelBuffer answer(final InvocationOnMock invocation) |
| 539 | throws Throwable { |
| 540 | return ChannelBuffers.wrappedBuffer(new byte[]{ 42 }); |
| 541 | } |
| 542 | }).when(helper).wrap(any(ChannelBuffer.class)); |
| 543 | |
| 544 | final GetRequest get = new GetRequest(TABLE, KEY, FAMILY, QUALIFIER); |
| 545 | get.setRegion(region); |
| 546 | get.getDeferred(); // required to initialize the deferred |
| 547 | |
| 548 | region_client.sendRpc(get); |
| 549 | |
| 550 | PowerMockito.verifyStatic(times(1)); |
| 551 | Channels.write((Channel)any(), (ChannelBuffer)any()); |
| 552 | verify(hbase_client, never()).sendRpcToRegion(get); |
| 553 | assertEquals(1, region_client.stats().rpcsSent()); |
| 554 | assertEquals(0, region_client.stats().pendingBatchedRPCs()); |
| 555 | assertEquals(0, region_client.stats().pendingRPCs()); |
| 556 | verify(helper, times(1)).wrap(any(ChannelBuffer.class)); |
| 557 | } |
| 558 | |
| 559 | @Test |
| 560 | public void pendingBreached() throws Exception { |
nothing calls this directly
no test coverage detected