maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-wagon/wagon-provider-test/src/main/java/org/apache/maven/wagon FileTestUtils.java WagonTestCase.java
Date Tue, 19 Apr 2005 03:08:30 GMT
brett       2005/04/18 20:08:30

  Modified:    wagon-provider-api/src/main/java/org/apache/maven/wagon/observers
                        ChecksumObserver.java
               wagon-provider-api/src/test/java/org/apache/maven/wagon
                        LazyFileOutputStreamTest.java
               wagon-provider-test/src/main/java/org/apache/maven/wagon
                        WagonTestCase.java
  Added:       wagon-provider-test/src/main/java/org/apache/maven/wagon
                        FileTestUtils.java
  Removed:     wagon-provider-api/src/main/java/org/apache/maven/wagon
                        FileTestUtils.java
  Log:
  remove some extra unhelpful output, move test code to test jar
  
  Revision  Changes    Path
  1.13      +11 -28    maven-wagon/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java
  
  Index: ChecksumObserver.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ChecksumObserver.java	19 Apr 2005 02:49:44 -0000	1.12
  +++ ChecksumObserver.java	19 Apr 2005 03:08:30 -0000	1.13
  @@ -22,6 +22,7 @@
   import org.apache.maven.wagon.WagonUtils;
   import org.apache.maven.wagon.events.TransferEvent;
   import org.apache.maven.wagon.events.TransferListener;
  +import org.apache.maven.wagon.resource.Resource;
   import org.apache.maven.wagon.util.FileUtils;
   import org.apache.maven.wagon.util.IoUtils;
   
  @@ -135,12 +136,12 @@
   
           transferingChecksum = true;
   
  -        try
  -        {
  -            int type = transferEvent.getRequestType();
  +        String checksumResource = transferEvent.getResource().getName() + extension;
   
  -            String resource = transferEvent.getResource().getName();
  +        int type = transferEvent.getRequestType();
   
  +        try
  +        {
               if ( type == TransferEvent.REQUEST_GET )
               {
   
  @@ -150,9 +151,7 @@
   
                   File checksumFile = new File( artifactFile.getPath() + extension );
   
  -                String md5Resource = resource + extension;
  -
  -                wagon.get( md5Resource, checksumFile );
  +                wagon.get( checksumResource, checksumFile );
   
                   expectedChecksum = FileUtils.fileRead( checksumFile ).trim();
               }
  @@ -160,25 +159,22 @@
               {
                   //It's PUT put request we will also put md5 checksum
                   // which was computed on the fly
  -                WagonUtils.fromString( resource + extension, wagon, actualChecksum );
  +                WagonUtils.fromString( checksumResource, wagon, actualChecksum );
   
               }
   
           }
           catch ( ResourceDoesNotExistException e )
           {
  -            // TODO: handle differently! No Exception catching....
  -            e.printStackTrace();
  +            transferError( new TransferEvent( wagon, new Resource( checksumResource ),
e, type ) );
           }
           catch ( WagonException e )
           {
  -            // TODO: handle differently! No Exception catching....
  -            e.printStackTrace();
  +            transferError( new TransferEvent( wagon, new Resource( checksumResource ),
e, type ) );
           }
           catch ( IOException e )
           {
  -            // TODO: handle differently! No Exception catching....
  -            e.printStackTrace();
  +            transferError( new TransferEvent( wagon, new Resource( checksumResource ),
e, type ) );
           }
           finally
           {
  @@ -255,17 +251,4 @@
       }
   
   
  -    public boolean checksumIsValid()
  -    {
  -        boolean retValue = false;
  -
  -        if ( actualChecksum != null && expectedChecksum != null )
  -        {
  -            retValue = actualChecksum.equals( expectedChecksum );
  -        }
  -
  -        return retValue;
  -    }
  -
  -
   }
  
  
  
  1.7       +6 -6      maven-wagon/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java
  
  Index: LazyFileOutputStreamTest.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LazyFileOutputStreamTest.java	19 Apr 2005 02:49:45 -0000	1.6
  +++ LazyFileOutputStreamTest.java	19 Apr 2005 03:08:30 -0000	1.7
  @@ -32,9 +32,9 @@
       public void testFileCreation()
           throws Exception
       {
  -        File file = FileTestUtils.createUniqueFile( getName() );
  +        File file = File.createTempFile( getName(), null );
   
  -        file.deleteOnExit();
  +        file.delete();
   
           assertFalse( file.exists() );
   
  @@ -42,9 +42,9 @@
   
           assertFalse( file.exists() );
   
  -        String exptected = "michal";
  +        String expected = "michal";
   
  -        stream.write( exptected.getBytes() );
  +        stream.write( expected.getBytes() );
   
           stream.close();
   
  @@ -52,7 +52,7 @@
   
           String actual = FileUtils.fileRead( file );
   
  -        assertEquals( exptected, actual );
  +        assertEquals( expected, actual );
   
       }
   
  
  
  
  1.6       +5 -28     maven-wagon/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
  
  Index: WagonTestCase.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WagonTestCase.java	19 Apr 2005 02:49:45 -0000	1.5
  +++ WagonTestCase.java	19 Apr 2005 03:08:30 -0000	1.6
  @@ -230,7 +230,7 @@
   
           wagon.connect( testRepository );
   
  -        destFile = FileTestUtils.createUniqueFile( getName() );
  +        destFile = FileTestUtils.createUniqueFile( getName(), getName() );
   
           destFile.deleteOnExit();
   
  @@ -250,43 +250,20 @@
   
           getFile();
   
  -        System.out.println( "checksumObserver:" + checksumObserver );
  +        assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum()
);
   
  -        System.out.println( "actual:" + checksumObserver.getActualChecksum() );
  +        assertEquals( "compare checksums", checksumObserver.getExpectedChecksum(),
  +                      checksumObserver.getActualChecksum() );
   
  -        System.out.println( "expected:" + checksumObserver.getExpectedChecksum() );
  -
  -        assertTrue( checksumObserver.checksumIsValid() );
  -
  -        compareContents( sourceFile, destFile );
  -    }
  -
  -    protected void compareContents( File sourceFile, File destFile )
  -        throws Exception
  -    {
           // Now compare the conents of the artifact that was placed in
           // the repository with the contents of the artifact that was
           // retrieved from the repository.
   
  -        System.out.println( "sourceFile = " + sourceFile );
  -
  -        System.out.println( "destFile = " + destFile );
  -
  -        System.out.println(
  -            "---------------------------------------------------------------------------------------------------------"
);
  -
  -        System.out.print( "Evaluating and comparing ... " );
  -
           String sourceContent = FileUtils.fileRead( sourceFile );
   
           String destContent = FileUtils.fileRead( destFile );
   
           assertEquals( sourceContent, destContent );
  -
  -        System.out.println( "OK" );
  -
  -        System.out.println(
  -            "---------------------------------------------------------------------------------------------------------"
);
       }
   
       // ----------------------------------------------------------------------
  
  
  
  1.1                  maven-wagon/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java
  
  Index: FileTestUtils.java
  ===================================================================
  package org.apache.maven.wagon;
  
  /*
   * Copyright 2001-2005 The 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.
   */
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.Writer;
  
  /**
   * @author <a href="michal@apache.org>Michal Maczka</a>
   * @version $Id: FileTestUtils.java,v 1.1 2005/04/19 03:08:30 brett Exp $
   */
  public class FileTestUtils
  {
  
      public static final File createUniqueFile( final String dirname, final String name )
          throws IOException
      {
  
          final File dir = createDir( dirname );
  
          final File retValue = new File( dir, name );
  
          return retValue;
  
      }
  
  
      public static final File createUniqueDir( final String name )
          throws IOException
      {
  
          String filename = name + System.currentTimeMillis();
  
          return createDir( filename );
  
      }
  
  
      public static final File createDir( final String name )
          throws IOException
      {
  
          final File baseDirectory = getTestOutputDir();
  
          final File retValue = new File( baseDirectory, name );
  
          retValue.delete();
  
          retValue.mkdirs();
  
          if ( !retValue.exists() )
          {
              throw new IOException( "Unable to create the directory for testdata" );
          }
  
          return retValue;
      }
  
      public static final File getTestOutputDir()
      {
          final String tempDir = System.getProperty( "java.io.tmpdir" );
  
          final String baseDir = System.getProperty( "basedir", tempDir );
  
          final File base = new File( baseDir ).getAbsoluteFile();
  
          final String pathname = base + File.separator + "target" + File.separator + "test-output";
  
          final File retValue = new File( pathname );
  
          retValue.mkdirs();
  
          return retValue;
      }
  
      public static File generateFile( String file, String content )
          throws IOException
      {
          File f = new File( file );
  
          f.getParentFile().mkdirs();
  
          Writer writer = new FileWriter( f );
  
          writer.write( content );
  
          writer.close();
  
          return f;
      }
  }
  
  
  

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


Mime
View raw message