### Question:
JerseyInvocation implements javax.ws.rs.client.Invocation { ClientRequest request() { return requestContext; } private  JerseyInvocation(final Builder builder); private  JerseyInvocation(final Builder builder, final boolean copyRequestContext); @Override Response invoke(); @Override T invoke(final Class<T> responseType); @Override T invoke(final GenericType<T> responseType); @Override Future<Response> submit(); @Override Future<T> submit(final Class<T> responseType); @Override Future<T> submit(final GenericType<T> responseType); @Override Future<T> submit(final InvocationCallback<T> callback); Future<T> submit(final GenericType<T> responseType, final InvocationCallback<T> callback); @Override JerseyInvocation property(final String name, final Object value); @Override String toString();  }### Answer:
@Test public void testOverrideHeadersWithMap() { final MultivaluedMap<String, Object> map = new MultivaluedHashMap<String, Object>(); map.add("a-header", "b-header"); final JerseyInvocation invocation = buildInvocationWithHeaders(map); assertEquals(1, invocation.request().getHeaders().size()); assertEquals("b-header", invocation.request().getHeaders().getFirst("a-header")); }
@Test public void testClearHeaders() { final JerseyInvocation invocation = buildInvocationWithHeaders(null); assertTrue(invocation.request().getHeaders().isEmpty()); }
@Test public void testClearHeader() { final Client client = ClientBuilder.newClient(); final Invocation.Builder builder = client.target("http: final JerseyInvocation invocation = (JerseyInvocation) builder .header("foo", "bar").header("foo", null).header("bar", "foo") .buildGet(); final MultivaluedMap<String, Object> headers = invocation.request().getHeaders(); assertThat(headers.size(), is(1)); assertThat(headers.keySet(), hasItem("bar")); }
@Test public void runtimeExceptionInAsyncInvocation() throws ExecutionException, InterruptedException { final AsyncInvoker ai = ClientBuilder.newClient().register(new ExceptionInvokerFilter()) .target("http: try { ai.get().get(); fail("ExecutionException should be thrown"); } catch (ExecutionException ee) { assertEquals(ProcessingException.class, ee.getCause().getClass()); assertEquals(RuntimeException.class, ee.getCause().getCause().getClass()); } }