Coverage Report - org.codehaus.plexus.archiver.gzip.GZipCompressor
 
Classes in this File Line Coverage Branch Coverage Complexity
GZipCompressor
66%
10/15
100%
2/2
3.5
 
 1  
 /**
 2  
  *
 3  
  * Copyright 2004 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.codehaus.plexus.archiver.gzip;
 18  
 
 19  
 import java.io.FileOutputStream;
 20  
 import java.io.IOException;
 21  
 import java.io.OutputStream;
 22  
 import java.util.zip.GZIPOutputStream;
 23  
 import org.codehaus.plexus.archiver.ArchiverException;
 24  
 import org.codehaus.plexus.archiver.util.Compressor;
 25  
 import org.codehaus.plexus.archiver.util.Streams;
 26  
 
 27  11
 public class GZipCompressor
 28  
     extends Compressor
 29  
 {
 30  
 
 31  
     private OutputStream zOut;
 32  
 
 33  
     /**
 34  
      * perform the GZip compression operation.
 35  
      */
 36  
     @Override
 37  
     public void compress()
 38  
         throws ArchiverException
 39  
     {
 40  
         try
 41  
         {
 42  8
             zOut = Streams.bufferedOutputStream( new GZIPOutputStream( new FileOutputStream( getDestFile() ) ) );
 43  8
             compress( getSource(), zOut );
 44  
         }
 45  0
         catch ( IOException ioe )
 46  
         {
 47  0
             String msg = "Problem creating gzip " + ioe.getMessage();
 48  0
             throw new ArchiverException( msg, ioe );
 49  8
         }
 50  8
     }
 51  
 
 52  
     @Override
 53  
     public void close()
 54  
     {
 55  
         try
 56  
         {
 57  10
             if ( this.zOut != null )
 58  
             {
 59  8
                 this.zOut.close();
 60  8
                 zOut = null;
 61  
             }
 62  
         }
 63  0
         catch ( final IOException e )
 64  
         {
 65  0
             throw new ArchiverException( "Failure closing target.", e );
 66  10
         }
 67  10
     }
 68  
 
 69  
 }