View Javadoc

1   /*
2    * $Id: QuartzPersistentCustomJobFromMessageTestCase.java 22498 2011-07-21 13:01:39Z justin.calleja $
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.transport.quartz;
12  
13  import static org.junit.Assert.assertNotNull;
14  import static org.junit.Assert.assertTrue;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.Test;
20  import org.junit.runners.Parameterized.Parameters;
21  import org.mule.api.MuleMessage;
22  import org.mule.module.client.MuleClient;
23  import org.mule.tck.AbstractServiceAndFlowTestCase;
24  import org.mule.transport.quartz.jobs.ScheduledDispatchJobConfig;
25  
26  public class QuartzPersistentCustomJobFromMessageTestCase extends AbstractServiceAndFlowTestCase
27  {
28  
29      private static final long TIMEOUT = 30000;
30  
31      public QuartzPersistentCustomJobFromMessageTestCase(ConfigVariant variant, String configResources)
32      {
33          super(variant, configResources);
34      }
35  
36      @Parameters
37      public static Collection<Object[]> parameters()
38      {
39          return Arrays.asList(new Object[][]{
40              {ConfigVariant.SERVICE, "quartz-persistent-custom-job-generator-service.xml"},
41              {ConfigVariant.FLOW, "quartz-persistent-custom-job-generator-flow.xml"}});
42      }
43  
44      @Test
45      public void testSendToCustomEventScheduler() throws Exception
46      {
47          MuleClient client = new MuleClient(muleContext);
48  
49          ScheduledDispatchJobConfig jobConfig = new ScheduledDispatchJobConfig();
50          jobConfig.setMuleContext(muleContext);
51          jobConfig.setEndpointRef("vm://resultQueue");
52          client.dispatch("vm://customJobQueue", jobConfig, null);
53  
54          MuleMessage result = client.request("vm://resultQueue", TIMEOUT);
55          assertNotNull(result);
56          assertTrue(result.getPayload() instanceof ScheduledDispatchJobConfig);
57      }
58  }