Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for existing AbstractArchiver behaviour.

  • Loading branch information...
commit 146b64f8c0decd3bec3b71d3c1e0424ba7a27ed3 1 parent 6208abb
Joseph Walton josephw authored committed
74 src/test/java/org/codehaus/plexus/archiver/AbstractArchiverTest.java
View
@@ -0,0 +1,74 @@
+package org.codehaus.plexus.archiver;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+public class AbstractArchiverTest extends TestCase
+{
+ private AbstractArchiver archiver;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ this.archiver = new AbstractArchiver()
+ {
+ protected String getArchiveType()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void execute() throws ArchiverException, IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void close() throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ public void testModesAndOverridesAreUnsetByDefault()
+ {
+ assertEquals(-1, archiver.getDefaultFileMode());
+ assertEquals(-1, archiver.getOverrideFileMode());
+
+ assertEquals(-1, archiver.getDefaultDirectoryMode());
+ assertEquals(-1, archiver.getOverrideDirectoryMode());
+ }
+
+ public void testWhenUnsetModeUsesDefault()
+ {
+ assertEquals(Archiver.DEFAULT_FILE_MODE, archiver.getFileMode());
+ assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDirectoryMode());
+ }
+
+ public void testSetModeIsUsedWithFlagsForType()
+ {
+ archiver.setFileMode(0400);
+ assertEquals(0100400, archiver.getFileMode());
+
+ archiver.setDirectoryMode(0600);
+ assertEquals(040600, archiver.getDirectoryMode());
+ }
+
+ public void testSetDefaultIncludesFlagsForType()
+ {
+ archiver.setDefaultFileMode(0400);
+ assertEquals(0100400, archiver.getDefaultFileMode());
+
+ archiver.setDefaultDirectoryMode(0600);
+ assertEquals(040600, archiver.getDefaultDirectoryMode());
+ }
+
+ public void testDefaultIsUsedWhenModeIsUnset()
+ {
+ archiver.setDefaultFileMode(0400);
+ assertEquals(0100400, archiver.getFileMode());
+
+ archiver.setDefaultDirectoryMode(0600);
+ assertEquals(040600, archiver.getDirectoryMode());
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.