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

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

bloritsch    2003/03/28 06:51:56

  Modified:    monitor/src/java/org/apache/avalon/excalibur/monitor
                        ResourceOutputStream.java ResourceWriter.java
               monitor/src/test/org/apache/avalon/excalibur/monitor/test
                        MonitorTestCase.java MonitorTestCaseListener.java
  Log:
  fix the testcases by using a MockResource instead of relying on the FIleSystem--which we cannot control
  
  Revision  Changes    Path
  1.11      +2 -2      avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ResourceOutputStream.java
  
  Index: ResourceOutputStream.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ResourceOutputStream.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ResourceOutputStream.java	22 Mar 2003 12:46:50 -0000	1.10
  +++ ResourceOutputStream.java	28 Mar 2003 14:51:56 -0000	1.11
  @@ -63,7 +63,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @version $Id$
    */
  -final class ResourceOutputStream
  +public final class ResourceOutputStream
       extends FilterOutputStream
   {
       private final StreamResource m_resource;
  
  
  
  1.11      +2 -2      avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ResourceWriter.java
  
  Index: ResourceWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ResourceWriter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ResourceWriter.java	22 Mar 2003 12:46:50 -0000	1.10
  +++ ResourceWriter.java	28 Mar 2003 14:51:56 -0000	1.11
  @@ -63,7 +63,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @version $Id$
    */
  -final class ResourceWriter
  +public final class ResourceWriter
       extends FilterWriter
   {
       private final StreamResource m_resource;
  
  
  
  1.18      +6 -9      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MonitorTestCase.java	22 Mar 2003 12:46:51 -0000	1.17
  +++ MonitorTestCase.java	28 Mar 2003 14:51:56 -0000	1.18
  @@ -50,9 +50,8 @@
   
   package org.apache.avalon.excalibur.monitor.test;
   
  -import java.io.File;
  -import java.io.FileWriter;
   import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
   import java.io.Writer;
   
   import org.apache.avalon.excalibur.monitor.FileResource;
  @@ -147,13 +146,12 @@
       {
           try
           {
  -            final File thirdWheel = new File( "test.txt" );
  -            thirdWheel.createNewFile();
  -            thirdWheel.setLastModified( System.currentTimeMillis() );
  +            final Mock thirdWheel = new Mock( "test.txt" );
  +            thirdWheel.touch();
               final MonitorTestCaseListener listener = new MonitorTestCaseListener();
               listener.enableLogging( getLogEnabledLogger() );
   
  -            final FileResource resource = new FileResource( "test.txt" );
  +            final MockResource resource = new MockResource( thirdWheel );
               resource.addPropertyChangeListener( listener );
   
               testMonitor.addResource( resource );
  @@ -161,7 +159,7 @@
   
               if( active )
               {
  -                final FileWriter externalWriter = new FileWriter( thirdWheel );
  +                final Writer externalWriter = new OutputStreamWriter( new MockOutputStream(thirdWheel) );
                   externalWriter.write( "External Writer modification" );
                   externalWriter.flush();
                   externalWriter.close();
  @@ -188,7 +186,6 @@
   
               resource.removePropertyChangeListener( listener );
               testMonitor.removeResource( resource );
  -            thirdWheel.delete();
           }
           catch( final Exception e )
           {
  
  
  
  1.7       +1 -2      avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCaseListener.java
  
  Index: MonitorTestCaseListener.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCaseListener.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MonitorTestCaseListener.java	22 Mar 2003 12:46:51 -0000	1.6
  +++ MonitorTestCaseListener.java	28 Mar 2003 14:51:56 -0000	1.7
  @@ -52,7 +52,6 @@
   import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeListener;
   
  -import org.apache.avalon.excalibur.monitor.FileResource;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   class MonitorTestCaseListener
  @@ -81,7 +80,7 @@
                                                              ( (Long)propertyChangeEvent.getNewValue() ).longValue() ) +
                                 "ms" );
               getLogger().info( "Received notification for " +
  -                              ( (FileResource)propertyChangeEvent.getSource() ).getResourceKey() );
  +                              ( (MockResource)propertyChangeEvent.getSource() ).getResourceKey() );
               getLogger().info( propertyChangeEvent.getPropertyName() +
                                 "\n  IS::" + (Long)propertyChangeEvent.getNewValue() +
                                 "\n  WAS::" + (Long)propertyChangeEvent.getOldValue() +
  
  
  

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