View Javadoc

1   /*
2    * $Id: BpmNamespaceHandlerTestCase.java 19710 2010-09-23 16:29:07Z tcarlson $
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  package org.mule.module.bpm.config;
11  
12  import org.mule.module.bpm.BPMS;
13  import org.mule.module.bpm.ProcessComponent;
14  import org.mule.module.bpm.test.TestBpms;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.bpm.ProcessConnector;
17  
18  
19  /**
20   * Tests the Spring XML namespace for the BPM transport.
21   */
22  public class BpmNamespaceHandlerTestCase extends FunctionalTestCase
23  {
24      protected String getConfigResources()
25      {
26          return "bpm-namespace-config.xml";
27      }
28  
29      /**
30       * @deprecated It is recommended to configure BPM as a component rather than a transport for 3.x
31       */
32      public void testDefaultsConnector() throws Exception
33      {
34          ProcessConnector c = (ProcessConnector)muleContext.getRegistry().lookupConnector("bpmConnectorDefaults");
35          assertNotNull(c);
36          
37          assertFalse(c.isAllowGlobalReceiver());
38          assertNull(c.getProcessIdField());
39          
40          BPMS bpms = c.getBpms();
41          assertNotNull(bpms);
42          assertEquals(TestBpms.class, bpms.getClass());
43          assertEquals("bar", ((TestBpms) bpms).getFoo());
44          
45          assertTrue(c.isConnected());
46          assertTrue(c.isStarted());
47      }
48      
49      public void testDefaultsComponent() throws Exception
50      {
51          ProcessComponent c = (ProcessComponent) muleContext.getRegistry().lookupService("Service1").getComponent();
52          assertNotNull(c);
53          
54          assertEquals("test.def", c.getResource());
55          assertNull(c.getProcessIdField());
56          
57          // BPMS gets set explicitly in config
58          BPMS bpms = c.getBpms();
59          assertNotNull(bpms);
60          assertEquals(TestBpms.class, bpms.getClass());
61          assertEquals("bar", ((TestBpms) bpms).getFoo());
62      }
63      
64      /**
65       * @deprecated It is recommended to configure BPM as a component rather than a transport for 3.x
66       */
67      public void testConfigConnector() throws Exception
68      {
69          ProcessConnector c = (ProcessConnector)muleContext.getRegistry().lookupConnector("bpmConnector1");
70          assertNotNull(c);
71          
72          assertTrue(c.isAllowGlobalReceiver());
73          assertEquals("myId", c.getProcessIdField());
74          
75          BPMS bpms = c.getBpms();
76          assertNotNull(bpms);
77          assertEquals(TestBpms.class, bpms.getClass());
78          assertEquals("bar", ((TestBpms) bpms).getFoo());
79  
80          assertTrue(c.isConnected());
81          assertTrue(c.isStarted());
82      }    
83  
84      public void testConfigComponent() throws Exception
85      {
86          ProcessComponent c = (ProcessComponent) muleContext.getRegistry().lookupService("Service2").getComponent();
87          assertNotNull(c);
88          
89          assertEquals("test.def", c.getResource());
90          assertEquals("myId", c.getProcessIdField());
91          
92          // BPMS gets set implicitly via MuleRegistry.lookupObject(BPMS.class)
93          BPMS bpms = c.getBpms();
94          assertNotNull(bpms);
95          assertEquals(TestBpms.class, bpms.getClass());
96          assertEquals("bar", ((TestBpms) bpms).getFoo());
97      }
98      
99  }