Package org.jboss.soa.esb.message

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


  }

  @Test
  public void processDiscountStateful() throws ObjectMappingException, ConfigurationException, RegistryException, MessageRouterException, ActionProcessingException
  {
    Message message = createMessageWithOrder( order );
        ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBPricingRulesStateful.drl" ).stateful( true ).messagePaths(messagePathList).build();
    BusinessRulesProcessor processor = new BusinessRulesProcessor( configTree );

    // process message
    processor.process( message );
        assertEquals( 20.0, order.getDiscount(), 0);
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));

        //  now dispose after this call
        message.getProperties().setProperty( DISPOSE.getName(), Boolean.TRUE );
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
    processor.process( message );

    //  counter is inserted into the working memory by the first rules execution
    //  from the above process call.
        Counter counter = (Counter) message.getBody().get("Counter");
        assertEquals( 2 , counter.getCounter() );
  }
View Full Code Here


        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", message.getBody().get());
    }

    public void test_InputStream2String() throws MessageDeliverException, RegistryException, FaultMessageException {
        ServiceInvoker invoker = new ServiceInvoker("Transform", "String");
        Message message = MessageFactory.getInstance().getMessage();

        message.getBody().add(new ByteArrayInputStream(personXmlBytes));
        message = invoker.deliverSync(message, 30000);

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", message.getBody().get());
    }
View Full Code Here

  }

    @Test
    public void processStatefulDispose() throws Exception
    {
        Message message = createMessageWithOrder( order );
        ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBStatefulDispose.drl" ).stateful( true ).messagePaths(messagePathList).build();
        BusinessRulesProcessor processor = new BusinessRulesProcessor( configTree );

        // process message
        processor.process( message );
        assertEquals( 20.0, order.getDiscount(), 0);
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));
        Counter counter = (Counter) message.getBody().get("Counter");
        assertEquals( 1 , counter.getCounter() );

        //  do not dispose after this call
        message.getBody().remove("Order");
        message.getProperties().setProperty( DISPOSE.getName(), Boolean.FALSE );
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
        message.getBody().add("Counter", new Counter(counter.getCounter()));
        processor.process( message );

        counter = (Counter) message.getBody().get("Counter");
        assertEquals( 2 , counter.getCounter() );
       
        //  now dispose after this call
        message.getProperties().setProperty( DISPOSE.getName(), Boolean.TRUE );
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
        message.getBody().add("Counter", new Counter(counter.getCounter()));
        processor.process( message );

        // If this assert fails then the second invocation disposed of the state when it shouldn't have
        // and this one did not fire any rules.
        counter = (Counter) message.getBody().get("Counter");
        assertEquals( 3 , counter.getCounter() );
       
        final Order order = new Order();
        order.setQuantity(20);
        order.setUnitPrice( new BigDecimal("20.0") );
        message = createMessageWithOrder( order );
       
        message.getProperties().setProperty( DISPOSE.getName(), Boolean.TRUE );
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
        processor.process( message );

        assertEquals( 20.0, order.getDiscount(), 0);
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));
        counter = (Counter) message.getBody().get("Counter");
        assertEquals( 1 , counter.getCounter() );
    }
View Full Code Here

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", message.getBody().get());
    }

    public void test_Reader2String() throws MessageDeliverException, RegistryException, FaultMessageException {
        ServiceInvoker invoker = new ServiceInvoker("Transform", "String");
        Message message = MessageFactory.getInstance().getMessage();

        message.getBody().add(new StringReader(new String(personXmlBytes)));
        message = invoker.deliverSync(message, 30000);

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", message.getBody().get());
    }
View Full Code Here

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", message.getBody().get());
    }

    public void test_String2Bytes() throws MessageDeliverException, RegistryException, FaultMessageException {
        ServiceInvoker invoker = new ServiceInvoker("Transform", "Bytes");
        Message message = MessageFactory.getInstance().getMessage();

        message.getBody().add(new String(personXmlBytes));
        message = invoker.deliverSync(message, 30000);

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", new String((byte[]) message.getBody().get()));
    }
View Full Code Here

    }

    @Test
    public void processStatefulContinuation() throws Exception
    {
        Message message = createMessageWithOrder( order );
        ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBStatefulDispose.drl" ).stateful( true ).messagePaths(messagePathList).build();
        BusinessRulesProcessor processor = new BusinessRulesProcessor( configTree );

        // process message
        processor.process( message );
        assertEquals( 20.0, order.getDiscount(), 0);
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));
        Counter counter = (Counter) message.getBody().get("Counter");
        assertEquals( 1 , counter.getCounter() );

        //  do not dispose after this call
        message.getBody().remove("Order");
        message.getProperties().setProperty( DISPOSE.getName(), Boolean.FALSE );
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
        message.getBody().add("Counter", new Counter(counter.getCounter()));
        processor.process( message );

        counter = (Counter) message.getBody().get("Counter");
        assertEquals( 2 , counter.getCounter() );
       
        //  Do not specify continue, it should dispose current session before this call
        final Order order = new Order();
        order.setQuantity(20);
        order.setUnitPrice( new BigDecimal("20.0") );
        message = createMessageWithOrder( order );
       
        processor.process( message );

        assertEquals( 20.0, order.getDiscount(), 0);
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));
        counter = (Counter) message.getBody().get("Counter");
        assertEquals( 1 , counter.getCounter() );
    }
View Full Code Here

        assertEquals("<someone called=\"Tom Fennelly\" is=\"21\">", new String((byte[]) message.getBody().get()));
    }

    public void test_Object2String() throws MessageDeliverException, RegistryException, FaultMessageException {
        ServiceInvoker invoker = new ServiceInvoker("Transform", "Person");
        Message message = MessageFactory.getInstance().getMessage();

        message.getBody().add(new Person1("Tom", 300));
        message = invoker.deliverSync(message, 30000);

        assertEquals("<someone called=\"Tom\" is=\"300\">", message.getBody().get());
    }
View Full Code Here

        assertEquals("<someone called=\"Tom\" is=\"300\">", message.getBody().get());
    }

    public void test_Object2Object() throws MessageDeliverException, RegistryException, FaultMessageException {
        ServiceInvoker invoker = new ServiceInvoker("Transform", "Person2Person");
        Message message = MessageFactory.getInstance().getMessage();

        message.getBody().add(new Person1("Tom", 300));
        message = invoker.deliverSync(message, 30000);

        Person2 person2 = (Person2) message.getBody().get();
        assertEquals("Tom", person2.getName());
        assertEquals(300, person2.getAge());
    }
View Full Code Here

    }

  @Test ( expected = ActionProcessingException.class )
  public void shouldThrowIfDisposePropertyIsNotSet() throws ObjectMappingException, ConfigurationException, RegistryException, MessageRouterException, ActionProcessingException
  {
    Message message = createMessageWithOrder( order );
        ConfigTree configTree = new CBRConfigTreeBuilder( true ).ruleFile( "JBossESBPricingRulesStateful.drl" ).messagePaths(messagePathList).stateful( true ).build();
    BusinessRulesProcessor processor = new BusinessRulesProcessor( configTree );

    // process message
    processor.process( message );
        assertEquals( 20.0, order.getDiscount(), 0 );
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));

        //  We don't set 'dispose' which should cause an exception to be thrown...
        message.getProperties().setProperty( CONTINUE.getName(), Boolean.TRUE );
    processor.process( message );
  }
View Full Code Here

    {
    Order order = new Order();
        order.setQuantity(20);
        order.setUnitPrice( new BigDecimal("20.0") );

        Message message = MessageFactory.getInstance().getMessage();
        message.getBody().add("Order", order);

        final ArrayList<String> defaultFacts = new ArrayList<String>();
        defaultFacts.add("body.Counter");

        final ArrayList<String> orderEntryPoints = new ArrayList<String>();
        orderEntryPoints.add("body.Order");

        Map<String, List<String>> entryPointFacts = new HashMap<String, List<String>>();
        entryPointFacts.put("OrderEntryPoint", orderEntryPoints);
        CBRConfigTreeBuilder builder = new CBRConfigTreeBuilder(true).ruleFile("PricingRulesStatefulEntryPoint.drl");
        builder.messagePaths(defaultFacts).entryPoints(entryPointFacts);
        ConfigTree config = builder.stateful(true).build();
        BusinessRulesProcessor processor = new BusinessRulesProcessor(config);

        processor.process( message );

        assertEquals( 20.0, order.getDiscount(), 0 );
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));
    }
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.