Package org.jboss.soa.esb.message

Examples of org.jboss.soa.esb.message.Message


  }

  @Test
  public void routeXMLMessageUsingXPathMatch() throws MessageRouterException
  {
    Message message = createMessage( MessageType.JBOSS_XML);
    message.getBody().add(("<jbossesb>TEST BODY</jbossesb>").getBytes());
    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBRules-XPath.drl").ruleLanguage("XPathLanguage.dsl").build();
    jbrRouter.setConfigTree( configTree );

    List<String> destinationServices = jbrRouter.route(null,null, false, message, null);
    assertEquals(destinationServices.iterator().next(),"XML_XPath_Destination");
View Full Code Here


  }

  @Test
  public void routeXMLMessageUsingXPathEquals() throws MessageRouterException
  {
    Message message = createMessage( MessageType.JBOSS_XML );
    message.getBody().add(("<Dave>rocks</Dave>").getBytes());

    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBRules-XPath.drl").ruleLanguage("XPathLanguage.dsl").build();
    jbrRouter.setConfigTree( configTree );

    List<String> destinationServices = jbrRouter.route(null,null, false, message, null);
View Full Code Here

  }

  @Test
  public void routeXMLMessageUsingXPathGreaterThen() throws MessageRouterException
  {
    Message message = createMessage( MessageType.JBOSS_XML );
    message.getBody().add(("<price>1.55</price>").getBytes());

    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBRules-XPath.drl").ruleLanguage("XPathLanguage.dsl").build();
    jbrRouter.setConfigTree( configTree );

    List<String> destinationServices = jbrRouter.route(null, null,false, message, null);
View Full Code Here

  @Test
  public void routeXMLMessageUsingXPathLessThen()
  {
    try {
      //add new messages
      Message message = MessageFactory.getInstance().getMessage( MessageType.JBOSS_XML );
      //set the body inside the Message
      message.getBody().add(("<price>0.55</price>").getBytes());
      ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBRules-XPath.drl").ruleLanguage("XPathLanguage.dsl").build();
        jbrRouter.setConfigTree( configTree );

      List<String> destinationServices = jbrRouter.route(null, null,false,message,null);
      assertEquals(destinationServices.iterator().next(),"XML_XPath_LessThan_Destination");
View Full Code Here

  @Test ( expected = IllegalArgumentException.class )
  public void shouldThrowIfNoRuleSetIsSupplied() throws MessageRouterException
  {
    //add new messages
    Message message = MessageFactory.getInstance().getMessage( MessageType.JBOSS_XML );
    ConfigTree configTree = new ConfigTree("bad-config");
    jbrRouter.setConfigTree( configTree );

    jbrRouter.route( null ,"XPathLanguage.dsl",false,message,null);
  }
View Full Code Here

  @Test ( expected = IllegalStateException.class )
  public void shouldThrowIfRuleServiceImplIsInvalid() throws MessageRouterException
  {
    //add new messages
    Message message = MessageFactory.getInstance().getMessage( MessageType.JBOSS_XML );
    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleServiceImpl( "bad.Class" ).ruleFile( "JBossESBRules.drl").build();
    jbrRouter.setConfigTree( configTree );

    jbrRouter.route( null, "XPathLanguage.dsl", false, message, null);
  }
View Full Code Here

  //  as that class also used JBossRulesRouter as you can see below
  @Test
  public void discount() throws ObjectMappingException
  {
        //new messages
    Message message = createMessage( MessageType.JAVA_SERIALIZED );
    Order order = new Order();
        order.setQuantity(20);
        order.setUnitPrice(new BigDecimal("20.0"));
    message.getBody().add("Order", order);
        //extract the order from the message, so the drl can process it
        List<String> messagePathList = new ArrayList<String>();
        messagePathList.add("body.Order");
        ObjectMapper mapper = new ObjectMapper();
        List<Object> objectList = mapper.createObjectList(message, messagePathList);
        //Now send to the rules engine
    JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBPricingRoutingRules.drl").build();
    jbossRulesRouter.setConfigTree( configTree );
        try {
        List<String> destinations = jbossRulesRouter.route("JBossESBPricingRoutingRules.drl", false, message, objectList);
            assertEquals(order.getDiscount(),10.0, 0);
            assertEquals("10%",message.getBody().get("DiscountObject"));
            String shippingDestination = destinations.iterator().next();
            System.out.println(shippingDestination);
            assertEquals("express-shipping-destination", shippingDestination);

        } catch (MessageRouterException mre) {
View Full Code Here

  //  as that class also used JBossRulesRouter as you can see befinal low
    @Test
    public void nodiscount() throws ObjectMappingException
    {
        //new messages
        Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
        Order order = new Order();
        order.setQuantity(2);
        order.setUnitPrice(new BigDecimal("20.0"));
        message.getBody().add("Order", order);
//      extract the order from the message, so the drl can process it
        List<String> messagePathList = new ArrayList<String>();
        messagePathList.add("body.Order");
        ObjectMapper mapper = new ObjectMapper();
        List<Object> objectList = mapper.createObjectList(message, messagePathList);
        //Now send to the rules engine
        JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
    ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBPricingRoutingRules.drl").build();
    jbossRulesRouter.setConfigTree( configTree );
        try {
            List<String> destinations = jbossRulesRouter.route("JBossESBPricingRoutingRules.drl", false, message, objectList);
            assertEquals(order.getDiscount(),0.0, 0);
            assertEquals("0%",message.getBody().get("DiscountObject"));
            String shippingDestination = destinations.iterator().next();
            System.out.println(shippingDestination);
            assertEquals("normal-shipping-destination", shippingDestination);

        } catch (MessageRouterException mre) {
View Full Code Here

  }

  private Message createMessage( final URI type )
  {
    //new messages
    Message message = MessageFactory.getInstance().getMessage( type );
    //set some properties inside the Message
    message.getProperties().setProperty("prop1", "val1");
    message.getProperties().setProperty("prop2", "val2");
    //set the body inside the Message
    message.getBody().add(("TEST BODY").getBytes());
    //set some object attachments inside the Message
    message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
    message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
    return message;
  }
View Full Code Here

  }

  @Test
  public void executeStatelessRulesDrlWithDsl() throws RuleServiceException, ConfigurationException, UnsupportedEncodingException
  {
    Message msg = MessageFactory.getInstance().getMessage();
    InputStream resourceAsStream = ClassUtil.getResourceAsStream( "/" + "5KB_message.xml", getClass() );
    String contents = StreamUtils.readStreamString( resourceAsStream, "UTF-8" );
    msg.getBody().add( contents );
    Map<String,Object> globals = getGlobalsWithDest();
    boolean ruleReload = true;

    // first run
    long startTime = System.nanoTime();
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.message.Message

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.