avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon-logkit/src/test/org/apache/log/test LoggerListenerTestCase.java
Date Thu, 06 Feb 2003 16:39:58 GMT
bloritsch    2003/02/06 08:39:58

  Modified:    src/java/org/apache/log Hierarchy.java
               src/test/org/apache/log/test LoggerListenerTestCase.java
  Log:
  update loggerlistener support to the best compromise
  
  Revision  Changes    Path
  1.23      +14 -3     avalon-logkit/src/java/org/apache/log/Hierarchy.java
  
  Index: Hierarchy.java
  ===================================================================
  RCS file: /home/cvs/avalon-logkit/src/java/org/apache/log/Hierarchy.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Hierarchy.java	5 Feb 2003 08:28:32 -0000	1.22
  +++ Hierarchy.java	6 Feb 2003 16:39:58 -0000	1.23
  @@ -195,13 +195,24 @@
       }
   
       /**
  -     * Set the LoggerListener associated with hierarchy.
  +     * Set the LoggerListener associated with hierarchy.  This is a
  +     * unicast listener, so only one LoggerListener is allowed.
        *
        * @param loggerListener the LoggerListener
  +     *
  +     * @throws UnsupportedOperationException if no more LoggerListeners are
  +     *         permitted.
        */
  -    public synchronized void setLoggerListener( final LoggerListener loggerListener )
  +    public synchronized void addLoggerListener( final LoggerListener loggerListener )
       {
  -        m_loggerListener = loggerListener;
  +        if ( null == m_loggerListener )
  +        {
  +            m_loggerListener = loggerListener;
  +        }
  +        else
  +        {
  +            throw new UnsupportedOperationException( "LoggerListener already set on a unicast
event notifier" );
  +        }
       }
   
       /**
  
  
  
  1.2       +19 -1     avalon-logkit/src/test/org/apache/log/test/LoggerListenerTestCase.java
  
  Index: LoggerListenerTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-logkit/src/test/org/apache/log/test/LoggerListenerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggerListenerTestCase.java	3 Feb 2003 19:39:39 -0000	1.1
  +++ LoggerListenerTestCase.java	6 Feb 2003 16:39:58 -0000	1.2
  @@ -24,12 +24,30 @@
           super( name );
       }
   
  +    public void testUnicastLoggerListener()
  +    {
  +        final Hierarchy hierarchy = new Hierarchy();
  +        final RecordingLoggerListener listener = new RecordingLoggerListener();
  +
  +        try
  +        {
  +            hierarchy.addLoggerListener( listener );
  +            hierarchy.addLoggerListener( listener );
  +
  +            fail( "You should only be able to add one listener." );
  +        }
  +        catch (UnsupportedOperationException uoe)
  +        {
  +            // It passed, yay!
  +        }
  +    }
  +
       public void testPriorityInheritance()
           throws Exception
       {
           final RecordingLoggerListener listener = new RecordingLoggerListener();
           final Hierarchy hierarchy = new Hierarchy();
  -        hierarchy.setLoggerListener( listener );
  +        hierarchy.addLoggerListener( listener );
   
           final Logger root = hierarchy.getRootLogger();
           final Logger l1 = root.getChildLogger( "logger1" );
  
  
  

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


Mime
View raw message