org.apache.cxf.message.Message Java Examples
The following examples show how to use
org.apache.cxf.message.Message.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpsTokenInterceptorProvider.java From steady with Apache License 2.0 | 8 votes |
public void handleMessage(Message message) throws Fault { AssertionInfoMap aim = message.get(AssertionInfoMap.class); // extract Assertion information if (aim != null) { Collection<AssertionInfo> ais = aim.get(SP12Constants.HTTPS_TOKEN); if (ais == null) { return; } if (isRequestor(message)) { assertHttps(ais, message); } else { //server side should be checked on the way in for (AssertionInfo ai : ais) { ai.setAsserted(true); } } } }
Example #2
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testQueryParameter() throws Exception { Message messageImpl = createMessage(); ProviderFactory.getInstance(messageImpl).registerUserProvider( new GenericObjectParameterHandler()); Class<?>[] argType = {Query.class}; Method m = Customer.class.getMethod("testGenericObjectParam", argType); messageImpl.put(Message.QUERY_STRING, "p1=thequery"); List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @SuppressWarnings("unchecked") Query<String> query = (Query<String>)params.get(0); assertEquals("thequery", query.getEntity()); }
Example #3
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * Set up the decoupled Destination if necessary. */ private Destination setUpDecoupledDestination(Bus bus, String replyToAddress, Message message) { EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(replyToAddress); if (reference != null) { String decoupledAddress = reference.getAddress().getValue(); LOG.info("creating decoupled endpoint: " + decoupledAddress); try { Destination dest = getDestination(bus, replyToAddress, message); bus.getExtension(ClientLifeCycleManager.class).registerListener(DECOUPLED_DEST_CLEANER); return dest; } catch (Exception e) { // REVISIT move message to localizable Messages.properties LOG.log(Level.WARNING, "decoupled endpoint creation failed: ", e); } } return null; }
Example #4
Source File: KerberosTokenInterceptorProvider.java From steady with Apache License 2.0 | 6 votes |
static final TokenStore getTokenStore(Message message) { EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo(); synchronized (info) { TokenStore tokenStore = (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); if (tokenStore == null) { tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); } if (tokenStore == null) { TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance(); String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE; if (info.getName() != null) { cacheKey += "-" + info.getName().toString().hashCode(); } tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message); info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); } return tokenStore; } }
Example #5
Source File: RMInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
private void testHandleSequenceAck(boolean onServer) throws SequenceFault, RMException, NoSuchMethodException { Method m = RMInInterceptor.class.getDeclaredMethod("processAcknowledgments", new Class[] {RMEndpoint.class, RMProperties.class, ProtocolVariation.class}); interceptor = EasyMock.createMockBuilder(RMInInterceptor.class) .addMockedMethod(m).createMock(control); Message message = setupInboundMessage(RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, onServer); rme.receivedControlMessage(); EasyMock.expectLastCall(); interceptor.processAcknowledgments(rme, rmps, ProtocolVariation.RM10WSA200408); EasyMock.expectLastCall(); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null); control.replay(); interceptor.handle(message); }
Example #6
Source File: JwkUtils.java From cxf with Apache License 2.0 | 6 votes |
public static JsonWebKeys loadJwkSet(Message m, Properties props, PrivateKeyPasswordProvider cb) { String key = (String)props.get(JoseConstants.RSSEC_KEY_STORE_FILE); JsonWebKeys jwkSet = null; if (key != null && m != null) { Object jwkSetProp = m.getExchange().get(key); if (jwkSetProp != null && !(jwkSetProp instanceof JsonWebKeys)) { throw new JwkException("Unexpected key store class: " + jwkSetProp.getClass().getName()); } else { jwkSet = (JsonWebKeys)jwkSetProp; } } if (jwkSet == null) { jwkSet = loadJwkSet(props, m != null ? m.getExchange().getBus() : null, cb); if (key != null && m != null) { m.getExchange().put(key, jwkSet); } } return jwkSet; }
Example #7
Source File: OpenTracingTracingTest.java From cxf with Apache License 2.0 | 6 votes |
private static BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example #8
Source File: AbstractSecurityPolicyValidator.java From cxf with Apache License 2.0 | 6 votes |
/** * Check to see if a token is required or not. * @param token the token * @param message The message * @return true if the token is required */ protected boolean isTokenRequired( AbstractToken token, Message message ) { IncludeTokenType inclusion = token.getIncludeTokenType(); if (inclusion == IncludeTokenType.INCLUDE_TOKEN_NEVER) { return false; } else if (inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS) { return true; } else { boolean initiator = MessageUtils.isRequestor(message); if (initiator && (inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_INITIATOR)) { return true; } else if (!initiator && (inclusion == IncludeTokenType.INCLUDE_TOKEN_ONCE || inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_RECIPIENT)) { return true; } return false; } }
Example #9
Source File: AbstractOutDatabindingInterceptor.java From cxf with Apache License 2.0 | 6 votes |
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) { /** * Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance * boost with the JAXB RI, so its worth it. */ if (s == null) { return false; } String enc = (String)m.get(Message.ENCODING); return "org.apache.cxf.binding.soap.model.SoapBindingInfo".equals(info.getClass().getName()) && "org.apache.cxf.jaxb.JAXBDataBinding".equals(s.getDataBinding().getClass().getName()) && !MessageUtils.isDOMPresent(m) && (enc == null || StandardCharsets.UTF_8.name().equals(enc)); }
Example #10
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testContextAnnotationOnMethod() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); Customer c = new Customer(); cri.setResourceProvider(new SingletonResourceProvider(c)); InjectionUtils.injectContextProxies(cri, cri.getResourceProvider().getInstance(null)); OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethods()[0], cri); Message message = createMessage(); InjectionUtils.injectContextMethods(c, ori.getClassResourceInfo(), message); assertNotNull(c.getUriInfo()); assertSame(ThreadLocalUriInfo.class, c.getUriInfo().getClass()); assertSame(UriInfoImpl.class, ((ThreadLocalProxy<UriInfo>)c.getUriInfo()).get().getClass()); assertSame(ThreadLocalServletConfig.class, c.getSuperServletConfig().getClass()); assertSame(ThreadLocalHttpServletRequest.class, c.getHttpServletRequest().getClass()); }
Example #11
Source File: CorbaServerConduitTest.java From cxf with Apache License 2.0 | 6 votes |
protected CorbaServerConduit setupCorbaServerConduit(boolean send) { target = EasyMock.createMock(EndpointReferenceType.class); endpointInfo = EasyMock.createMock(EndpointInfo.class); CorbaServerConduit corbaServerConduit = new CorbaServerConduit(endpointInfo, target, targetObject, null, orbConfig, corbaTypeMap); if (send) { // setMessageObserver observer = new MessageObserver() { public void onMessage(Message m) { inMessage = m; } }; corbaServerConduit.setMessageObserver(observer); } return corbaServerConduit; }
Example #12
Source File: CryptoCoverageCheckerTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #13
Source File: ResponseTimeMessageInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testServiceMessageIn() { setupCounterRepository(true, false); setupExchangeForMessage(); EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes(); EasyMock.expect(message.getExchange()).andReturn(exchange); EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null); EasyMock.expect(exchange.getOutMessage()).andReturn(message); EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null); exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), EasyMock.isA(MessageHandlingTimeRecorder.class)); EasyMock.replay(exchange); EasyMock.replay(message); rtmii.handleMessage(message); EasyMock.verify(message); EasyMock.verify(exchange); }
Example #14
Source File: AbstractHTTPDestination.java From cxf with Apache License 2.0 | 6 votes |
@Override public String getId(Map<String, Object> context) { String id = null; if (isMultiplexWithAddress()) { String address = (String)context.get(Message.PATH_INFO); if (null != address) { int afterLastSlashIndex = address.lastIndexOf('/') + 1; if (afterLastSlashIndex > 0 && afterLastSlashIndex < address.length()) { id = address.substring(afterLastSlashIndex); } } else { getLogger().log(Level.WARNING, new org.apache.cxf.common.i18n.Message( "MISSING_PATH_INFO", LOG).toString()); } } else { return super.getId(context); } return id; }
Example #15
Source File: AbstractSupportingTokenPolicyValidator.java From cxf with Apache License 2.0 | 6 votes |
/** * Validate (SignedParts|SignedElements|EncryptedParts|EncryptedElements) policies of this * SupportingToken. */ private boolean validateSignedEncryptedPolicies(List<WSSecurityEngineResult> tokenResults, List<WSSecurityEngineResult> signedResults, List<WSSecurityEngineResult> encryptedResults, Message message) { if (!validateSignedEncryptedParts(signedParts, false, signedResults, tokenResults, message)) { return false; } if (!validateSignedEncryptedParts(encryptedParts, true, encryptedResults, tokenResults, message)) { return false; } if (!validateSignedEncryptedElements(signedElements, signedResults, tokenResults, message)) { return false; } return validateSignedEncryptedElements(encryptedElements, encryptedResults, tokenResults, message); }
Example #16
Source File: FormUtils.java From cxf with Apache License 2.0 | 6 votes |
private static void checkNumberOfParts(Message m, int numberOfParts) { if (m == null || m.getExchange() == null || m.getExchange().getInMessage() == null) { return; } String maxPartsCountProp = (String)m.getExchange() .getInMessage().getContextualProperty(MAX_FORM_PARAM_COUNT); if (maxPartsCountProp == null) { return; } try { int maxPartsCount = Integer.parseInt(maxPartsCountProp); if (maxPartsCount != -1 && numberOfParts >= maxPartsCount) { throw new WebApplicationException(413); } } catch (NumberFormatException ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } }
Example #17
Source File: NettyHttpDestinationTest.java From cxf with Apache License 2.0 | 6 votes |
private void verifyRequestHeaders() throws Exception { Map<String, List<String>> requestHeaders = CastUtils.cast((Map<?, ?>)inMessage.get(Message.PROTOCOL_HEADERS)); assertNotNull("expected request headers", requestHeaders); List<String> values = requestHeaders.get("content-type"); assertNotNull("expected field", values); assertEquals("unexpected values", 2, values.size()); assertTrue("expected value", values.contains("text/xml")); assertTrue("expected value", values.contains("charset=utf8")); values = requestHeaders.get(AUTH_HEADER); assertNotNull("expected field", values); assertEquals("unexpected values", 1, values.size()); assertTrue("expected value", values.contains(BASIC_AUTH)); AuthorizationPolicy authpolicy = inMessage.get(AuthorizationPolicy.class); assertNotNull("Expected some auth tokens", policy); assertEquals("expected user", USER, authpolicy.getUserName()); assertEquals("expected passwd", PASSWD, authpolicy.getPassword()); }
Example #18
Source File: AhcWebSocketConduit.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void setupConnection(Message message, Address address, HTTPClientPolicy csPolicy) throws IOException { URI currentURL = address.getURI(); String s = currentURL.getScheme(); if (!"ws".equals(s) && !"wss".equals(s)) { throw new MalformedURLException("unknown protocol: " + s); } message.put("http.scheme", currentURL.getScheme()); String httpRequestMethod = (String)message.get(Message.HTTP_REQUEST_METHOD); if (httpRequestMethod == null) { httpRequestMethod = "POST"; message.put(Message.HTTP_REQUEST_METHOD, httpRequestMethod); } final AhcWebSocketConduitRequest request = new AhcWebSocketConduitRequest(currentURL, httpRequestMethod); final int rtimeout = determineReceiveTimeout(message, csPolicy); request.setReceiveTimeout(rtimeout); message.put(AhcWebSocketConduitRequest.class, request); }
Example #19
Source File: IssuedTokenInterceptorProvider.java From steady with Apache License 2.0 | 6 votes |
static final TokenStore createTokenStore(Message message) { EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo(); synchronized (info) { TokenStore tokenStore = (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); if (tokenStore == null) { tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); } if (tokenStore == null) { TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance(); String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE; if (info.getName() != null) { cacheKey += "-" + info.getName().toString().hashCode(); } tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message); info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); } return tokenStore; } }
Example #20
Source File: CryptoCoverageCheckerTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #21
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testPerRequestContextFields() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); cri.setResourceProvider(new PerRequestResourceProvider(Customer.class)); OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethod("postConstruct", new Class[]{}), cri); Customer c = new Customer(); Message m = createMessage(); m.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>()); HttpServletResponse response = EasyMock.createMock(HttpServletResponse.class); m.put(AbstractHTTPDestination.HTTP_RESPONSE, response); InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m); assertSame(UriInfoImpl.class, c.getUriInfo2().getClass()); assertSame(HttpHeadersImpl.class, c.getHeaders().getClass()); assertSame(RequestImpl.class, c.getRequest().getClass()); assertSame(SecurityContextImpl.class, c.getSecurityContext().getClass()); assertSame(ProvidersImpl.class, c.getBodyWorkers().getClass()); }
Example #22
Source File: ReactiveIOInvoker.java From cxf with Apache License 2.0 | 5 votes |
protected AsyncResponseImpl handleSingle(Message inMessage, Single<?> single) { final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage); Disposable d = single.subscribe(asyncResponse::resume, t -> handleThrowable(asyncResponse, t)); if (d == null) { throw new IllegalStateException("Subscribe did not return a Disposable"); } return asyncResponse; }
Example #23
Source File: AttachmentOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(Message message) { AttachmentSerializer ser = message.getContent(AttachmentSerializer.class); if (ser != null) { try { String cte = (String)message.getContextualProperty(Message.CONTENT_TRANSFER_ENCODING); if (cte != null) { ser.setContentTransferEncoding(cte); } ser.writeAttachments(); } catch (IOException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("WRITE_ATTACHMENTS", BUNDLE), e); } } }
Example #24
Source File: SpnegoTokenInterceptorProvider.java From steady with Apache License 2.0 | 5 votes |
private static void mapSecurityProps(Message message, Map<String, Object> ctx) { for (String s : SecurityConstants.ALL_PROPERTIES) { Object v = message.getContextualProperty(s); if (v != null) { ctx.put(s, v); } } }
Example #25
Source File: RPCOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testWriteOutbound() throws Exception { RPCOutInterceptor interceptor = new RPCOutInterceptor(); soapMessage.setContent(XMLStreamWriter.class, XMLOutputFactory.newInstance().createXMLStreamWriter( baos)); soapMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE); interceptor.handleMessage(soapMessage); assertNull(soapMessage.getContent(Exception.class)); soapMessage.getContent(XMLStreamWriter.class).flush(); baos.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr = StaxUtils.createXMLStreamReader(bais); DepthXMLStreamReader reader = new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit", "sendReceiveData"), reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName(null, "in"), reader.getName()); StaxUtils.toNextText(reader); assertEquals("elem1", reader.getText()); }
Example #26
Source File: SecuredPartsPolicyValidator.java From cxf with Apache License 2.0 | 5 votes |
private boolean isTransportBinding(AssertionInfoMap aim, Message message) { AssertionInfo symAis = PolicyUtils.getFirstAssertionByLocalname(aim, SPConstants.SYMMETRIC_BINDING); if (symAis != null) { return false; } AssertionInfo asymAis = PolicyUtils.getFirstAssertionByLocalname(aim, SPConstants.ASYMMETRIC_BINDING); if (asymAis != null) { return false; } AssertionInfo transAis = PolicyUtils.getFirstAssertionByLocalname(aim, SPConstants.TRANSPORT_BINDING); if (transAis != null) { return true; } // No bindings, check if we are using TLS TLSSessionInfo tlsInfo = message.get(TLSSessionInfo.class); if (tlsInfo != null) { // We don't need to check these policies for TLS PolicyUtils.assertPolicy(aim, SP12Constants.ENCRYPTED_PARTS); PolicyUtils.assertPolicy(aim, SP11Constants.ENCRYPTED_PARTS); PolicyUtils.assertPolicy(aim, SP12Constants.SIGNED_PARTS); PolicyUtils.assertPolicy(aim, SP11Constants.SIGNED_PARTS); return true; } return false; }
Example #27
Source File: AbstractXmlEncInHandler.java From cxf with Apache License 2.0 | 5 votes |
protected byte[] decryptSymmetricKey(String base64EncodedKey, X509Certificate cert, Crypto crypto, String keyEncAlgo, Message message) throws WSSecurityException { return decryptSymmetricKey(base64EncodedKey, cert, crypto, keyEncAlgo, null, message); }
Example #28
Source File: SpnegoContextTokenInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private SpnegoTokenContext handleBinaryExchange( Element binaryExchange, Message message, String namespace ) throws Exception { if (binaryExchange == null) { throw new Exception("No BinaryExchange element received"); } String encoding = binaryExchange.getAttributeNS(null, "EncodingType"); if (!WSS4JConstants.BASE64_ENCODING.equals(encoding)) { throw new Exception("Unknown encoding type: " + encoding); } String valueType = binaryExchange.getAttributeNS(null, "ValueType"); if (!(namespace + "/spnego").equals(valueType)) { throw new Exception("Unknown value type: " + valueType); } String content = DOMUtils.getContent(binaryExchange); byte[] decodedContent = XMLUtils.decode(content); String jaasContext = (String)message.getContextualProperty(SecurityConstants.KERBEROS_JAAS_CONTEXT_NAME); String kerberosSpn = (String)message.getContextualProperty(SecurityConstants.KERBEROS_SPN); CallbackHandler callbackHandler = SecurityUtils.getCallbackHandler( SecurityUtils.getSecurityPropertyValue(SecurityConstants.CALLBACK_HANDLER, message) ); SpnegoTokenContext spnegoToken = new SpnegoTokenContext(); spnegoToken.validateServiceTicket( jaasContext, callbackHandler, kerberosSpn, decodedContent ); return spnegoToken; }
Example #29
Source File: WadlGeneratorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGenericImplementation() throws Exception { setUpGenericImplementationTest(); WadlGenerator wg = new WadlGenerator(); wg.setApplicationTitle("My Application"); wg.setNamespacePrefix("ns"); ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(ActualResource.class, ActualResource.class, true, true); Message m = mockMessage("http://example.com", "/", WadlGenerator.WADL_QUERY, cri); Response r = handleRequest(wg, m); checkResponse(r); Document doc = StaxUtils.read(new StringReader(r.getEntity().toString())); checkDocs(doc.getDocumentElement(), "My Application", "", ""); List<Element> grammarEls = DOMUtils.getChildrenWithName(doc.getDocumentElement(), WadlGenerator.WADL_NS, "grammars"); assertEquals(1, grammarEls.size()); List<Element> schemasEls = DOMUtils.getChildrenWithName(grammarEls.get(0), Constants.URI_2001_SCHEMA_XSD, "schema"); assertEquals(2, schemasEls.size()); List<Element> importEls = DOMUtils.getChildrenWithName(schemasEls.get(0), Constants.URI_2001_SCHEMA_XSD, "import"); int schemaElementsIndex = !importEls.isEmpty() ? 0 : 1; int schemaTypesIndex = schemaElementsIndex == 0 ? 1 : 0; checkGenericImplSchemaWithTypes(schemasEls.get(schemaTypesIndex)); checkGenericImplSchemaWithElements(schemasEls.get(schemaElementsIndex)); List<Element> reps = DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(), WadlGenerator.WADL_NS, "representation"); assertEquals(2, reps.size()); assertEquals("ns1:actual", reps.get(0).getAttribute("element")); assertEquals("ns1:actual", reps.get(1).getAttribute("element")); }
Example #30
Source File: MicroProfileClientProxyImpl.java From cxf with Apache License 2.0 | 5 votes |
private void mergeHeaders(Class<ClientHeadersFactory> factoryCls, MultivaluedMap<String, String> existingHeaders) { try { ClientHeadersFactory factory; Message m = JAXRS_UTILS_GET_CURRENT_MESSAGE_METHOD == null ? null : (Message) JAXRS_UTILS_GET_CURRENT_MESSAGE_METHOD.invoke(null); if (m != null) { factory = CDIFacade.getInstanceFromCDI(factoryCls, m.getExchange().getBus()) .map(this::mapInstance) .orElse(factoryCls.newInstance()); ProviderInfo<ClientHeadersFactory> pi = clientHeaderFactories.computeIfAbsent(factoryCls, k -> { return new ProviderInfo<ClientHeadersFactory>(factory, m.getExchange().getBus(), true); }); InjectionUtils.injectContexts(factory, pi, m); } else { factory = CDIFacade.getInstanceFromCDI(factoryCls) .map(this::mapInstance) .orElse(factoryCls.newInstance()); } MultivaluedMap<String, String> updatedHeaders = factory.update(getJaxrsHeaders(m), existingHeaders); existingHeaders.putAll(updatedHeaders); } catch (Throwable t) { // expected if not running in a JAX-RS server environment. if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Caught exception getting JAX-RS incoming headers", t); } } }