1 /* 2 * $Id: AbstractJmsRequestFromScriptTestCase.java 19692 2010-09-21 23:50:35Z aperepel $ 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.FunctionalTestCase; 16 17 /** 18 * Defines a scenario when we request a jms message from inside a groovy script 19 * which is executed as part of a service whose endpoints are jms ones. 20 * Subclasses must provide the service configuration through the implementation 21 * of {@link org.mule.tck.FunctionalTestCase#getConfigResources()}. 22 */ 23 public abstract class AbstractJmsRequestFromScriptTestCase extends FunctionalTestCase 24 { 25 26 /** 27 * Requests jms message from inside a groovy script which run as part of a 28 * service defined using jms endpoints. The first part of the test loads 29 * a couple of jms message in a queue so the script will have data to 30 * process. 31 */ 32 public void testRequestingMessageFromScript() throws Exception 33 { 34 MuleClient muleClient = new MuleClient(muleContext); 35 36 // Sends data to process 37 muleClient.send("vm://in", TEST_MESSAGE, null); 38 muleClient.send("vm://in", TEST_MESSAGE, null); 39 40 // Sends the signal to start the batch process 41 muleClient.send("vm://startBatch", TEST_MESSAGE, null); 42 43 // Checks that the batch has processed the two messages without error 44 MuleMessage message = muleClient.request("jms://status.queue?connector=jmsConnector", 5000); 45 assertNotNull(message); 46 assertEquals("messagemessage", message.getPayloadAsString()); 47 } 48 }