1
2
3
4
5
6
7
8
9
10
11 package org.mule.extras.spring;
12
13 import org.mule.tck.model.AbstractContainerContextTestCase;
14 import org.mule.tck.testmodels.fruit.FruitBowl;
15 import org.mule.umo.manager.ObjectNotFoundException;
16 import org.mule.umo.manager.UMOContainerContext;
17
18
19
20
21 public class SpringContainerContextTestCase extends AbstractContainerContextTestCase
22 {
23 SpringContainerContext context;
24
25 public UMOContainerContext getContainerContext()
26 {
27 return context;
28 }
29
30 protected void doSetUp() throws Exception
31 {
32 context = new SpringContainerContext();
33 context.setConfigResources(getConfigResources());
34 }
35
36 public String getConfigResources()
37 {
38 return "test-application-context.xml";
39 }
40
41 public void testContainerContext() throws Exception
42 {
43 UMOContainerContext container = getContainerContext();
44 container.initialise();
45 assertNotNull(container);
46
47 try
48 {
49 container.getComponent(null);
50 fail("Should throw ObjectNotFoundException for null key");
51 }
52 catch (ObjectNotFoundException e)
53 {
54
55 }
56
57 try
58 {
59 container.getComponent("abcdefg123456!�$%^n");
60 fail("Should throw ObjectNotFoundException for a key that doesn't exist");
61 }
62 catch (ObjectNotFoundException e)
63 {
64
65 }
66
67 try
68 {
69 Object result = container.getComponent("apple");
70 assertNotNull("Component should exist in container", result);
71 }
72 catch (ObjectNotFoundException e)
73 {
74 fail("Component should exist in the container");
75 }
76 }
77
78 protected String getFruitBowlComponentName()
79 {
80 return "fruitBowl";
81 }
82 }