Coverage Report - org.mule.tck.model.AbstractContainerContextTestCase
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractContainerContextTestCase
42%
13/31
50%
2/4
1.75
 
 1  
 /*
 2  
  * $Id: AbstractContainerContextTestCase.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  10
 public abstract class AbstractContainerContextTestCase extends AbstractMuleTestCase
 22  
 {
 23  
     public void testContainerContext() throws Exception
 24  
     {
 25  4
         UMOContainerContext container = getContainerContext();
 26  4
         container.initialise();
 27  4
         assertNotNull(container);
 28  
 
 29  4
         Object result = null;
 30  
 
 31  
         try
 32  
         {
 33  4
             result = container.getComponent(null);
 34  0
             fail("Should throw ObjectNotFoundException for null key");
 35  
         }
 36  4
         catch (ObjectNotFoundException e)
 37  
         {
 38  
             // expected
 39  0
         }
 40  
 
 41  
         try
 42  
         {
 43  4
             result = container.getComponent("abcdefg123456!�$%^n");
 44  0
             fail("Should throw ObjectNotFoundException for a key that doesn't exist");
 45  
         }
 46  4
         catch (ObjectNotFoundException e)
 47  
         {
 48  
             // expected
 49  0
         }
 50  
 
 51  
         try
 52  
         {
 53  6
             result = container.getComponent(Apple.class);
 54  4
             assertNotNull("Component should exist in container", result);
 55  
         }
 56  0
         catch (ObjectNotFoundException e)
 57  
         {
 58  0
             fail("Component should exist in the container");
 59  4
         }
 60  4
     }
 61  
 
 62  
     /**
 63  
      * Usage 2: the implementation reference on the descriptor is to a component in
 64  
      * the container
 65  
      * 
 66  
      * @throws Exception
 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  
 }