1 /* 2 * $Id: AbstractJmsRequestFromScriptTestCase.java 22620 2011-08-09 10:02:17Z dirk.olmes $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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.test.integration.transport.jms.scripting; 12 13 import org.mule.api.MuleMessage; 14 import org.mule.module.client.MuleClient; 15 import org.mule.tck.junit4.FunctionalTestCase; 16 17 import org.junit.Test; 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertNotNull; 21 22 /** 23 * Defines a scenario when we request a jms message from inside a groovy script 24 * which is executed as part of a service whose endpoints are jms ones. 25 * Subclasses must provide the service configuration through the implementation 26 * of {@link org.mule.tck.junit4.FunctionalTestCase#getConfigResources()}. 27 */ 28 public abstract class AbstractJmsRequestFromScriptTestCase extends FunctionalTestCase 29 { 30 31 /** 32 * Requests jms message from inside a groovy script which run as part of a 33 * service defined using jms endpoints. The first part of the test loads 34 * a couple of jms message in a queue so the script will have data to 35 * process. 36 */ 37 @Test 38 public void testRequestingMessageFromScript() throws Exception 39 { 40 MuleClient muleClient = new MuleClient(muleContext); 41 42 // Sends data to process 43 muleClient.send("vm://in", TEST_MESSAGE, null); 44 muleClient.send("vm://in", TEST_MESSAGE, null); 45 46 // Sends the signal to start the batch process 47 muleClient.send("vm://startBatch", TEST_MESSAGE, null); 48 49 // Checks that the batch has processed the two messages without error 50 MuleMessage message = muleClient.request("jms://status.queue?connector=jmsConnector", 5000); 51 assertNotNull(message); 52 assertEquals("messagemessage", message.getPayloadAsString()); 53 } 54 }