Package org.jboss.soa.esb.message

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


  }

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

    RuleInfo ruleInfo = new RuleInfoBuilder("RulesWithDslNS.drl").dslSource("XPathLanguage.dsl").reload(ruleReload).globals(globals).build();
    message = ruleService.executeStatelessRules( ruleInfo, msg );
View Full Code Here


  }

  @Test
  public void executeStatefulRulesContinueSession() throws RuleServiceException, ObjectMappingException
  {
    Message message = createMessageWithOrder( order );
    Map<String,Object> globals = getGlobalsWithMessage( message );
      ArrayList<String> messagePathList = new ArrayList<String>();
        messagePathList.add("body.Order");
        messagePathList.add("body.Counter");

        // process message
        List<Object> objectList = new ObjectMapper().createObjectList(message, messagePathList);
    RuleInfo ruleInfo = new RuleInfoBuilder("JBossESBPricingRulesStateful.drl").reload(true).globals(globals).defaultFacts(objectList).build();
    StatefulRuleInfoImpl statefulRuleInfo = new StatefulRuleInfoImpl(ruleInfo, false, true);
    message = ruleService.executeStatefulRules( statefulRuleInfo, message );
        assertEquals( 20.0, order.getDiscount(), 0 );
        assertEquals( "20%" ,message.getBody().get("DiscountObject"));

        //  process message again with a counter instance
        objectList = new ObjectMapper().createObjectList(message, messagePathList);
    ruleInfo = new RuleInfoBuilder("JBossESBPricingRulesStateful.drl").reload(true).globals(globals).defaultFacts(objectList).build();
    statefulRuleInfo = new StatefulRuleInfoImpl(ruleInfo, false, true);
    message = ruleService.continueStatefulRulesExecution( statefulRuleInfo, message );

        Counter counter = (Counter) message.getBody().get("Counter");
        assertEquals( 2 , counter.getCounter() );
  }
View Full Code Here

  }

  @Test
    public void continueSessionWithEntryPoint() throws RuleServiceException, ObjectMappingException, InterruptedException
    {
        Message message = createMessageWithOrder(order);
        long timestamp = System.currentTimeMillis();
        message.getProperties().setProperty(Environment.MESSAGE_ENTRY_TIME, timestamp);

        final RuleInfoBuilder builder = new RuleInfoBuilder("PricingRulesStatefulEntryPoint.drl");
    builder.global("message", message);
    final ObjectMapper objectMapper = new ObjectMapper();
    builder.defaultFact(objectMapper.getObjectFromMessage(message, "body.Counter"));
    builder.defaultFact(message);

    // OrderEntryPoint that matches the entry-point name in PricingRulesStatfulEntryPoint.drl.
    builder.fact("OrderEntryPoint", objectMapper.getObjectFromMessage(message, "body.Order"));
        // process message
    StatefulRuleInfo statefulInfo = new StatefulRuleInfoImpl(builder.build(), false, true);
        message = ruleService.executeStatefulRules(statefulInfo, message);

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

    }
View Full Code Here

    }

  @Test (expected = RuleServiceException.class)
    public void shouldThrowIfEntryPointDoesNotExistInSession() throws RuleServiceException, ObjectMappingException
    {
        Message message = createMessageWithOrder( order );
        long timestamp = System.currentTimeMillis();
        message.getProperties().setProperty(Environment.MESSAGE_ENTRY_TIME, timestamp);

        final ArrayList<String> messagePathList = new ArrayList<String>();
        messagePathList.add("body.Order");
        messagePathList.add("body.Counter");
View Full Code Here

    return globals;
  }

  private Message createMessageWithOrder( final Order order )
  {
    Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
    message.getBody().add("Order", order);
    return message;
  }
View Full Code Here

        processInstance.getContextInstance().setVariable("h3", objectTokenScope, token);
        processInstance.getContextInstance().setVariable("i4", objectGlobalScope);
        ExecutionContext executionContext = new ExecutionContext(token);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);

        assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
        assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
        assertEquals(objectTokenScope.getInternal(), String.valueOf(message.getBody().get("esbObj3")));
        assertEquals(objectGlobalScope.getInternal(), String.valueOf(message.getBody().get("esbObj4")));
  }
View Full Code Here

        processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
        processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
        ExecutionContext executionContext = new ExecutionContext(token);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, Boolean.FALSE, executionContext);
        assertEquals(message.getBody().getNames().length,0);
    }
View Full Code Here

        processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
        processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
        ExecutionContext executionContext = new ExecutionContext(token);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
        //We should find 2 variables which are named just like their jBPM counterparts.
        assertEquals(message.getBody().getNames().length,4);
        assertEquals(String.valueOf(message.getBody().get("v1")),helloWorldTokenScope);
        assertEquals(String.valueOf(message.getBody().get("g2")),helloWorldGlobalScope);
        assertEquals(message.getBody().get("h3"), objectTokenScope);
        assertEquals(message.getBody().get("i4"), objectGlobalScope);
    }
View Full Code Here

        ExecutionContext executionContext = new ExecutionContext(token);
        Node node = executionContext.getNode();
        Transition transition = (Transition) node.getLeavingTransitions().get(0);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);

        assertEquals(message.getBody().getNames().length,6);
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
        //The token name is null.
        assertNull(message.getBody().get("TokenName"));
        //Get info about the node.
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("NodeName"))), String.valueOf(node.getName()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("esbNodeId"))), String.valueOf(node.getId()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("transName"))), String.valueOf(transition.getName()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piId"))), String.valueOf(processInstance.getId()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
        logger.info("Message=" + message);
    }
View Full Code Here

    }

    public void test_XStream_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
        ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-01");
        SOAPClient soapClient = new SOAPClient(actionConfig);
        Message message = MessageFactory.getInstance().getMessage();

        soapClient.processResponse(message, response_01);
        assertEquals(true, message.getBody().get());

        soapClient.processResponse(message, response_02);
        assertEquals(false, message.getBody().get());
    }
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.