Package org.apache.servicemix.jbi.messaging

Examples of org.apache.servicemix.jbi.messaging.NormalizedMessageImpl


   * helper method to return a new JBI NormalizedMessage when we need one
   *
   * @return
   */
  private NormalizedMessage makeTestMessage(String xml) {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME, TEST_STRING);
    if (xml == null) {
      xml = "<this><is><some attr='1234'>xml123</some></is></this>";
    }
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here


   * helper method to return a new JBI NormalizedMessage
   * when we need one
   * @return
   */
  private NormalizedMessage getTestMessage() {
    NormalizedMessage message = new NormalizedMessageImpl();
    message.setProperty(PROPNAME,TEST_STRING);
    String xml = "<this><is><some attr='1234'>xml123</some></is></this>";
    try {
      DocumentBuilder db;
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document dom = db.parse(new InputSource(new StringReader(xml)));
      message.setContent(new DOMSource(dom));
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
    return message;
  }
View Full Code Here

  protected void testToNMS(MessageFactory messageFactory) throws Exception {
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", "text/xml;");
    InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/http/soap-response.xml");
    SOAPMessage sm = messageFactory.createMessage(headers, is);
    NormalizedMessage nm = new NormalizedMessageImpl();
    new SaajMarshaler().toNMS(nm, sm);

        Node node = new SourceTransformer().toDOMNode(new SourceTransformer().toStreamSource(nm.getContent()));
        log.info(new SourceTransformer().toString(node));
   
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name() = 'userId']");
        Element root = (Element) iterator.nextNode();
View Full Code Here

        
        InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/saaj/xml-request.xml");        
        log.info("Raw XML: " + new SourceTransformer().toString(new StreamSource(is)));
        
        is = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/components/saaj/xml-request.xml");        
        NormalizedMessage nm = new NormalizedMessageImpl();
        nm.setContent(new StreamSource(is));
          
        SaajMarshaler marshaler = new SaajMarshaler();
        marshaler.setMessageFactory(messageFactory);
        SOAPMessage msg = marshaler.createSOAPMessage(nm);
       
View Full Code Here

        //assertExpression(new XMLBeansStringXPathExpression("foo/bar/text()"), "cheese", "<foo><bar>cheese</bar></foo>");
    }

    protected void assertExpression(Expression expression, String expected, String xml) throws MessagingException {
        MessageExchangeImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setProperty("name", "James");
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
    }
View Full Code Here

        r.close();
        new SourceTransformer().contentToString(msg);
    }
   
    protected NormalizedMessage copyMessage(Source src) throws Exception {
        NormalizedMessage from = new NormalizedMessageImpl();
        NormalizedMessage to = new NormalizedMessageImpl();
        from.setContent(src);
        transformer.transform(null, from, to);
        return to;
    }
View Full Code Here

        assertExpression(exp, params, "<header>" + xStream.toXML(params) + "</header>");
    }

    protected void assertExpression(Expression expression, Object expected, String xml) throws MessagingException {
        InOnlyImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.messaging.NormalizedMessageImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.