@Test public void testCreateTarArchiver_InvalidFormat_ShouldFailWithInvalidCompression() throws NoSuchArchiverException, ArchiverException { final EasyMockSupport mm = new EasyMockSupport(); final TestTarArchiver ttArchiver = new TestTarArchiver(); final DefaultAssemblyArchiver subject = createSubject( mm, ttArchiver ); try { subject.createTarArchiver( "tar.Z", null ); fail( "Invalid compression formats should throw an error." ); } catch ( final IllegalArgumentException e ) { } mm.verifyAll(); }
protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode ) throws NoSuchArchiverException { final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" ); final int index = format.indexOf( '.' ); if ( index >= 0 ) { TarArchiver.TarCompressionMethod tarCompressionMethod; final String compression = format.substring( index + 1 ); if ( "gz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip; } else if ( "bz2".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2; } else if ( "xz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.xz; } else if ( "snappy".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy; } else { throw new IllegalArgumentException( "Unknown compression format: " + compression ); } tarArchiver.setCompression( tarCompressionMethod ); } else if ( "tgz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip ); } else if ( "tbz2".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 ); } else if ( "txz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz ); } tarArchiver.setLongfile( tarLongFileMode ); return tarArchiver; }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode ) throws NoSuchArchiverException { final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" ); final int index = format.indexOf( '.' ); if ( index >= 0 ) { TarArchiver.TarCompressionMethod tarCompressionMethod; final String compression = format.substring( index + 1 ); if ( "gz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip; } else if ( "bz2".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2; } else if ( "xz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.xz; } else if ( "snappy".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy; } else { throw new IllegalArgumentException( "Unknown compression format: " + compression ); } tarArchiver.setCompression( tarCompressionMethod ); } else if ( "tgz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip ); } else if ( "tbz2".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 ); } else if ( "txz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz ); } tarArchiver.setLongfile( tarLongFileMode ); return tarArchiver; } }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode ) throws NoSuchArchiverException { final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" ); final int index = format.indexOf( '.' ); if ( index >= 0 ) { TarArchiver.TarCompressionMethod tarCompressionMethod; final String compression = format.substring( index + 1 ); if ( "gz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip; } else if ( "bz2".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2; } else if ( "xz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.xz; } else if ( "snappy".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy; } else { throw new IllegalArgumentException( "Unknown compression format: " + compression ); } tarArchiver.setCompression( tarCompressionMethod ); } else if ( "tgz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip ); } else if ( "tbz2".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 ); } else if ( "txz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz ); } tarArchiver.setLongfile( tarLongFileMode ); return tarArchiver; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode ) throws NoSuchArchiverException { final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" ); final int index = format.indexOf( '.' ); if ( index >= 0 ) { TarArchiver.TarCompressionMethod tarCompressionMethod; final String compression = format.substring( index + 1 ); if ( "gz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip; } else if ( "bz2".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2; } else if ( "xz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.xz; } else if ( "snappy".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy; } else { throw new IllegalArgumentException( "Unknown compression format: " + compression ); } tarArchiver.setCompression( tarCompressionMethod ); } else if ( "tgz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip ); } else if ( "tbz2".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 ); } else if ( "txz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz ); } tarArchiver.setLongfile( tarLongFileMode ); return tarArchiver; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); @Override File createArchive( final Assembly assembly, final String fullName, final String format,
                               final AssemblerConfigurationSource configSource, boolean recompressZippedFiles,
                               String mergeManifestMode ); @Override void contextualize( final Context context ); }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode ) throws NoSuchArchiverException { final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" ); final int index = format.indexOf( '.' ); if ( index >= 0 ) { TarArchiver.TarCompressionMethod tarCompressionMethod; final String compression = format.substring( index + 1 ); if ( "gz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip; } else if ( "bz2".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2; } else if ( "xz".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.xz; } else if ( "snappy".equals( compression ) ) { tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy; } else { throw new IllegalArgumentException( "Unknown compression format: " + compression ); } tarArchiver.setCompression( tarCompressionMethod ); } else if ( "tgz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip ); } else if ( "tbz2".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 ); } else if ( "txz".equals( format ) ) { tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz ); } tarArchiver.setLongfile( tarLongFileMode ); return tarArchiver; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); @Override File createArchive( final Assembly assembly, final String fullName, final String format,
                               final AssemblerConfigurationSource configSource, boolean recompressZippedFiles,
                               String mergeManifestMode ); @Override void contextualize( final Context context );  }