Skip to content

Commit 73c75f4

Browse files
o Updated to reformat all test source files to a common code style.
o Updated to add missing '@OverRide' annotations. o Updated to organize imports.
1 parent 06f6177 commit 73c75f4

37 files changed

+971
-792
lines changed
Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,92 @@
11
package org.codehaus.plexus.archiver;
22

33
import java.io.IOException;
4-
54
import junit.framework.TestCase;
65

76
public class AbstractArchiverTest extends TestCase
87
{
8+
99
private AbstractArchiver archiver;
1010

11+
@Override
1112
protected void setUp() throws Exception
1213
{
1314
super.setUp();
1415
this.archiver = new AbstractArchiver()
1516
{
17+
18+
@Override
1619
protected String getArchiveType()
1720
{
1821
throw new UnsupportedOperationException();
1922
}
2023

24+
@Override
2125
protected void execute() throws ArchiverException, IOException
2226
{
2327
throw new UnsupportedOperationException();
2428
}
2529

30+
@Override
2631
protected void close() throws IOException
2732
{
2833
throw new UnsupportedOperationException();
2934
}
35+
3036
};
3137
}
3238

3339
public void testModesAndOverridesAreUnsetByDefault()
3440
{
35-
assertEquals(-1, archiver.getDefaultFileMode());
36-
assertEquals(-1, archiver.getOverrideFileMode());
41+
assertEquals( -1, archiver.getDefaultFileMode() );
42+
assertEquals( -1, archiver.getOverrideFileMode() );
3743

38-
assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDefaultDirectoryMode());
39-
assertEquals(-1, archiver.getOverrideDirectoryMode());
44+
assertEquals( Archiver.DEFAULT_DIR_MODE, archiver.getDefaultDirectoryMode() );
45+
assertEquals( -1, archiver.getOverrideDirectoryMode() );
4046
}
4147

4248
public void testWhenUnsetModeUsesDefault()
4349
{
44-
assertEquals(Archiver.DEFAULT_FILE_MODE, archiver.getFileMode());
45-
assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDirectoryMode());
50+
assertEquals( Archiver.DEFAULT_FILE_MODE, archiver.getFileMode() );
51+
assertEquals( Archiver.DEFAULT_DIR_MODE, archiver.getDirectoryMode() );
4652
}
4753

4854
public void testSetModeIsUsedWithFlagsForType()
4955
{
50-
archiver.setFileMode(0400);
51-
assertEquals(0100400, archiver.getFileMode());
56+
archiver.setFileMode( 0400 );
57+
assertEquals( 0100400, archiver.getFileMode() );
5258

53-
archiver.setDirectoryMode(0600);
54-
assertEquals(040600, archiver.getDirectoryMode());
59+
archiver.setDirectoryMode( 0600 );
60+
assertEquals( 040600, archiver.getDirectoryMode() );
5561
}
5662

5763
public void testSetDefaultIncludesFlagsForType()
5864
{
59-
archiver.setDefaultFileMode(0400);
60-
assertEquals(0100400, archiver.getDefaultFileMode());
65+
archiver.setDefaultFileMode( 0400 );
66+
assertEquals( 0100400, archiver.getDefaultFileMode() );
6167

62-
archiver.setDefaultDirectoryMode(0600);
63-
assertEquals(040600, archiver.getDefaultDirectoryMode());
68+
archiver.setDefaultDirectoryMode( 0600 );
69+
assertEquals( 040600, archiver.getDefaultDirectoryMode() );
6470
}
6571

6672
public void testDefaultIsUsedWhenModeIsUnset()
6773
{
68-
archiver.setDefaultFileMode(0400);
69-
assertEquals(0100400, archiver.getFileMode());
74+
archiver.setDefaultFileMode( 0400 );
75+
assertEquals( 0100400, archiver.getFileMode() );
7076

71-
archiver.setDefaultDirectoryMode(0600);
72-
assertEquals(040600, archiver.getDirectoryMode());
77+
archiver.setDefaultDirectoryMode( 0600 );
78+
assertEquals( 040600, archiver.getDirectoryMode() );
7379
}
7480

7581
public void testOverridesCanBeReset()
7682
{
77-
archiver.setFileMode(0400);
78-
archiver.setFileMode(-1);
79-
assertEquals(-1, archiver.getOverrideFileMode());
83+
archiver.setFileMode( 0400 );
84+
archiver.setFileMode( -1 );
85+
assertEquals( -1, archiver.getOverrideFileMode() );
8086

81-
archiver.setDirectoryMode(0600);
82-
archiver.setDirectoryMode(-1);
83-
assertEquals(-1, archiver.getOverrideDirectoryMode());
87+
archiver.setDirectoryMode( 0600 );
88+
archiver.setDirectoryMode( -1 );
89+
assertEquals( -1, archiver.getOverrideDirectoryMode() );
8490
}
91+
8592
}
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package org.codehaus.plexus.archiver;
2-
31
/*
42
* The MIT License
53
*
@@ -23,62 +21,67 @@
2321
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2422
* SOFTWARE.
2523
*/
24+
package org.codehaus.plexus.archiver;
2625

2726
import java.io.File;
28-
2927
import org.codehaus.plexus.PlexusTestCase;
3028
import org.codehaus.plexus.util.FileUtils;
29+
3130
/**
32-
* Base abstract class that all the test-cases for different archivers
31+
* Base abstract class that all the test-cases for different archivers
3332
* extend so that they can use its helpful methids.
34-
*
35-
*
3633
*/
3734
public abstract class BasePlexusArchiverTest extends PlexusTestCase
3835
{
36+
3937
/**
4038
* Ensure that when a new file is created at the specified location that the timestamp of
4139
* that file will be greater than the one specified as a reference.
42-
*
40+
*
4341
* Warning: Runs in a busy loop creating a file until the output file is newer than the reference timestamp.
4442
* This should be better than sleeping for a race condition time out value.
45-
*
43+
*
4644
* @param outputFile the file to be created
4745
* @param timestampReference the created file will have a newer timestamp than this reference timestamp.
46+
*
4847
* @throws Exception failures
4948
*/
5049
protected void waitUntilNewTimestamp( File outputFile, long timestampReference ) throws Exception
5150
{
5251
File tmpFile = File.createTempFile( "ZipArchiverTest.waitUntilNewTimestamp", null );
5352
// slurp the file into a temp file and then copy the temp back over the top until it is newer.
5453
FileUtils.copyFile( outputFile, tmpFile );
55-
56-
FileUtils.copyFile( tmpFile, outputFile );
54+
55+
FileUtils.copyFile( tmpFile, outputFile );
5756
while ( timestampReference >= outputFile.lastModified() )
5857
{
5958
FileUtils.copyFile( tmpFile, outputFile );
6059
Thread.yield();
6160
}
62-
61+
6362
tmpFile.delete();
6463
}
65-
64+
6665
/**
6766
* Base method for all the Archivers to create an archiver.
68-
*
67+
*
6968
* @param format
69+
*
7070
* @return
71+
*
7172
* @throws Exception
7273
*/
73-
protected Archiver createArchiver(String format) throws Exception {
74-
75-
final File pomFile = new File("pom.xml");
76-
final File rarFile = new File( "target/output/pom.xml."+format );
77-
74+
protected Archiver createArchiver( String format ) throws Exception
75+
{
76+
77+
final File pomFile = new File( "pom.xml" );
78+
final File rarFile = new File( "target/output/pom.xml." + format );
79+
7880
Archiver archiver = (Archiver) lookup( Archiver.ROLE, format );
7981
archiver.setDestFile( rarFile );
8082
archiver.addFile( pomFile, "pom.xml" );
8183

8284
return archiver;
8385
}
86+
8487
}

src/test/java/org/codehaus/plexus/archiver/DotDirectiveArchiveFinalizerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package org.codehaus.plexus.archiver;
22

3-
import org.codehaus.plexus.PlexusTestCase;
4-
import org.codehaus.plexus.archiver.jar.JarArchiver;
5-
63
import java.io.File;
74
import java.util.jar.JarFile;
5+
import org.codehaus.plexus.PlexusTestCase;
6+
import org.codehaus.plexus.archiver.jar.JarArchiver;
87

9-
/** @author Jason van Zyl */
8+
/**
9+
* @author Jason van Zyl
10+
*/
1011
public class DotDirectiveArchiveFinalizerTest
1112
extends PlexusTestCase
1213
{
14+
1315
public void testDotDirectiveArchiveFinalizer()
1416
throws Exception
1517
{

src/test/java/org/codehaus/plexus/archiver/DuplicateFilesTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package org.codehaus.plexus.archiver;
22

3+
import java.io.BufferedInputStream;
4+
import java.io.BufferedReader;
5+
import java.io.File;
6+
import java.io.FileInputStream;
7+
import java.io.FileReader;
8+
import java.util.Enumeration;
39
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
410
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
511
import org.codehaus.plexus.PlexusTestCase;
@@ -8,19 +14,13 @@
814
import org.codehaus.plexus.logging.Logger;
915
import org.codehaus.plexus.util.FileUtils;
1016

11-
import java.io.File;
12-
import java.io.FileReader;
13-
import java.io.BufferedReader;
14-
import java.io.BufferedInputStream;
15-
import java.io.FileInputStream;
16-
import java.util.Enumeration;
17-
1817
/**
1918
* @author Erik Engstrom
2019
*/
2120
public class DuplicateFilesTest
2221
extends PlexusTestCase
2322
{
23+
2424
private static final File file1 = getTestFile( "src/test/resources/group-writable/foo.txt" );
2525

2626
private static final File file2 = getTestFile( "src/test/resources/world-writable/foo.txt" );
@@ -42,7 +42,9 @@ public void testZipArchiver()
4242

4343
File archive = createArchive( archiver, "zip" );
4444

45-
org.apache.commons.compress.archivers.zip.ZipFile zf = new org.apache.commons.compress.archivers.zip.ZipFile( archive );
45+
org.apache.commons.compress.archivers.zip.ZipFile zf =
46+
new org.apache.commons.compress.archivers.zip.ZipFile( archive );
47+
4648
Enumeration e = zf.getEntries();
4749
int entryCount = 0;
4850
while ( e.hasMoreElements() )
@@ -69,9 +71,9 @@ public void testTarArchiver()
6971
throws Exception
7072
{
7173
TarArchiver archiver = (TarArchiver) lookup( Archiver.ROLE, "tar" );
72-
archiver.setLongfile(TarLongFileMode.posix );
74+
archiver.setLongfile( TarLongFileMode.posix );
7375
archiver.setDuplicateBehavior( Archiver.DUPLICATES_SKIP );
74-
76+
7577
File archive = createArchive( archiver, "tar" );
7678
TarArchiveInputStream tis;
7779

@@ -145,4 +147,5 @@ private void testFinalFile( String path )
145147
reader.close();
146148
assertEquals( expectedFirstLine, firstLine );
147149
}
150+
148151
}

src/test/java/org/codehaus/plexus/archiver/EmptyDirectoryTest.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package org.codehaus.plexus.archiver;
2-
31
/*
42
* The MIT License
53
*
@@ -23,24 +21,24 @@
2321
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2422
* SOFTWARE.
2523
*/
24+
package org.codehaus.plexus.archiver;
2625

26+
import java.io.File;
2727
import org.codehaus.plexus.PlexusTestCase;
2828
import org.codehaus.plexus.archiver.tar.TarArchiver;
2929
import org.codehaus.plexus.archiver.tar.TarLongFileMode;
3030

31-
import java.io.File;
32-
3331
/**
3432
* @author Daniel Krisher
35-
*
3633
*/
3734
public class EmptyDirectoryTest
3835
extends PlexusTestCase
3936
{
37+
4038
public void testZipArchiver()
4139
throws Exception
4240
{
43-
testEmptyDirectory( "zip", (Archiver) lookup( Archiver.ROLE, "zip"));
41+
testEmptyDirectory( "zip", (Archiver) lookup( Archiver.ROLE, "zip" ) );
4442
}
4543

4644
public void testJarArchiver()
@@ -53,21 +51,17 @@ public void testJarArchiver()
5351
public void testTarArchiver()
5452
throws Exception
5553
{
56-
final TarArchiver tar = (TarArchiver) lookup(Archiver.ROLE, "tar");
57-
tar.setLongfile(TarLongFileMode.posix );
58-
testEmptyDirectory("tar", tar);
54+
final TarArchiver tar = (TarArchiver) lookup( Archiver.ROLE, "tar" );
55+
tar.setLongfile( TarLongFileMode.posix );
56+
testEmptyDirectory( "tar", tar );
5957
}
6058

61-
// ----------------------------------------------------------------------
62-
//
63-
// ----------------------------------------------------------------------
64-
65-
private void testEmptyDirectory(String role, Archiver archiver)
59+
private void testEmptyDirectory( String role, Archiver archiver )
6660
throws Exception
6761
{
6862

69-
// Should default to true...
70-
assertTrue(archiver.getIncludeEmptyDirs());
63+
// Should default to true...
64+
assertTrue( archiver.getIncludeEmptyDirs() );
7165

7266
// create an empty directory to store in the zip archive
7367
File emptyDir = getTestFile( "target/output/emptyTest/TmpEmptyDir" );
@@ -78,22 +72,21 @@ private void testEmptyDirectory(String role, Archiver archiver)
7872
emptyDir.delete();
7973
}
8074
emptyDir.mkdirs();
81-
archiver.addDirectory(emptyDir.getParentFile());
75+
archiver.addDirectory( emptyDir.getParentFile() );
8276

8377
File archive = getTestFile( "target/output/emptyDirArchive.zip" );
8478
if ( archive.exists() )
8579
{
8680
archive.delete();
8781
}
8882

89-
archiver.setDestFile(archive);
83+
archiver.setDestFile( archive );
9084
archiver.createArchive();
9185

9286
// delete the empty dir, we will extract it from the archive
9387
emptyDir.delete();
9488

9589
// Check the content of the archive by extracting it
96-
9790
UnArchiver unArchiver = (UnArchiver) lookup( UnArchiver.ROLE, role );
9891
unArchiver.setSourceFile( archive );
9992

@@ -103,4 +96,5 @@ private void testEmptyDirectory(String role, Archiver archiver)
10396
assertTrue( emptyDir.exists() );
10497
assertTrue( emptyDir.isDirectory() );
10598
}
99+
106100
}

0 commit comments

Comments
 (0)