Coverage Report - org.mule.tck.testmodels.services.TestServiceComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
TestServiceComponent
0%
0/26
0%
0/3
1.75
 
 1  
 /*
 2  
  * $Id: TestServiceComponent.java 7976 2007-08-21 14:26:13Z 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.testmodels.services;
 12  
 
 13  
 import org.mule.components.simple.EchoService;
 14  
 import org.mule.tck.functional.FunctionalTestComponent;
 15  
 import org.mule.umo.lifecycle.Disposable;
 16  
 import org.mule.util.StringUtils;
 17  
 
 18  
 import java.util.Collections;
 19  
 import java.util.Date;
 20  
 import java.util.HashMap;
 21  
 import java.util.Map;
 22  
 
 23  
 /**
 24  
  * <code>TestServiceComponent</code> is a test WebServices component.
 25  
  */
 26  
 public class TestServiceComponent extends FunctionalTestComponent
 27  
     implements EchoService, DateService, PeopleService, Disposable
 28  
 {
 29  
     // we keep two collections - one static for testing the return of complex types
 30  
     // and one for modifying by methods invoked on the TestComponent instance
 31  
 
 32  0
     private static final Person[] originalPeople = new Person[]{new Person("Barney", "Rubble"),
 33  
         new Person("Fred", "Flintstone"), new Person("Wilma", "Flintstone")};
 34  
 
 35  0
     private final Map people = Collections.synchronizedMap(new HashMap());
 36  
 
 37  
     public TestServiceComponent()
 38  
     {
 39  0
         super();
 40  0
         people.put("Barney", originalPeople[0]);
 41  0
         people.put("Fred", originalPeople[1]);
 42  0
         people.put("Wilma", originalPeople[2]);
 43  0
     }
 44  
 
 45  
     public String echo(String echo)
 46  
     {
 47  0
         return echo;
 48  
     }
 49  
 
 50  
     public String getDate()
 51  
     {
 52  0
         return new Date().toString();
 53  
     }
 54  
 
 55  
     public Person getPerson(String firstName)
 56  
     {
 57  0
         if (StringUtils.isEmpty(firstName))
 58  
         {
 59  0
             throw new IllegalArgumentException("Name parameter cannot be null");
 60  
         }
 61  0
         return (Person)people.get(firstName);
 62  
     }
 63  
 
 64  
     public Person[] getPeople()
 65  
     {
 66  0
         return originalPeople;
 67  
     }
 68  
 
 69  
     public void addPerson(Person person) throws Exception
 70  
     {
 71  0
         if (person == null || person.getFirstName() == null || person.getLastName() == null)
 72  
         {
 73  0
             throw new IllegalArgumentException("null person, first name or last name");
 74  
         }
 75  0
         if (person.getFirstName().equals("Ross"))
 76  
         {
 77  0
             throw new Exception("Ross is banned");
 78  
         }
 79  0
         people.put(person.getFirstName(), person);
 80  0
         logger.debug("Added Person: " + person);
 81  0
     }
 82  
 
 83  
     public Person addPerson(String firstname, String surname) throws Exception
 84  
     {
 85  0
         Person p = new Person(firstname, surname);
 86  0
         addPerson(p);
 87  0
         logger.debug("Added Person: " + p);
 88  0
         return p;
 89  
     }
 90  
 
 91  
     /**
 92  
      * A lifecycle method where implementor should free up any resources. If an
 93  
      * exception is thrown it should just be logged and processing should continue.
 94  
      * This method should not throw RuntimeExceptions.
 95  
      */
 96  
     public void dispose()
 97  
     {
 98  0
         people.clear();
 99  0
     }
 100  
 
 101  
 }