avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data Component4.java Component4.xinfo
Date Tue, 01 Oct 2002 07:30:25 GMT
donaldp     2002/10/01 00:30:25

  Modified:    src/test/org/apache/avalon/phoenix/components/application/test
                        ApplicationTestCase.java
  Added:       src/test/org/apache/avalon/phoenix/components/application/test
                        assembly3.xml
               src/test/org/apache/avalon/phoenix/test/data Component4.java
                        Component4.xinfo
  Log:
  Add in a unit test to test Map dependencies.
  
  Revision  Changes    Path
  1.2       +8 -20     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/components/application/test/ApplicationTestCase.java
  
  Index: ApplicationTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/components/application/test/ApplicationTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationTestCase.java	1 Oct 2002 06:19:50 -0000	1.1
  +++ ApplicationTestCase.java	1 Oct 2002 07:30:24 -0000	1.2
  @@ -7,28 +7,10 @@
    */
   package org.apache.avalon.phoenix.components.application.test;
   
  -import java.io.File;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.HashMap;
  -import junit.framework.TestCase;
  -import org.apache.avalon.excalibur.io.FileUtil;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.logger.ConsoleLogger;
  -import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.phoenix.components.logger.DefaultLogManager;
   import org.apache.avalon.phoenix.components.application.DefaultApplication;
  -import org.apache.avalon.phoenix.interfaces.LogManager;
  -import org.apache.avalon.phoenix.interfaces.ApplicationContext;
  -import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
  -import org.apache.avalon.phoenix.metadata.BlockMetaData;
   import org.apache.avalon.phoenix.metadata.SarMetaData;
   import org.apache.avalon.phoenix.test.AbstractContainerTestCase;
  -import org.apache.excalibur.threadcontext.ThreadContext;
  -import org.apache.excalibur.threadcontext.impl.DefaultThreadContextPolicy;
   
   /**
    *  An basic test case for the LogManager.
  @@ -50,10 +32,16 @@
           runApplicationTest( "assembly1.xml" );
       }
   
  -    public void testComplex()
  +    public void testArrayAssembly()
           throws Exception
       {
           runApplicationTest( "assembly2.xml" );
  +    }
  +
  +    public void testMapAssembly()
  +        throws Exception
  +    {
  +        runApplicationTest( "assembly3.xml" );
       }
   
       private void runApplicationTest( final String config )
  
  
  
  1.1                  jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/components/application/test/assembly3.xml
  
  Index: assembly3.xml
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE assembly PUBLIC "-//PHOENIX/Assembly DTD Version 1.0//EN"
                    "http://jakarta.apache.org/avalon/dtds/phoenix/assembly_1.0.dtd">
  
  <assembly>
  
      <block class="org.apache.avalon.phoenix.test.data.Component2"
          name="c2a"/>
  
      <block class="org.apache.avalon.phoenix.test.data.Component2"
          name="c2b"/>
  
      <block class="org.apache.avalon.phoenix.test.data.Component2"
          name="c2c"/>
  
      <block class="org.apache.avalon.phoenix.test.data.Component4"
          name="c3">
          <provide name="c2a"
              role="org.apache.avalon.phoenix.test.data.Service2#"/>
          <provide name="c2b"
              role="org.apache.avalon.phoenix.test.data.Service2#"/>
          <provide name="c2c"
              alias="fred"
              role="org.apache.avalon.phoenix.test.data.Service2#"/>
      </block>
  
  </assembly>
  
  
  1.1                  jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Component4.java
  
  Index: Component4.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.test.data;
  
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import java.util.Arrays;
  import java.util.Map;
  
  /**
   * A test component.
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/10/01 07:30:25 $
   */
  public class Component4
      implements Serviceable
  {
      public void service( final ServiceManager manager )
          throws ServiceException
      {
          final Map services =
              (Map)manager.lookup( Service2.ROLE + "#" );
          System.out.println( "Passed the following services: " +
                              services );
  
          final int size = services.size();
          if( 3 != size )
          {
              final String message =
                  "Expected to get 3 services but got " + size;
              throw new ServiceException( message );
          }
  
          checkService( "c2a", services );
          checkService( "c2b", services );
          checkService( "fred", services );
      }
  
      private void checkService( final String name, final Map services ) throws ServiceException
      {
          final Object service1 = services.get( name );
          if( null == service1 )
          {
              final String message =
                  "Expected to get service " + name;
              throw new ServiceException( message );
          }
          else if( !( service1 instanceof Service2 ) )
          {
              final String message =
                  "Expected to service " + name +
                  " to be of type Service2 but was " +
                  "of type: " + service1.getClass().getName();
              throw new ServiceException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Component4.xinfo
  
  Index: Component4.xinfo
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN"
                    "http://jakarta.apache.org/avalon/dtds/phoenix/blockinfo_1.0.dtd">
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are required by this block -->
    <dependencies>
      <dependency>
        <service name="org.apache.avalon.phoenix.test.data.Service2#"/>
      </dependency>
    </dependencies>
  </blockinfo>
  
  
  

--
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