Coverage Report - org.codehaus.plexus.archiver.bzip2.BZip2Archiver
 
Classes in this File Line Coverage Branch Coverage Complexity
BZip2Archiver
88%
16/18
83%
5/6
2,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.bzip2;
 18  
 
 19  
 import java.io.IOException;
 20  
 import org.codehaus.plexus.archiver.AbstractArchiver;
 21  
 import org.codehaus.plexus.archiver.ArchiveEntry;
 22  
 import org.codehaus.plexus.archiver.ArchiverException;
 23  
 import org.codehaus.plexus.archiver.ResourceIterator;
 24  
 import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
 25  
 
 26  8
 public class BZip2Archiver
 27  
     extends AbstractArchiver
 28  
 {
 29  
 
 30  8
     private BZip2Compressor compressor = new BZip2Compressor();
 31  
 
 32  
     @Override
 33  
     public void execute()
 34  
         throws ArchiverException, IOException
 35  
     {
 36  7
         if ( !checkForced() )
 37  
         {
 38  1
             return;
 39  
         }
 40  
 
 41  6
         ResourceIterator iter = getResources();
 42  6
         if ( !iter.hasNext() )
 43  
         {
 44  1
             throw new EmptyArchiveException( "archive cannot be empty" );
 45  
         }
 46  5
         ArchiveEntry entry = iter.next();
 47  5
         if ( iter.hasNext() )
 48  
         {
 49  0
             throw new ArchiverException( "There is more than one file in input." );
 50  
         }
 51  5
         compressor.setSource( entry.getResource() );
 52  5
         compressor.setDestFile( getDestFile() );
 53  5
         compressor.compress();
 54  5
     }
 55  
 
 56  
     @Override
 57  
     public boolean isSupportingForced()
 58  
     {
 59  2
         return true;
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected void close()
 64  
     {
 65  7
         compressor.close();
 66  7
     }
 67  
 
 68  
     @Override
 69  
     protected String getArchiveType()
 70  
     {
 71  0
         return "bzip2";
 72  
     }
 73  
 
 74  
 }