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