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
Date Tue, 01 Oct 2002 07:50:57 GMT
donaldp     2002/10/01 00:50:56

  Modified:    src/java/org/apache/avalon/phoenix/components/application
                        BlockResourceProvider.java
               src/test/org/apache/avalon/phoenix/test/data Component4.java
  Log:
  Make sure serviceMap returned is unmodifiable. Add a unit test to verify this.
  
  Revision  Changes    Path
  1.9       +5 -2      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockResourceProvider.java
  
  Index: BlockResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockResourceProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BlockResourceProvider.java	1 Oct 2002 07:29:27 -0000	1.8
  +++ BlockResourceProvider.java	1 Oct 2002 07:50:56 -0000	1.9
  @@ -32,6 +32,7 @@
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Collections;
   import java.lang.reflect.Array;
   
   /**
  @@ -257,7 +258,9 @@
               }
               else
               {
  -                map.put( key, value );
  +                final Map smap =
  +                    Collections.unmodifiableMap( (Map)value);
  +                map.put( key, smap );
               }
           }
   
  
  
  
  1.2       +22 -2     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Component4.java
  
  Index: Component4.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Component4.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Component4.java	1 Oct 2002 07:30:25 -0000	1.1
  +++ Component4.java	1 Oct 2002 07:50:56 -0000	1.2
  @@ -41,9 +41,29 @@
           checkService( "c2a", services );
           checkService( "c2b", services );
           checkService( "fred", services );
  +
  +        checkReadOnly( services );
  +    }
  +
  +    private void checkReadOnly( final Map services )
  +        throws ServiceException
  +    {
  +        try
  +        {
  +            services.put( "s", services.get( "fred" ) );
  +        }
  +        catch( Exception e )
  +        {
  +            return;
  +        }
  +
  +        throw new ServiceException( "Was able to modify map " +
  +                                    "retrieved from ServiceManager" );
       }
   
  -    private void checkService( final String name, final Map services ) throws ServiceException
  +    private void checkService( final String name,
  +                               final Map services )
  +        throws ServiceException
       {
           final Object service1 = services.get( name );
           if( null == service1 )
  
  
  

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