MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / before

Method before

test/BaseTestRegionClient.java:87–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85 protected RegionClient region_client;
86
87 @Before
88 public void before() throws Exception {
89 config = new Config();
90 hbase_client = mock(HBaseClient.class);
91 timer = new FakeTimer();
92 when(hbase_client.getConfig()).thenReturn(config);
93 when(hbase_client.getTimer()).thenReturn(timer);
94 when(hbase_client.getRpcTimeoutTimer()).thenReturn(timer);
95 when(hbase_client.getDefaultRpcTimeout()).thenReturn(60000);
96
97 chan = mock(Channel.class, Mockito.RETURNS_DEEP_STUBS);
98 ctx = mock(ChannelHandlerContext.class);
99 cse = mock(ChannelStateEvent.class);
100 secure_rpc_helper = mock(SecureRpcHelper.class);
101
102 when(ctx.getChannel()).thenReturn(chan);
103 final HeapChannelBufferFactory factory = new HeapChannelBufferFactory();
104 when(chan.getConfig().getBufferFactory()).thenReturn(factory);
105
106 PowerMockito.doAnswer(new Answer<RegionClient>(){
107 @Override
108 public RegionClient answer(InvocationOnMock invocation) throws Throwable {
109 final Object[] args = invocation.getArguments();
110 final String endpoint = (String)args[0] + ":" + (Integer)args[1];
111 final RegionClient rc = mock(RegionClient.class);
112 when(rc.getRemoteAddress()).thenReturn(endpoint);
113 return rc;
114 }
115 }).when(hbase_client, "newClient", anyString(), anyInt());
116
117 region_client = PowerMockito.spy(new RegionClient(hbase_client));
118 Whitebox.setInternalState(region_client, "chan", chan);
119 Whitebox.setInternalState(region_client, "server_version",
120 RegionClient.SERVER_VERSION_095_OR_ABOVE);
121 rpcs_inflight = Whitebox.getInternalState(region_client, "rpcs_inflight");
122 }
123
124 /**
125 * Injects the security helper mock in the class. The default is to operate

Callers

nothing calls this directly

Calls 5

getConfigMethod · 0.80
getTimerMethod · 0.80
getRpcTimeoutTimerMethod · 0.80
getDefaultRpcTimeoutMethod · 0.80
getChannelMethod · 0.80

Tested by

no test coverage detected