Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
... ... @@ -0,0 +1,74 @@
  1 +package org.codehaus.plexus.archiver;
  2 +
  3 +import java.io.IOException;
  4 +
  5 +import junit.framework.TestCase;
  6 +
  7 +public class AbstractArchiverTest extends TestCase
  8 +{
  9 + private AbstractArchiver archiver;
  10 +
  11 + protected void setUp() throws Exception
  12 + {
  13 + super.setUp();
  14 + this.archiver = new AbstractArchiver()
  15 + {
  16 + protected String getArchiveType()
  17 + {
  18 + throw new UnsupportedOperationException();
  19 + }
  20 +
  21 + protected void execute() throws ArchiverException, IOException
  22 + {
  23 + throw new UnsupportedOperationException();
  24 + }
  25 +
  26 + protected void close() throws IOException
  27 + {
  28 + throw new UnsupportedOperationException();
  29 + }
  30 + };
  31 + }
  32 +
  33 + public void testModesAndOverridesAreUnsetByDefault()
  34 + {
  35 + assertEquals(-1, archiver.getDefaultFileMode());
  36 + assertEquals(-1, archiver.getOverrideFileMode());
  37 +
  38 + assertEquals(-1, archiver.getDefaultDirectoryMode());
  39 + assertEquals(-1, archiver.getOverrideDirectoryMode());
  40 + }
  41 +
  42 + public void testWhenUnsetModeUsesDefault()
  43 + {
  44 + assertEquals(Archiver.DEFAULT_FILE_MODE, archiver.getFileMode());
  45 + assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDirectoryMode());
  46 + }
  47 +
  48 + public void testSetModeIsUsedWithFlagsForType()
  49 + {
  50 + archiver.setFileMode(0400);
  51 + assertEquals(0100400, archiver.getFileMode());
  52 +
  53 + archiver.setDirectoryMode(0600);
  54 + assertEquals(040600, archiver.getDirectoryMode());
  55 + }
  56 +
  57 + public void testSetDefaultIncludesFlagsForType()
  58 + {
  59 + archiver.setDefaultFileMode(0400);
  60 + assertEquals(0100400, archiver.getDefaultFileMode());
  61 +
  62 + archiver.setDefaultDirectoryMode(0600);
  63 + assertEquals(040600, archiver.getDefaultDirectoryMode());
  64 + }
  65 +
  66 + public void testDefaultIsUsedWhenModeIsUnset()
  67 + {
  68 + archiver.setDefaultFileMode(0400);
  69 + assertEquals(0100400, archiver.getFileMode());
  70 +
  71 + archiver.setDefaultDirectoryMode(0600);
  72 + assertEquals(040600, archiver.getDirectoryMode());
  73 + }
  74 +}

0 comments on commit 146b64f

Please sign in to comment.
Something went wrong with that request. Please try again.