View Javadoc
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.module.bpm.config;
8   
9   import org.mule.module.bpm.BPMS;
10  import org.mule.module.bpm.ProcessComponent;
11  import org.mule.module.bpm.test.TestBpms;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertNull;
19  
20  
21  /**
22   * Tests the Spring XML namespace for the BPM transport.
23   */
24  public class BpmNamespaceHandlerTestCase extends FunctionalTestCase
25  {
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "bpm-namespace-config.xml";
31      }
32  
33      @Test
34      public void testDefaultsComponent() throws Exception
35      {
36          ProcessComponent c = (ProcessComponent) muleContext.getRegistry().lookupService("Service1").getComponent();
37          assertNotNull(c);
38          
39          assertEquals("test.def", c.getResource());
40          assertNull(c.getProcessIdField());
41          
42          // BPMS gets set explicitly in config
43          BPMS bpms = c.getBpms();
44          assertNotNull(bpms);
45          assertEquals(TestBpms.class, bpms.getClass());
46          assertEquals("bar", ((TestBpms) bpms).getFoo());
47      }
48      
49      @Test
50      public void testConfigComponent() throws Exception
51      {
52          ProcessComponent c = (ProcessComponent) muleContext.getRegistry().lookupService("Service2").getComponent();
53          assertNotNull(c);
54          
55          assertEquals("test.def", c.getResource());
56          assertEquals("myId", c.getProcessIdField());
57          
58          // BPMS gets set implicitly via MuleRegistry.lookupObject(BPMS.class)
59          BPMS bpms = c.getBpms();
60          assertNotNull(bpms);
61          assertEquals(TestBpms.class, bpms.getClass());
62          assertEquals("bar", ((TestBpms) bpms).getFoo());
63      }
64      
65  }