### Question:
JaxWsHandler extends SoapClientHandler<BindingProvider> { @Override public void setHeader(BindingProvider soapClient, String namespace, String headerName, Object headerValue) { if (headerValue instanceof SOAPElement) { getContextHandlerFromClient(soapClient).addHeader(namespace, headerName, (SOAPElement) headerValue); } else { throw new ServiceException("Unexpected SOAP header given for JAX-WS binding. Given " + "object of class \"" + headerValue.getClass().toString() + "\" but expecting " + "object of class \"" + SOAPElement.class + "\".", null); } } @Inject protected  JaxWsHandler(Provider<JaxWsSoapContextHandler> contextHandlerProvider); @Override void setEndpointAddress(BindingProvider soapClient, String endpointAddress); @Override Object getHeader(BindingProvider soapClient, String headerName); @Override void clearHeaders(BindingProvider soapClient); @Override void setHeader(BindingProvider soapClient, String namespace, String headerName,
      Object headerValue); void setHeaderChildString(BindingProvider soapClient, final String headerName,
      String childNamespace, String childName, String childValue); @Override void putAllHttpHeaders(BindingProvider soapClient, Map<String, String> headersMap); @Override void setCompression(BindingProvider soapClient, boolean compress); @Override BindingProvider createSoapClient(SoapServiceDescriptor soapServiceDescriptor); @Override void setRequestTimeout(BindingProvider bindingProvider, int timeout); @Override RemoteCallReturn invokeSoapCall(SoapCall<BindingProvider> soapCall); @Override String getEndpointAddress(BindingProvider soapClient); @Override SOAPHeaderElement createSoapHeaderElement(QName qName);  }### Answer:
@Test public void testSetHeader() { String namespace = "namespace"; String headerName = "headerName"; final SOAPElement headerValue = Mockito.mock(SOAPElement.class); when(mockSoapClient.getBinding()).thenReturn(mockBinding); when(mockBinding.getHandlerChain()).thenReturn(handlerChain); jaxWsHandler.setHeader(mockSoapClient, namespace, headerName, headerValue); assertEquals(ImmutableSet.of(headerValue), contextHandler.getAddedHeaders()); }
@Test public void testSetHeader_fail() { String namespace = "namespace"; String headerName = "headerName"; Object headerValue = new Object(); thrown.expect(ServiceException.class); jaxWsHandler.setHeader(mockSoapClient, namespace, headerName, headerValue); }