1 /* 2 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 3 * The software in this package is published under the terms of the CPAL v1.0 4 * license, a copy of which has been included with this distribution in the 5 * LICENSE.txt file. 6 */ 7 package org.mule.test.cookbook.quartz; 8 9 import org.mule.tck.junit4.FunctionalTestCase; 10 import org.mule.module.client.MuleClient; 11 import org.mule.api.MuleMessage; 12 13 import org.junit.Test; 14 15 import static org.junit.Assert.assertEquals; 16 import static org.junit.Assert.assertNotNull; 17 18 /** 19 * The Quartz transport can be used to trigger an event to be received by the component based on the endpoint 20 * configuration. In Mule an event is usually expected, however in this example we have a service component who's 21 * service method doesn't take any parameters. The {@link org.mule.transport.quartz.jobs.EventGeneratorJob} can be used to trigger a service method, 22 * and by not specifying a 'payload' element there is no data to try and match to the service method, so Mule will 23 * match a method with no arguments. 24 */ 25 public class TriggerNoArgsServiceMethodTestCase extends FunctionalTestCase 26 { 27 28 @Override 29 protected String getConfigResources() 30 { 31 return "org/mule/test/cookbook/quartz/trigger-no-args-method-config.xml"; 32 } 33 34 @Test 35 public void testTrigger() throws Exception 36 { 37 MuleClient client = new MuleClient(muleContext); 38 39 //Our method should have fired and we can pick up the result 40 MuleMessage result = client.request("resultQueue", 2000); 41 42 //Always check method is not null. It wuld be rude not to! 43 assertNotNull(result); 44 45 //Check we have a hit 46 assertEquals("Bullseye!", result.getPayloadAsString()); 47 } 48 }