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