Package org.mule.api

Examples of org.mule.api.MuleMessage


  private void test_pathRedirection(String path, String targetPath) throws JsonParseException, JsonMappingException, IOException, DefaultChannelInvalidConfigException {
    DefaultChannelComponent dcc = new DefaultChannelComponent();
    dcc.readMappings();

    URLMapping mapping = dcc.findURLMapping(Scheme.HTTPS, path);
    MuleMessage mockMsg = mock(MuleMessage.class);
    RestfulHttpRequest req = new RestfulHttpRequest();
    req.setPath(path);
   
    dcc.setMessagePropertiesFromMapping(req, mockMsg, mapping);
    verify(mockMsg).setProperty(eq("http.host"), eq("localhost"), eq(PropertyScope.OUTBOUND));
View Full Code Here


  public void test_pathRedirection_invalid() throws DefaultChannelInvalidConfigException, JsonParseException, JsonMappingException, IOException {
    //cannot specify both path and pathTransform
   
    try {
      DefaultChannelComponent dcc = new DefaultChannelComponent();
      MuleMessage mockMsg = mock(MuleMessage.class);
      URLMapping mapping = mock(URLMapping.class);

      when(mapping.getPath()).thenReturn("path");
      when(mapping.getPathTransform()).thenReturn("pathTransform");
      dcc.setMessagePropertiesFromMapping(new RestfulHttpRequest(), mockMsg, mapping);
View Full Code Here

  }

  @Test
  public void testPOST() throws Exception {
   
    MuleMessage msg = executeTestCase("TEST BODY", "", sampleHttpHeaders, "POST", "test/path");
    assertNotNull(msg);
   
    verify(msg).setPayload("TEST BODY");
   
    verify(msg).setProperty("http.method", "POST", PropertyScope.OUTBOUND);
View Full Code Here

  }
 
  @Test
  public void testGET() throws Exception {
   
    MuleMessage msg = executeTestCase(null, "", sampleHttpHeaders, "GET", "test/path");
    assertNotNull(msg);
   
    verify(msg).setProperty("http.method", "GET", PropertyScope.OUTBOUND);
    verify(msg).setProperty("http.path", "test/path", PropertyScope.OUTBOUND);
    verify(msg).setProperty("TEST1", "VAL1", PropertyScope.OUTBOUND);
View Full Code Here

  }
 
  private MuleMessage executeTestCase(String body, String uuid, Map<String, Object> httpHeaders, String httpMethod, String path) throws Exception {
    setupMocks(body, uuid, httpHeaders, httpMethod, path);
    RestfulHttpRequestToHttpRequestTransformer trans = new RestfulHttpRequestToHttpRequestTransformer();
    MuleMessage msg = (MuleMessage) trans.transformMessage(this.msg, "UTF-8");
    return msg;
  }
View Full Code Here

    if (mappings.size() < 1) {
      readMappings();
    }

    MuleMessage msg = eventContext.getMessage();
    RestfulHttpRequest req = (RestfulHttpRequest) msg.getPayload();
    String actualPath = req.getPath();

    URLMapping mapping = findURLMapping(req.getScheme(), actualPath);
   
    if (mapping == null) {
View Full Code Here

  public static MuleMessage buildMockMuleResponse(boolean successful) {
    return buildMockMuleResponse(successful, null);
  }
 
  public static MuleMessage buildMockMuleResponse(boolean successful, Object payload) {
    MuleMessage mockResponse = mock(MuleMessage.class);
   
    when(mockResponse.getInboundProperty(eq("success"))).thenReturn(successful ? "true" : "false");
    try {
      if (payload!=null) {
        if (payload instanceof String)
          when(mockResponse.getPayloadAsString()).thenReturn((String)payload);
        when(mockResponse.getPayload()).thenReturn(payload);
      }
    } catch (Exception e) { /* Quiet! */ }
   
    return mockResponse;
  }
View Full Code Here

    public Object call(Object[] params, ExpressionLanguageContext context)
    {
        if (params != null && params.length > 0 && params[0] instanceof String)
        {

            MuleMessage message = getMuleMessageFrom(context);
            String flowName = (String) params[0];
            Object registeredScript = message.getMuleContext().getRegistry().lookupObject(flowName);

            Preconditions.checkNotNull(registeredScript, "The script called " + flowName + " could not be found");
            if (registeredScript instanceof Scriptable)
            {
                Scriptable script = (Scriptable) registeredScript;
View Full Code Here

    @Override
    public Object call(Object[] params, ExpressionLanguageContext context)
    {
        if (params != null && params.length > 0 && params[0] instanceof String)
        {
            MuleMessage messageFrom = getMuleMessageFrom(context);

            if (messageFrom == null)
            {
                throw new RuntimeException("Could not get message;");
            }
View Full Code Here

    @Override
    public Object call(Object[] params, ExpressionLanguageContext context)
    {
        if (params != null && params.length > 0 && params[0] instanceof String)
        {
            MuleMessage muleMessage = getMuleMessageFrom(context);

            if (muleMessage == null)
            {
                return false;
            }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleMessage

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.