Permalink
Browse files

Add tests for existing AbstractArchiver behaviour.

  • Loading branch information...
1 parent 6208abb commit 146b64f8c0decd3bec3b71d3c1e0424ba7a27ed3 @josephw josephw committed with Jan 6, 2012
Showing with 74 additions and 0 deletions.
  1. +74 −0 src/test/java/org/codehaus/plexus/archiver/AbstractArchiverTest.java
View
74 src/test/java/org/codehaus/plexus/archiver/AbstractArchiverTest.java
@@ -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());
+ }
+}

0 comments on commit 146b64f

Please sign in to comment.