MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / setupUnwrap

Method setupUnwrap

test/BaseTestSecureRpcHelper.java:156–171  ·  view source on GitHub ↗

Helper to unwrap a wrapped buffer, pretending the sasl client simply prepends the length. @throws Exception Exception it really shouldn't. Really.

()

Source from the content-addressed store, hash-verified

154 * @throws Exception Exception it really shouldn't. Really.
155 */
156 protected void setupUnwrap() throws Exception {
157 // TODO - figure out a way to use real wrapping. For now we just stick on
158 // two bytes or take em off.
159 when(sasl_client.unwrap(any(byte[].class), anyInt(), anyInt()))
160 .thenAnswer(new Answer<byte[]>() {
161 @Override
162 public byte[] answer(final InvocationOnMock invocation)
163 throws Throwable {
164 final byte[] buffer = (byte[])invocation.getArguments()[0];
165 final int length = (Integer)invocation.getArguments()[2];
166 final byte[] unwrapped = new byte[length - 4];
167 System.arraycopy(buffer, 4, unwrapped, 0, length - 4);
168 return unwrapped;
169 }
170 });
171 }
172
173 /**
174 * Helper to wrap a buffer, pretending the sasl client simply prepends the

Callers 4

unwrapMethod · 0.80
unwrapNotWrappedMethod · 0.80

Calls 1

unwrapMethod · 0.45

Tested by

no test coverage detected