You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/02/26 15:28:51 UTC

cvs commit: avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test DirectoryTCListener.java MonitorTCListener.java DirectoryTestCase.java MonitorTestCase.java DirectoryTestCaseListener.java MonitorTestCaseListener.java

niclas      2004/02/26 06:28:51

  Modified:    monitor/src/test/org/apache/avalon/excalibur/monitor/test
                        DirectoryTestCase.java MonitorTestCase.java
  Added:       monitor/src/test/org/apache/avalon/excalibur/monitor/test
                        DirectoryTCListener.java MonitorTCListener.java
  Removed:     monitor/src/test/org/apache/avalon/excalibur/monitor/test
                        DirectoryTestCaseListener.java
                        MonitorTestCaseListener.java
  Log:
  Renamed the TestCaseListeners, since Maven will take any class with TestCase in its name as a testcase.
  
  Revision  Changes    Path
  1.5       +2 -2      avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCase.java
  
  Index: DirectoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DirectoryTestCase.java	25 Feb 2004 10:33:18 -0000	1.4
  +++ DirectoryTestCase.java	26 Feb 2004 14:28:51 -0000	1.5
  @@ -125,7 +125,7 @@
           final DirectoryResource resource =
               new DirectoryResource( dir.getCanonicalPath() );
   
  -        final DirectoryTestCaseListener listener = new DirectoryTestCaseListener();
  +        final DirectoryTCListener listener = new DirectoryTCListener();
           listener.enableLogging( new ConsoleLogger() );
           resource.addPropertyChangeListener( listener );
   
  
  
  
  1.5       +3 -3      avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCase.java
  
  Index: MonitorTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonitorTestCase.java	25 Feb 2004 10:33:18 -0000	1.4
  +++ MonitorTestCase.java	26 Feb 2004 14:28:51 -0000	1.5
  @@ -112,7 +112,7 @@
           {
               final Mock thirdWheel = new Mock( "test.txt" );
               thirdWheel.touch();
  -            final MonitorTestCaseListener listener = new MonitorTestCaseListener();
  +            final MonitorTCListener listener = new MonitorTCListener();
               listener.enableLogging( getLogEnabledLogger() );
   
               final MockResource resource = new MockResource( thirdWheel );
  @@ -188,7 +188,7 @@
           }
       }
   
  -    private void checkForModification( final MonitorTestCaseListener listener )
  +    private void checkForModification( final MonitorTCListener listener )
       {
           final long sleepTo = System.currentTimeMillis() + 1000L;
           while( System.currentTimeMillis() < sleepTo &&
  
  
  
  1.1                  avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTCListener.java
  
  Index: DirectoryTCListener.java
  ===================================================================
  /* 
   * Copyright 2002-2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.avalon.excalibur.monitor.test;
  
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeListener;
  import java.util.Collections;
  import java.util.Set;
  
  import org.apache.avalon.excalibur.monitor.DirectoryResource;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  /**
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   */
  class DirectoryTCListener
      extends AbstractLogEnabled
      implements PropertyChangeListener
  {
      private int m_changeCount;
      private Set m_added = Collections.EMPTY_SET;
      private Set m_removed = Collections.EMPTY_SET;
      private Set m_modified = Collections.EMPTY_SET;
  
      void reset()
      {
          m_added = Collections.EMPTY_SET;
          m_removed = Collections.EMPTY_SET;
          m_modified = Collections.EMPTY_SET;
      }
  
      public Set getAdded()
      {
          return m_added;
      }
  
      public Set getRemoved()
      {
          return m_removed;
      }
  
      public Set getModified()
      {
          return m_modified;
      }
  
      public int getChangeCount()
      {
          return m_changeCount;
      }
  
      public void propertyChange( final PropertyChangeEvent event )
      {
          m_changeCount++;
          final String name = event.getPropertyName();
          final Set newValue = (Set)event.getNewValue();
          if( name.equals( DirectoryResource.ADDED ) )
          {
              m_added = newValue;
          }
          else if( name.equals( DirectoryResource.REMOVED ) )
          {
              m_removed = newValue;
          }
          else
          {
              m_modified = newValue;
          }
      }
  }
  
  
  
  1.1                  avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTCListener.java
  
  Index: MonitorTCListener.java
  ===================================================================
  /* 
   * Copyright 2002-2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.avalon.excalibur.monitor.test;
  
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeListener;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  /*
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   */
  class MonitorTCListener
      extends AbstractLogEnabled
      implements PropertyChangeListener
  {
      private volatile boolean m_hasChanged = false;
  
      public boolean hasBeenModified()
      {
          return m_hasChanged;
      }
  
      public void reset()
      {
          m_hasChanged = false;
      }
  
      public void propertyChange( final PropertyChangeEvent propertyChangeEvent )
      {
          m_hasChanged = true;
  
          if( getLogger().isInfoEnabled() )
          {
              getLogger().info( "NOTIFICATION LATENCY: " + ( System.currentTimeMillis() -
                                                             ( (Long)propertyChangeEvent.getNewValue() ).longValue() ) +
                                "ms" );
              getLogger().info( "Received notification for " +
                                ( (MockResource)propertyChangeEvent.getSource() ).getResourceKey() );
              getLogger().info( propertyChangeEvent.getPropertyName() +
                                "\n  IS::" + (Long)propertyChangeEvent.getNewValue() +
                                "\n  WAS::" + (Long)propertyChangeEvent.getOldValue() +
                                "\n  TIME SINCE LAST MOD::" +
                                ( ( (Long)propertyChangeEvent.getNewValue() ).longValue() -
                                  ( (Long)propertyChangeEvent.getOldValue() ).longValue() ) );
          }
      }
  }
  
  
  

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