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