avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit PUnitBlockContext.java PUnitBlock.java PUnitComponentManager.java PUnitResourceProvider.java PUnitServiceManager.java PUnitTestCase.java
Date Sat, 09 Nov 2002 19:23:21 GMT
hammant     2002/11/09 11:23:21

  Modified:    src/java/org/apache/avalon/phoenix/tools/punit
                        PUnitBlock.java PUnitComponentManager.java
                        PUnitResourceProvider.java PUnitServiceManager.java
                        PUnitTestCase.java
  Added:       src/java/org/apache/avalon/phoenix/tools/punit
                        PUnitBlockContext.java
  Log:
  More work on Punit. Checkstyle compliance
  
  Revision  Changes    Path
  1.5       +22 -0     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitBlock.java
  
  Index: PUnitBlock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitBlock.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PUnitBlock.java	5 Nov 2002 23:56:03 -0000	1.4
  +++ PUnitBlock.java	9 Nov 2002 19:23:21 -0000	1.5
  @@ -9,12 +9,22 @@
   
   import org.apache.excalibur.containerkit.lifecycle.ResourceProvider;
   
  +/**
  + * PUnitBlock
  + * @author Paul Hammant
  + */
   public class PUnitBlock
   {
       private String m_blockName;
       private Object m_block;
       private ResourceProvider m_resourceProvider;
   
  +    /**
  +     * Construct a PUnitBlock
  +     * @param blockName The block name
  +     * @param block The block
  +     * @param resourceProvider The resource provider for the block
  +     */
       public PUnitBlock( String blockName, Object block, ResourceProvider resourceProvider
)
       {
           this.m_blockName = blockName;
  @@ -22,16 +32,28 @@
           this.m_resourceProvider = resourceProvider;
       }
   
  +    /**
  +     * Get the block name
  +     * @return The block name
  +     */
       public String getBlockName()
       {
           return m_blockName;
       }
   
  +    /**
  +     * Get The block
  +     * @return The block
  +     */
       public Object getBlock()
       {
           return m_block;
       }
   
  +    /**
  +     * Get the resource provider
  +     * @return The resource provider.
  +     */
       public ResourceProvider getResourceProvider()
       {
           return m_resourceProvider;
  
  
  
  1.3       +24 -1     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitComponentManager.java
  
  Index: PUnitComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitComponentManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PUnitComponentManager.java	5 Nov 2002 23:56:03 -0000	1.2
  +++ PUnitComponentManager.java	9 Nov 2002 19:23:21 -0000	1.3
  @@ -13,16 +13,30 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
   
  +/**
  + * PUnitComponentManager
  + * @author Paul Hammant
  + */
   public class PUnitComponentManager
       implements ComponentManager
   {
       private ServiceManager m_serviceManager;
   
  +    /**
  +     * PUnitComponentManager
  +     * @param serviceManager The service manager to delegate to
  +     */
       public PUnitComponentManager(ServiceManager serviceManager)
       {
           this.m_serviceManager = serviceManager;
       }
   
  +    /**
  +     * Lookup a comp
  +     * @param key The key
  +     * @return The comp
  +     * @throws ComponentException If a problem
  +     */
       public Component lookup( String key )
           throws ComponentException
       {
  @@ -36,13 +50,22 @@
           }
       }
   
  +    /**
  +     * Has Component
  +     * @param key The key
  +     * @return true/false
  +     */
       public boolean hasComponent( String key )
       {
           return m_serviceManager.hasService(key);
       }
   
  +    /**
  +     * Release the component
  +     * @param component
  +     */
       public void release( Component component )
       {
  -
  +       m_serviceManager.release(component);
       }
   }
  
  
  
  1.5       +81 -30    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitResourceProvider.java
  
  Index: PUnitResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitResourceProvider.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PUnitResourceProvider.java	5 Nov 2002 23:56:03 -0000	1.4
  +++ PUnitResourceProvider.java	9 Nov 2002 19:23:21 -0000	1.5
  @@ -11,61 +11,112 @@
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.parameters.Parameters;
   
  +/**
  + * PUnitResourceProvider
  + * @author Paul Hammant
  + */
   public class PUnitResourceProvider
       implements ResourceProvider
   {
   
  -    private PUnitServiceManager m_pUnitServiceManager;
  -    private PUnitComponentManager m_pUnitComponentManager;
  +    private ServiceManager m_serviceManager;
  +    private ComponentManager m_componentManager;
       private Configuration m_configuration;
   
  -    public PUnitResourceProvider( PUnitServiceManager pUnitServiceManager,
  +    /**
  +     * PUnitResourceProvider
  +     * @param serviceManager The service manager
  +     * @param configuration The configuration
  +     */
  +    public PUnitResourceProvider( ServiceManager serviceManager,
                                     Configuration configuration )
       {
  -        m_pUnitServiceManager = pUnitServiceManager;
  -        m_pUnitComponentManager = new PUnitComponentManager(pUnitServiceManager);
  +        m_serviceManager = serviceManager;
  +        m_componentManager = new PUnitComponentManager(serviceManager);
           m_configuration = configuration;
       }
   
  -    public Object createObject(Object o) throws Exception
  -    {
  -        return o;
  -    }
  -
  -    public Logger createLogger(Object o) throws Exception
  +    /**
  +     * Create an object
  +     * @param object The object
  +     * @return The returned object
  +     * @throws Exception If a problm
  +     */
  +    public Object createObject(Object object) throws Exception
  +    {
  +        return object;
  +    }
  +
  +    /**
  +     * Create a Logger
  +     * @param object The object to make a logger for
  +     * @return The Logger
  +     * @throws Exception If a problem
  +     */
  +    public Logger createLogger(Object object) throws Exception
       {
           // should be queryable mock logger ?
           return new ConsoleLogger();
       }
   
  -    public Context createContext(Object o) throws Exception
  -    {
  -        return new DefaultContext();
  -    }
  -
  -    public ComponentManager createComponentManager(Object o) throws Exception
  -    {
  -        return m_pUnitComponentManager;
  -    }
  -
  -    public ServiceManager createServiceManager(Object o) throws Exception
  -    {
  -        return m_pUnitServiceManager;
  -    }
  -
  -    public Configuration createConfiguration(Object o) throws Exception
  +    /**
  +     * Create some Context
  +     * @param object For this object
  +     * @return the context
  +     * @throws Exception If a problem
  +     */
  +    public Context createContext(Object object) throws Exception
  +    {
  +        return new PUnitBlockContext();
  +    }
  +
  +    /**
  +     * Create a Comp Mgr
  +     * @param object For this object
  +     * @return The comp mgr
  +     * @throws Exception If a problem
  +     */
  +    public ComponentManager createComponentManager(Object object) throws Exception
  +    {
  +        return m_componentManager;
  +    }
  +
  +    /**
  +     * Create a Service Manager
  +     * @param object For this object
  +     * @return The service manager
  +     * @throws Exception If a problem
  +     */
  +    public ServiceManager createServiceManager(Object object) throws Exception
  +    {
  +        return m_serviceManager;
  +    }
  +
  +    /**
  +     * Create some Configuration
  +     * @param object For this object
  +     * @return The configuration
  +     * @throws Exception If a problem
  +     */
  +    public Configuration createConfiguration(Object object) throws Exception
       {
           return m_configuration;
       }
   
  -    public Parameters createParameters(Object o) throws Exception
  +    /**
  +     * Create Some parameters
  +     * @param object For this object
  +     * @return The parameters
  +     * @throws Exception If a problem
  +     */
  +    public Parameters createParameters(Object object) throws Exception
       {
  -        return null;
  +        //TODO
  +        throw new UnsupportedOperationException();
       }
   }
  
  
  
  1.4       +24 -0     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitServiceManager.java
  
  Index: PUnitServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitServiceManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PUnitServiceManager.java	5 Nov 2002 23:50:50 -0000	1.3
  +++ PUnitServiceManager.java	9 Nov 2002 19:23:21 -0000	1.4
  @@ -12,27 +12,51 @@
   
   import java.util.HashMap;
   
  +/**
  + * PUnitServiceManager
  + * @author Paul Hammant
  + */
   public class PUnitServiceManager
       implements ServiceManager
   {
       private HashMap m_serviceMap = new HashMap();
   
  +    /**
  +     * Add a service
  +     * @param name The service name
  +     * @param object The service
  +     */
       void addService( String name, Object object )
       {
           m_serviceMap.put(name, object);
       }
   
  +    /**
  +     * Lookup a service
  +     * @param key The key
  +     * @return The service
  +     * @throws ServiceException If a problem
  +     */
       public Object lookup( String key )
           throws ServiceException
       {
           return m_serviceMap.get(key);
       }
   
  +    /**
  +     * Has a service
  +     * @param key The service key
  +     * @return The service
  +     */
       public boolean hasService( String key )
       {
           return m_serviceMap.containsKey(key);
       }
   
  +    /**
  +     * Release the service
  +     * @param service The service
  +     */
       public void release( Object service )
       {
   
  
  
  
  1.3       +32 -5     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitTestCase.java
  
  Index: PUnitTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PUnitTestCase.java	5 Nov 2002 23:56:03 -0000	1.2
  +++ PUnitTestCase.java	9 Nov 2002 19:23:21 -0000	1.3
  @@ -14,12 +14,29 @@
   import junit.framework.TestCase;
   import java.util.ArrayList;
   
  +/**
  + * PUnitTestCase
  + * @author Paul Hammant
  + */
   public abstract class PUnitTestCase extends TestCase
   {
       private LifecycleHelper m_lifecycleHelper;
       private ArrayList m_blocks;
       private PUnitServiceManager m_pUnitServiceManager;
   
  +    /**
  +     * PUnitTestCase
  +     * @param name The method name for JUnit
  +     */
  +    public PUnitTestCase( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Setup as per Junit
  +     * @throws Exception If a problem
  +     */
       protected void setUp() throws Exception
       {
           m_lifecycleHelper = new LifecycleHelper();
  @@ -28,11 +45,13 @@
           m_blocks = new ArrayList();
       }
   
  -    public PUnitTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
  +    /**
  +     * Add a block
  +     * @param blockName The block name
  +     * @param block The block
  +     * @param serviceName The service name (for lookup)
  +     * @param configuration The configuration
  +     */
       protected void addBlock( String blockName, String serviceName,
                                Object block , Configuration configuration )
       {
  @@ -45,6 +64,10 @@
           }
       }
   
  +    /**
  +     * Run blocks thru startup.
  +     * @throws LifecycleException If a problem
  +     */
       protected final void startup() throws LifecycleException
       {
   
  @@ -59,6 +82,10 @@
           }
       }
   
  +    /**
  +     * Run blocks thru shutdown
  +     * @throws LifecycleException If a problem
  +     */
       protected final void shutdown() throws LifecycleException
       {
           for( int i = 0; i < m_blocks.size(); i++ )
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/punit/PUnitBlockContext.java
  
  Index: PUnitBlockContext.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.tools.punit;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.phoenix.BlockContext;
  
  import java.io.File;
  import java.io.InputStream;
  
  /**
   * PUnitBlockContext
   * @author Paul Hammant
   */
  public class PUnitBlockContext
      implements BlockContext
  {
  
      public File getBaseDirectory()
      {
          // TODO
          return null;
      }
  
      public String getName()
      {
          // TODO
          return null;
      }
  
  
      public void requestShutdown()
      {
          //TODO
      }
  
      // TODO
      public InputStream getResourceAsStream(String name)
      {
          return null;
      }
  
      public Logger getLogger(String name)
      {
          throw new UnsupportedOperationException();
      }
  
      public ClassLoader getClassLoader(String name)
              throws Exception
      {
          // TODO
          return null;
      }
  
      public Object get(Object o) throws ContextException
      {
          //TODO
          return null;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message