1   /*
2    * $Id: EndpointTransformerMule2131TestCase.java 9698 2007-11-13 13:40:41Z aperepel $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.vm.issues;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.umo.UMOMessage;
16  
17  public class EndpointTransformerMule2131TestCase extends FunctionalTestCase
18  {
19  
20      public static final long TIMEOUT = 5000L;
21      public static final String MESSAGE = "a message";
22  
23      protected String getConfigResources()
24      {
25          return "endpoint-transformer-mule-2131-test.xml";
26      }
27  
28      public void testAllCases() throws Exception
29      {
30          MuleClient client = new MuleClient();
31          client.dispatch("in", MESSAGE, null);
32          for (int i = 0; i < 3; i++)
33          {
34              receive(client, "vm://outT?connector=queue", MESSAGE + StringAppendTransformer.DEFAULT_TEXT);
35          }
36          receive(client, "vm://outD?connector=queue", MESSAGE);
37  
38          client.dispose();
39  
40      }
41  
42      // not possible before 2.0?
43  //    public void testLocalNameLocalTransformer() throws Exception
44  //    {
45  //        doTestTransformed("local-name-local-transformer");
46  //    }
47  
48  
49      protected String receive(MuleClient client, String endpoint, String src) throws Exception
50      {
51          UMOMessage message = client.receive(endpoint, TIMEOUT);
52          assertNotNull(message);
53          assertNotNull(message.getPayloadAsString());
54          logger.debug("Receive " + message.getPayloadAsString());
55          assertEquals(src, message.getPayloadAsString());
56          return message.getPayloadAsString();
57      }
58  
59  }