diff --git a/pom.xml b/pom.xml
index 72ce96d27..367dc4ff5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,12 @@
${junitVersion}
test
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junitVersion}
+ test
+
org.junit.jupiter
junit-jupiter-engine
diff --git a/src/main/java/org/codehaus/plexus/archiver/manager/ArchiverManager.java b/src/main/java/org/codehaus/plexus/archiver/manager/ArchiverManager.java
index b32a0a698..49e969e76 100644
--- a/src/main/java/org/codehaus/plexus/archiver/manager/ArchiverManager.java
+++ b/src/main/java/org/codehaus/plexus/archiver/manager/ArchiverManager.java
@@ -17,6 +17,8 @@
package org.codehaus.plexus.archiver.manager;
import java.io.File;
+import java.util.Collection;
+
import javax.annotation.Nonnull;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.UnArchiver;
@@ -35,6 +37,9 @@ Archiver getArchiver( @Nonnull String archiverName )
Archiver getArchiver( @Nonnull File file )
throws NoSuchArchiverException;
+ @Nonnull
+ Collection getAvailableArchivers();
+
@Nonnull
UnArchiver getUnArchiver( @Nonnull String unArchiverName )
throws NoSuchArchiverException;
@@ -43,6 +48,9 @@ UnArchiver getUnArchiver( @Nonnull String unArchiverName )
UnArchiver getUnArchiver( @Nonnull File file )
throws NoSuchArchiverException;
+ @Nonnull
+ Collection getAvailableUnArchivers();
+
@Nonnull
PlexusIoResourceCollection getResourceCollection( @Nonnull File file )
throws NoSuchArchiverException;
@@ -51,4 +59,6 @@ PlexusIoResourceCollection getResourceCollection( @Nonnull File file )
PlexusIoResourceCollection getResourceCollection( String unArchiverName )
throws NoSuchArchiverException;
+ @Nonnull
+ Collection getAvailableResourceCollections();
}
diff --git a/src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java b/src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java
index 884fd2dbe..1d8ec82e0 100644
--- a/src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java
+++ b/src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java
@@ -17,6 +17,7 @@
package org.codehaus.plexus.archiver.manager;
import java.io.File;
+import java.util.Collection;
import java.util.Locale;
import java.util.Map;
@@ -29,7 +30,6 @@
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
-import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import static java.util.Objects.requireNonNull;
@@ -101,49 +101,67 @@ PlexusIoResourceCollection getResourceCollection( String resourceCollectionName
}
private static @Nonnull
- String getFileExtention( @Nonnull File file )
+ String getFileExtension( @Nonnull File file )
{
- String path = file.getAbsolutePath();
- String archiveExt = FileUtils.getExtension( path ).toLowerCase( Locale.ENGLISH );
+ String fileName = file.getName().toLowerCase( Locale.ROOT );
+ String[] tokens = StringUtils.split( fileName, "." );
- if ( "gz".equals( archiveExt )
- || "bz2".equals( archiveExt )
- || "xz".equals( archiveExt )
- || "zst".equals( archiveExt )
- || "snappy".equals( archiveExt ) )
- {
- String[] tokens = StringUtils.split( path, "." );
+ String archiveExt = "";
- if ( tokens.length > 2 && "tar".equals( tokens[tokens.length - 2].toLowerCase( Locale.ENGLISH ) ) )
- {
- archiveExt = "tar." + archiveExt;
- }
+ if ( tokens.length == 2 ) {
+ archiveExt = tokens[1];
+ }
+ else if ( tokens.length > 2 && "tar".equals( tokens[tokens.length - 2] ) )
+ {
+ archiveExt = "tar." + tokens[tokens.length - 1];
+ }
+ else if ( tokens.length > 2 ) {
+ archiveExt = tokens[tokens.length-1];
}
return archiveExt;
-
}
@Override
@Nonnull public Archiver getArchiver( @Nonnull File file )
throws NoSuchArchiverException
{
- return getArchiver( getFileExtention( file ) );
+ return getArchiver( getFileExtension( file ) );
+ }
+
+ @Override
+ public Collection getAvailableArchivers()
+ {
+ return archivers.keySet();
}
@Override
@Nonnull public UnArchiver getUnArchiver( @Nonnull File file )
throws NoSuchArchiverException
{
- return getUnArchiver( getFileExtention( file ) );
+ return getUnArchiver( getFileExtension( file ) );
+ }
+
+ @Nonnull
+ @Override
+ public Collection getAvailableUnArchivers()
+ {
+ return unArchivers.keySet();
}
@Override
@Nonnull public PlexusIoResourceCollection getResourceCollection( @Nonnull File file )
throws NoSuchArchiverException
{
- return getResourceCollection( getFileExtention( file ) );
+ return getResourceCollection( getFileExtension( file ) );
+ }
+
+ @Nonnull
+ @Override
+ public Collection getAvailableResourceCollections()
+ {
+ return plexusIoResourceCollections.keySet();
}
}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TBZ2Archiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TBZ2Archiver.java
new file mode 100644
index 000000000..5f6f53162
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TBZ2Archiver.java
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2004 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Alias for {@link TarBZip2Archiver}.
+ *
+ * @since 4.7.0
+ */
+@Named( "tbz2" )
+public class TBZ2Archiver
+ extends TarBZip2Archiver
+{
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TGZArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TGZArchiver.java
new file mode 100644
index 000000000..5d5d8b554
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TGZArchiver.java
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2004 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Alias for {@link TarGZipArchiver}.
+ *
+ * @since 4.7.0
+ */
+@Named( "tgz" )
+public class TGZArchiver
+ extends TarGZipArchiver
+{
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TXZArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TXZArchiver.java
new file mode 100644
index 000000000..abc6fc3b7
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TXZArchiver.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016 Codehaus.
+ *
+ * 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Alias for {@link TarXZArchiver}.
+ *
+ * @since 4.7.0
+ */
+@Named( "txz" )
+public class TXZArchiver extends TarXZArchiver
+{
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TarBZip2Archiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TarBZip2Archiver.java
new file mode 100644
index 000000000..16a031eb8
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TarBZip2Archiver.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2004 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Create tar with bzip2 compression.
+ *
+ * @since 4.7.0
+ */
+@Named( "tar.bz2" )
+public class TarBZip2Archiver
+ extends TarArchiver
+{
+
+ public TarBZip2Archiver()
+ {
+ this.setupCompressionMethod();
+ }
+
+ private void setupCompressionMethod()
+ {
+ this.setCompression( TarCompressionMethod.bzip2 );
+ }
+
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TarGZipArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TarGZipArchiver.java
new file mode 100644
index 000000000..1ee308dab
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TarGZipArchiver.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2004 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Create tar with gzip compression.
+ *
+ * @since 4.7.0
+ */
+@Named( "tar.gz" )
+public class TarGZipArchiver
+ extends TarArchiver
+{
+
+ public TarGZipArchiver()
+ {
+ this.setupCompressionMethod();
+ }
+
+ private void setupCompressionMethod()
+ {
+ this.setCompression( TarCompressionMethod.gzip );
+ }
+
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TarSnappyArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TarSnappyArchiver.java
new file mode 100644
index 000000000..22afff0b9
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TarSnappyArchiver.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2004 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Create tar with snappy compression.
+ *
+ * @since 4.7.0
+ */
+@Named( "tar.snappy" )
+public class TarSnappyArchiver
+ extends TarArchiver
+{
+
+ public TarSnappyArchiver()
+ {
+ this.setupCompressionMethod();
+ }
+
+ private void setupCompressionMethod()
+ {
+ this.setCompression( TarCompressionMethod.snappy );
+ }
+
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TarXZArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TarXZArchiver.java
new file mode 100644
index 000000000..754c35ddd
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TarXZArchiver.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Codehaus.
+ *
+ * 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Create tar with XZ compression.
+ *
+ * @since 4.7.0
+ */
+@Named( "tar.xz" )
+public class TarXZArchiver extends TarArchiver
+{
+
+ public TarXZArchiver()
+ {
+ setupCompressionMethod();
+ }
+
+ private void setupCompressionMethod()
+ {
+ setCompression( TarCompressionMethod.xz );
+ }
+
+}
diff --git a/src/main/java/org/codehaus/plexus/archiver/tar/TarZstdArchiver.java b/src/main/java/org/codehaus/plexus/archiver/tar/TarZstdArchiver.java
new file mode 100644
index 000000000..28c43c172
--- /dev/null
+++ b/src/main/java/org/codehaus/plexus/archiver/tar/TarZstdArchiver.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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.
+ */
+package org.codehaus.plexus.archiver.tar;
+
+import javax.inject.Named;
+
+/**
+ * Create tar with zstd compression.
+ *
+ * @since 4.7.0
+ */
+@Named( "tar.zst" )
+public class TarZstdArchiver extends TarArchiver
+{
+
+ public TarZstdArchiver()
+ {
+ setupCompressionMethod();
+ }
+
+ private final void setupCompressionMethod()
+ {
+ setCompression( TarCompressionMethod.zstd );
+ }
+}
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index f12f3c60a..e49b1cd03 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -16,32 +16,53 @@ Plexus Archiver
|| Interface || Components for supported formats (as Plexus role hint)
*------------------+-----------------+
| {{{./apidocs/index.html?org/codehaus/plexus/archiver/Archiver.html}<<>>}} |
-| | {{{./xref/org/codehaus/plexus/archiver/bzip2/BZip2Archiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/xz/XZArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/dir/DirectoryArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/ear/EarArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/gzip/GZipArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/jar/JarArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/jar/JarToolModularJarArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/snappy/SnappyArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/zstandard/ZstdArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/tar/TarArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/war/WarArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/zip/ZipArchiver.html}<<>>}}.
-| | Notice that <<>> component produces a <<>>
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2Archiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/dir/DirectoryArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarToolModularJarArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarArchiver.html}<<>>}} (notice produces a <<>>),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipArchiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZArchiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdArchiver.html}<<>>}}
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZArchiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZArchiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/war/WarArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipArchiver.html}<<>>}}.
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdArchiver.html}<<>>}}
+| |
*------------------+-----------------+
| {{{./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html}<<>>}} |
-| | {{{./xref/org/codehaus/plexus/archiver/bzip2.BZip2UnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/xz.XZUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/gzip.GZipUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/snappy.SnappyUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/zstandard.ZstdUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/zip.ZipUnArchiver.html}<<>>}}
-| | (also available as <<>>, <<>>, <<>>, <<>>, <<>>, <<>>, <<>>, <<>>, <<>>, <<>>),
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarGZipUnArchiver.html}<<>>}} or <<>>,
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarBZip2UnArchiver.html}<<>>}} or <<>>,
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarXZUnArchiver.html}<<>>}} or <<>>,
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarZstdUnArchiver.html}<<>>}},
-| | {{{./xref/org/codehaus/plexus/archiver/tar.TarSnappyUnArchiver.html}<<>>}}.
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2UnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipUnArchiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZUnArchiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyUnArchiver.html}<<>>}}
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdUnArchiver.html}<<>>}}
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZUnArchiver.html}<<>>}}
+| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZUnArchiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipUnArchiver.html}<<>>}}
+| | (also available as {{{./apidocs/index.html?org/codehaus/plexus/archiver/car/CarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/esb/EsbUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/nar/NarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/par/ParUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/sar/SarUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/swc/SwcUnArchiver.html}<<>>}},
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/war/WarUnArchiver.html}<<>>}}),
+| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdUnArchiver.html}<<>>}}
*------------------+-----------------+
diff --git a/src/test/java/org/codehaus/plexus/archiver/manager/ArchiverManagerTest.java b/src/test/java/org/codehaus/plexus/archiver/manager/ArchiverManagerTest.java
index 62658fbd5..a5a1681e9 100644
--- a/src/test/java/org/codehaus/plexus/archiver/manager/ArchiverManagerTest.java
+++ b/src/test/java/org/codehaus/plexus/archiver/manager/ArchiverManagerTest.java
@@ -24,35 +24,90 @@
package org.codehaus.plexus.archiver.manager;
import java.io.File;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.TestSupport;
import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Dan T. Tran
*/
-public class ArchiverManagerTest
- extends TestSupport
+class ArchiverManagerTest
+ extends TestSupport
{
- @Test
- public void testLookupArchiver()
- throws Exception
+ // list of items which support Archiver and UnArchiver
+ private static Stream getArchiversAndUnArchiverForTests()
{
- ArchiverManager manager = lookup( ArchiverManager.class );
+ return Stream.of(
+ "bzip2",
+ "ear",
+ "gzip",
+ "jar",
+ "rar",
+ "tar",
+ "tar.bz2",
+ "tar.gz",
+ "tar.snappy",
+ "tar.xz",
+ "tar.zst",
+ "tbz2",
+ "tgz",
+ "txz",
+ "war",
+ "xz",
+ "zip",
+ "snappy",
+ "zst"
+ );
+ }
- Archiver archiver = manager.getArchiver( "jar" );
- assertNotNull( archiver );
+ // list of items which support UnArchiver
+ private static Stream getUnArchiversForTests()
+ {
+ return Stream.concat( getArchiversAndUnArchiverForTests(), Stream.of(
+ // only UnArchivers
+ "car",
+ "esb",
+ "nar",
+ "par",
+ "sar",
+ "swc" ) );
+ }
+
+ // list of Archiver
+ private static Stream getArchiversForTests()
+ {
+ return Stream.concat( getArchiversAndUnArchiverForTests(), Stream.of(
+ // only Archivers
+ "dir",
+ "mjar" ) );
+ }
+
+ private static Stream getResourceCollectionsForTests()
+ {
+ return Stream.concat(
+ getUnArchiversForTests(),
+ Stream.of( "default", "files", /* defined in plexus-io */
+ "gz", "bz2" /* additional alias only for it */
+ ) );
}
@Test
- public void testReuseArchiver()
+ void testReuseArchiver()
throws Exception
{
ArchiverManager manager = lookup( ArchiverManager.class );
@@ -70,137 +125,153 @@ public void testReuseArchiver()
}
@Test
- public void testLookupUnArchiver()
- throws Exception
+ void allArchiversShouldBeUnderTest()
{
ArchiverManager manager = lookup( ArchiverManager.class );
- UnArchiver unarchiver = manager.getUnArchiver( "zip" );
- assertNotNull( unarchiver );
+ assertThat( manager.getAvailableArchivers() )
+ .containsExactlyInAnyOrderElementsOf( getArchiversForTests().collect( Collectors.toList() ) );
}
@Test
- public void testLookupUnknownArchiver()
- throws Exception
+ void allUnArchiversShouldBeUnderTest()
{
ArchiverManager manager = lookup( ArchiverManager.class );
- try
- {
- manager.getArchiver( "Unknown" );
- fail();
- }
- catch ( NoSuchArchiverException ignore )
- {
- }
+
+ assertThat( manager.getAvailableUnArchivers() )
+ .containsExactlyInAnyOrderElementsOf( getUnArchiversForTests().collect( Collectors.toList() ) );
}
@Test
- public void testLookupUnknownUnArchiver()
- throws Exception
+ void allResourceCollectionsShouldBeUnderTest()
{
ArchiverManager manager = lookup( ArchiverManager.class );
- try
- {
- manager.getUnArchiver( "Unknown" );
- fail();
- }
- catch ( NoSuchArchiverException ignore )
- {
- }
+
+ assertThat( manager.getAvailableResourceCollections() )
+ .containsExactlyInAnyOrderElementsOf( getResourceCollectionsForTests().collect( Collectors.toList() ) );
}
- @Test
- public void testLookupUnArchiverUsingFile()
- throws Exception
+ @ParameterizedTest
+ @MethodSource( "getArchiversForTests" )
+ void testLookupArchiver( String archiveName ) throws Exception
{
ArchiverManager manager = lookup( ArchiverManager.class );
+ Archiver archiver = manager.getArchiver( archiveName );
- UnArchiver unarchiver = manager.getUnArchiver( new File( "test.tar.gz" ) );
- assertNotNull( unarchiver );
+ assertThat( archiver ).isNotNull();
+ }
- unarchiver = manager.getUnArchiver( new File( "test.tar.bz2" ) );
- assertNotNull( unarchiver );
+ @ParameterizedTest
+ @MethodSource( "getUnArchiversForTests" )
+ void testLookupUnArchiver( String archiveName ) throws Exception
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+ UnArchiver archiver = manager.getUnArchiver( archiveName );
- unarchiver = manager.getUnArchiver( new File( "test.tgz" ) );
- assertNotNull( unarchiver );
+ assertThat( archiver ).isNotNull();
+ }
- unarchiver = manager.getUnArchiver( new File( "test.tbz2" ) );
- assertNotNull( unarchiver );
+ @ParameterizedTest
+ @MethodSource( "getResourceCollectionsForTests" )
+ void testLookupResourceCollection( String resourceName ) throws Exception
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+ PlexusIoResourceCollection resourceCollection = manager.getResourceCollection( resourceName );
- unarchiver = manager.getUnArchiver( new File( "test.bzip2" ) );
- assertNotNull( unarchiver );
+ assertThat( resourceCollection ).isNotNull();
+ }
- unarchiver = manager.getUnArchiver( new File( "test.tar" ) );
- assertNotNull( unarchiver );
+ @Test
+ void testLookupUnknownArchiver()
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+ assertThrowsExactly( NoSuchArchiverException.class, () -> manager.getArchiver( "Unknown" ) );
}
@Test
- public void testLookupArchiverUsingFile()
- throws Exception
+ void testLookupUnknownUnArchiver()
{
ArchiverManager manager = lookup( ArchiverManager.class );
- Archiver archiver = manager.getArchiver( new File( "test.gzip" ) );
- assertNotNull( archiver );
+ assertThrowsExactly( NoSuchArchiverException.class, () -> manager.getUnArchiver( "Unknown" ) );
+ }
- archiver = manager.getArchiver( new File( "test.bzip2" ) );
- assertNotNull( archiver );
+ @Test
+ void testLookupUnknownResourceCollection()
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
- archiver = manager.getArchiver( new File( "test.tar" ) );
- assertNotNull( archiver );
+ assertThrowsExactly( NoSuchArchiverException.class, () -> manager.getResourceCollection( "Unknown" ) );
+ }
+ @ParameterizedTest
+ @MethodSource( "getUnArchiversForTests" )
+ void testLookupUnArchiverUsingFile( String archiveName )
+ throws Exception
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+
+ UnArchiver archiver = manager.getUnArchiver( new File( "test", "test." + archiveName ) );
+ assertThat( archiver ).isNotNull();
}
- @Test
- public void testUnspportedLookupArchiverUsingFile()
+ @ParameterizedTest
+ @MethodSource( "getArchiversForTests" )
+ void testLookupArchiverUsingFile( String archiveName )
throws Exception
{
ArchiverManager manager = lookup( ArchiverManager.class );
- try
- {
- manager.getArchiver( new File( "test.tbz2" ) );
- //until we support this type, this must fail
- fail( "Please remove this test." );
- }
- catch ( NoSuchArchiverException ignore )
- {
-
- }
-
- try
- {
- manager.getArchiver( new File( "test.tgz" ) );
- //until we support this type, this must fail
- fail( "Please remove this test." );
- }
- catch ( NoSuchArchiverException ignore )
- {
-
- }
-
- try
- {
- manager.getArchiver( new File( "test.tar.gz" ) );
- //until we support this type, this must fail
- fail( "Please remove this test." );
- }
- catch ( NoSuchArchiverException ignore )
- {
-
- }
-
- try
- {
- manager.getArchiver( new File( "test.tar.bz2" ) );
- //until we support this type, this must fail
- fail( "Please remove this test." );
- }
- catch ( NoSuchArchiverException ignore )
- {
-
- }
+ Archiver archiver = manager.getArchiver( new File( "test." + archiveName ) );
+ assertThat( archiver ).isNotNull();
+ }
+
+ private static Stream getUnsupportedFiles()
+ {
+ return Stream.of(
+ Arguments.of( "", "" ),
+ Arguments.of( "test", "" ),
+ Arguments.of( "test.xxx", "xxx" ),
+ Arguments.of( "test.tar.xxx", "tar.xxx" ),
+ Arguments.of( "tar.gz.xxx", "xxx" )
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource( "getUnsupportedFiles" )
+ void testUnsupportedLookupArchiverUsingFile( String fileName, String fileExtension )
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+
+ NoSuchArchiverException exception = assertThrowsExactly(
+ NoSuchArchiverException.class, () -> manager.getArchiver( new File( "test", fileName ) ) );
+
+ assertThat( exception.getArchiver() ).isEqualTo( fileExtension );
+ }
+
+ @ParameterizedTest
+ @MethodSource( "getUnsupportedFiles" )
+ void testUnsupportedLookupUnArchiverUsingFile( String fileName, String fileExtension )
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+
+ NoSuchArchiverException exception = assertThrowsExactly(
+ NoSuchArchiverException.class, () -> manager.getUnArchiver( new File( fileName ) ) );
+
+ assertThat( exception.getArchiver() ).isEqualTo( fileExtension );
+ }
+
+ @ParameterizedTest
+ @MethodSource( "getUnsupportedFiles" )
+ void testUnsupportedLookupResourceCollectionUsingFile( String fileName, String fileExtension )
+ {
+ ArchiverManager manager = lookup( ArchiverManager.class );
+
+ NoSuchArchiverException exception = assertThrowsExactly(
+ NoSuchArchiverException.class, () -> manager.getResourceCollection( new File( fileName ) ) );
+
+ assertThat( exception.getArchiver() ).isEqualTo( fileExtension );
}
}