This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch MWAR-453-cleanup in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git
commit d5e8b3efeafa72ae717d12994c3208f43bde3714 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Thu May 19 02:34:51 2022 +0200 [MWAR-453] Code cleanup, upgrade deps to Java 8 --- pom.xml | 8 +- src/it/MWAR-427_update-without-clean/pom.xml | 6 +- src/it/MWAR-441/pom.xml | 6 +- .../apache/maven/plugins/war/AbstractWarMojo.java | 9 +- .../java/org/apache/maven/plugins/war/Overlay.java | 18 +-- .../java/org/apache/maven/plugins/war/WarMojo.java | 16 +-- .../war/packaging/AbstractWarPackagingTask.java | 1 - .../war/packaging/WarProjectPackagingTask.java | 4 +- .../plugins/war/AbstractWarExplodedMojoTest.java | 15 +-- .../maven/plugins/war/AbstractWarMojoTest.java | 5 +- .../plugins/war/WarExplodedMojoFilteringTest.java | 8 +- .../maven/plugins/war/WarExplodedMojoTest.java | 140 ++++++++++----------- .../maven/plugins/war/WarInPlaceMojoTest.java | 6 +- .../org/apache/maven/plugins/war/WarMojoTest.java | 1 - .../apache/maven/plugins/war/WarOverlaysTest.java | 12 +- .../plugins/war/overlay/OverlayManagerTest.java | 5 +- .../war/stub/MavenProject4CopyConstructor.java | 3 - .../plugins/war/stub/MavenProjectBasicStub.java | 1 - .../maven/plugins/war/stub/ZipArtifactStub.java | 15 --- 19 files changed, 117 insertions(+), 162 deletions(-) diff --git a/pom.xml b/pom.xml index 7634a01..91ed99c 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ </distributionManagement> <properties> - <mavenArchiverVersion>3.5.1</mavenArchiverVersion> + <mavenArchiverVersion>3.5.2</mavenArchiverVersion> <mavenFilteringVersion>3.2.0</mavenFilteringVersion> <mavenVersion>3.2.5</mavenVersion> <javaVersion>8</javaVersion> @@ -140,12 +140,12 @@ <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>2.6</version> + <version>2.11.0</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-archiver</artifactId> - <version>4.2.5</version> + <version>4.2.7</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> @@ -155,7 +155,7 @@ <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.3.0</version> + <version>3.4.1</version> </dependency> <dependency> <groupId>org.apache.maven.shared</groupId> diff --git a/src/it/MWAR-427_update-without-clean/pom.xml b/src/it/MWAR-427_update-without-clean/pom.xml index 07b1e17..fb13ddc 100644 --- a/src/it/MWAR-427_update-without-clean/pom.xml +++ b/src/it/MWAR-427_update-without-clean/pom.xml @@ -44,7 +44,7 @@ under the License. <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>groovy-maven-plugin</artifactId> - <version>2.0</version> + <version>2.1.1</version> <configuration> <source> def fileToModify = new File(project.basedir, 'pom.xml') @@ -61,8 +61,8 @@ under the License. <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>2.4.21</version> + <artifactId>groovy</artifactId> + <version>3.0.10</version> </dependency> </dependencies> </plugin> diff --git a/src/it/MWAR-441/pom.xml b/src/it/MWAR-441/pom.xml index 261c77c..b63c3d9 100644 --- a/src/it/MWAR-441/pom.xml +++ b/src/it/MWAR-441/pom.xml @@ -45,7 +45,7 @@ under the License. <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>groovy-maven-plugin</artifactId> - <version>2.0</version> + <version>2.1.1</version> <configuration> <source> def fileToModify = new File(project.basedir, 'pom.xml') @@ -62,8 +62,8 @@ under the License. <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>2.4.21</version> + <artifactId>groovy</artifactId> + <version>3.0.10</version> </dependency> </dependencies> </plugin> diff --git a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java index 24a8eb5..2f0c751 100644 --- a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java +++ b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -417,7 +418,7 @@ public abstract class AbstractWarMojo excludeList.add( "**/" + META_INF + "/" + containerConfigXML.getName() ); } - return excludeList.toArray( new String[excludeList.size()] ); + return excludeList.toArray( new String[0] ); } /** @@ -427,7 +428,7 @@ public abstract class AbstractWarMojo */ protected String[] getIncludes() { - return StringUtils.split( StringUtils.defaultString( warSourceIncludes ), "," ); + return StringUtils.split( Objects.toString( warSourceIncludes, "" ), "," ); } /** @@ -437,7 +438,7 @@ public abstract class AbstractWarMojo */ protected String[] getDependentWarExcludes() { - return StringUtils.split( StringUtils.defaultString( dependentWarExcludes ), "," ); + return StringUtils.split( Objects.toString( dependentWarExcludes, "" ), "," ); } /** @@ -447,7 +448,7 @@ public abstract class AbstractWarMojo */ protected String[] getDependentWarIncludes() { - return StringUtils.split( StringUtils.defaultString( dependentWarIncludes ), "," ); + return StringUtils.split( Objects.toString( dependentWarIncludes, "" ), "," ); } /** diff --git a/src/main/java/org/apache/maven/plugins/war/Overlay.java b/src/main/java/org/apache/maven/plugins/war/Overlay.java index c42f1c7..e705df2 100644 --- a/src/main/java/org/apache/maven/plugins/war/Overlay.java +++ b/src/main/java/org/apache/maven/plugins/war/Overlay.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.Artifact; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; /** * <p> @@ -356,29 +357,20 @@ public class Overlay @Override public int hashCode() { - int result; - result = ( getId() != null ? getId().hashCode() : 0 ); - result = 31 * result + ( includes != null ? includes.hashCode() : 0 ); - result = 31 * result + ( excludes != null ? excludes.hashCode() : 0 ); - return result; + return Objects.hash( getId(), Arrays.hashCode( includes ), Arrays.hashCode( excludes ) ); } private String[] parse( String s ) { final List<String> result = new ArrayList<>(); - if ( s == null ) + if ( s != null ) { - return result.toArray( new String[result.size()] ); - } - else - { - String[] tokens = s.split( "," ); - for ( String token : tokens ) + for ( String token : s.split( "," ) ) { result.add( token.trim() ); } - return result.toArray( new String[result.size()] ); } + return result.toArray( new String[0] ); } } diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java index 97939f9..474f446 100644 --- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java +++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java @@ -305,7 +305,7 @@ public class WarMojo * @throws MalformedURLException if the path to a dependency file can't be transformed to a URL. */ private boolean isProjectUsingAtLeastServlet30() - throws DependencyResolutionRequiredException, MalformedURLException + throws DependencyResolutionRequiredException, IOException { List<String> classpathElements = getProject().getCompileClasspathElements(); URL[] urls = new URL[classpathElements.size()]; @@ -313,22 +313,10 @@ public class WarMojo { urls[i] = new File( classpathElements.get( i ) ).toURI().toURL(); } - URLClassLoader loader = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() ); - try + try ( URLClassLoader loader = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() ) ) { return hasWebServletAnnotationClassInClasspath( loader ); } - finally - { - try - { - loader.close(); - } - catch ( IOException ex ) - { - // ignore - } - } } private static boolean hasWebServletAnnotationClassInClasspath( ClassLoader loader ) diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java index 171275f..b2df33b 100644 --- a/src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java +++ b/src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java @@ -180,7 +180,6 @@ public abstract class AbstractWarPackagingTask public void refused( String ownerId, String targetFilename, String actualOwnerId ) - throws IOException { context.getLog().debug( " - " + targetFilename diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java index 5993706..b70947d 100644 --- a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java +++ b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java @@ -360,7 +360,7 @@ public class WarProjectPackagingTask scanner.setBasedir( resource.getDirectory() ); if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() ) { - scanner.setIncludes( resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) ); + scanner.setIncludes( resource.getIncludes().toArray( new String[0] ) ); } else { @@ -368,7 +368,7 @@ public class WarProjectPackagingTask } if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() ) { - scanner.setExcludes( resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) ); + scanner.setExcludes( resource.getExcludes().toArray( new String[0] ) ); } scanner.addDefaultExcludes(); diff --git a/src/test/java/org/apache/maven/plugins/war/AbstractWarExplodedMojoTest.java b/src/test/java/org/apache/maven/plugins/war/AbstractWarExplodedMojoTest.java index f140940..0a86fdc 100644 --- a/src/test/java/org/apache/maven/plugins/war/AbstractWarExplodedMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/AbstractWarExplodedMojoTest.java @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.Objects; /** * @author Stephane Nicoll @@ -156,8 +157,8 @@ public abstract class AbstractWarExplodedMojoTest File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" ); File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" ); - assertTrue( "source file not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source file not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source file not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source file not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); final List<File> content = new ArrayList<>(); content.add( expectedWebSourceFile ); @@ -175,7 +176,7 @@ public abstract class AbstractWarExplodedMojoTest protected List<File> assertWebXml( File webAppDirectory ) { File expectedWEBXMLFile = new File( webAppDirectory, "WEB-INF/web.xml" ); - assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() ); + assertTrue( "web xml not found: " + expectedWEBXMLFile, expectedWEBXMLFile.exists() ); final List<File> content = new ArrayList<>(); content.add( expectedWEBXMLFile ); @@ -199,11 +200,11 @@ public abstract class AbstractWarExplodedMojoTest final File expectedFile = new File( webAppDirectory, filePath ); if ( customMessage != null ) { - assertTrue( customMessage + " - " + expectedFile.toString(), expectedFile.exists() ); + assertTrue( customMessage + " - " + expectedFile, expectedFile.exists() ); } else { - assertTrue( "source file not found: " + expectedFile.toString(), expectedFile.exists() ); + assertTrue( "source file not found: " + expectedFile, expectedFile.exists() ); } content.add( expectedFile ); } @@ -250,7 +251,7 @@ public abstract class AbstractWarExplodedMojoTest { final File[] files = dir.listFiles(); - for ( File file : files ) + for ( File file : Objects.requireNonNull( files ) ) { // Add the file if the filter is ok with it if ( filter.accept( file ) ) @@ -267,7 +268,7 @@ public abstract class AbstractWarExplodedMojoTest } } - class FileFilterImpl + static class FileFilterImpl implements FileFilter { diff --git a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java index 3de518f..2cb2fbc 100644 --- a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java @@ -48,8 +48,7 @@ public abstract class AbstractWarMojoTest protected static final String MANIFEST_PATH = "META-INF" + File.separator + "MANIFEST.MF"; - protected abstract File getTestDirectory() - throws Exception; + protected abstract File getTestDirectory(); /** * initialize required parameters @@ -180,7 +179,7 @@ public abstract class AbstractWarMojoTest { if ( !dir.exists() ) { - assertTrue( "can not create test dir: " + dir.toString(), dir.mkdirs() ); + assertTrue( "can not create test dir: " + dir, dir.mkdirs() ); } } diff --git a/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoFilteringTest.java b/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoFilteringTest.java index 9997f4d..757358c 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoFilteringTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoFilteringTest.java @@ -99,10 +99,10 @@ public class WarExplodedMojoFilteringTest File expectedResourceFile = new File( webAppDirectory, "custom-setting.cfg" ); File expectedResourceWDirFile = new File( webAppDirectory, "custom-config/custom-setting.cfg" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "resource file not found:" + expectedResourceFile.toString(), expectedResourceFile.exists() ); - assertTrue( "resource file with dir not found:" + expectedResourceWDirFile.toString(), + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "resource file not found:" + expectedResourceFile, expectedResourceFile.exists() ); + assertTrue( "resource file with dir not found:" + expectedResourceWDirFile, expectedResourceWDirFile.exists() ); // validate filtered file diff --git a/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoTest.java index 45faf0f..3f027e3 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarExplodedMojoTest.java @@ -91,8 +91,8 @@ public class WarExplodedMojoTest File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" ); File expectedMETAINFDir = new File( webAppDirectory, "META-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); assertTrue( "resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists() ); assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); @@ -135,8 +135,8 @@ public class WarExplodedMojoTest File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" ); File expectedMETAINFDir = new File( webAppDirectory, "META-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); assertTrue( "resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists() ); assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); @@ -172,9 +172,9 @@ public class WarExplodedMojoTest File expectedWEBXMLFile = new File( webAppDirectory, "WEB-INF/web.xml" ); File expectedMETAINFDir = new File( webAppDirectory, "META-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "WEB XML not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "WEB XML not found: " + expectedWEBXMLFile, expectedWEBXMLFile.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); assertEquals( "WEB XML not correct", mojo.getWebXml().toString(), FileUtils.fileRead( expectedWEBXMLFile ) ); @@ -210,10 +210,10 @@ public class WarExplodedMojoTest File expectedContainerConfigXMLFile = new File( webAppDirectory, "META-INF/config.xml" ); File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() ); - assertTrue( "Container Config XML not found:" + expectedContainerConfigXMLFile.toString(), + assertTrue( "Container Config XML not found:" + expectedContainerConfigXMLFile, expectedContainerConfigXMLFile.exists() ); // house keeping @@ -256,11 +256,11 @@ public class WarExplodedMojoTest File expectedWEBXMLFile = new File( webAppDirectory, "WEB-INF/web.xml" ); File expectedWARFile = new File( webAppDirectory, "/org/sample/company/test.jsp" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); // check simple.war in the unit test dir under resources to verify the list of files - assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() ); - assertTrue( "war file not found: " + expectedWARFile.toString(), expectedWARFile.exists() ); + assertTrue( "web xml not found: " + expectedWEBXMLFile, expectedWEBXMLFile.exists() ); + assertTrue( "war file not found: " + expectedWARFile, expectedWARFile.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -300,7 +300,7 @@ public class WarExplodedMojoTest // validate operation File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" ); - assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() ); + assertTrue( "file not found: " + expectedFile, expectedFile.exists() ); assertEquals( "file incorrect", simpleJSP.toString(), FileUtils.fileRead( expectedFile ) ); // check when the merged war file is newer - so set an old time on the local file @@ -313,7 +313,7 @@ public class WarExplodedMojoTest setVariableValueToObject( mojo, "workDirectory", workDirectory ); mojo.execute(); - assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() ); + assertTrue( "file not found: " + expectedFile, expectedFile.exists() ); assertEquals( "file incorrect", simpleJSP.toString(), FileUtils.fileRead( expectedFile ) ); // house keeping @@ -404,9 +404,9 @@ public class WarExplodedMojoTest File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" ); // File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "ejb artifact not found: " + expectedEJBArtifact, expectedEJBArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -440,9 +440,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/lib/jarartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact, expectedJarArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -478,9 +478,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbclientartifact-0.0-Test-client.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "ejb artifact not found: " + expectedEJBArtifact, expectedEJBArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -516,9 +516,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedTLDArtifact = new File( webAppDirectory, "WEB-INF/tld/tldartifact-0.0-Test.tld" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "tld artifact not found: " + expectedTLDArtifact.toString(), expectedTLDArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "tld artifact not found: " + expectedTLDArtifact, expectedTLDArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -554,9 +554,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedPARArtifact = new File( webAppDirectory, "WEB-INF/lib/parartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "par artifact not found: " + expectedPARArtifact.toString(), expectedPARArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "par artifact not found: " + expectedPARArtifact, expectedPARArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -594,9 +594,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/services/aarartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact, expectedJarArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -634,9 +634,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/modules/marartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact, expectedJarArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -674,9 +674,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/extensions/xarartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact, expectedJarArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -718,10 +718,10 @@ public class WarExplodedMojoTest File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact-0.0-Test.jar" ); File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact-0.0-Test.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() ); - assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "ejb artifact not found: " + expectedEJBArtifact, expectedEJBArtifact.exists() ); + assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact, expectedEJBDupArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -770,10 +770,10 @@ public class WarExplodedMojoTest File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" ); File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test-classifier.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() ); - assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "ejb artifact not found: " + expectedEJBArtifact, expectedEJBArtifact.exists() ); + assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact, expectedEJBDupArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -805,9 +805,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedClass = new File( webAppDirectory, "WEB-INF/classes/sample-servlet.class" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "classes not found: " + expectedClass.toString(), expectedClass.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "classes not found: " + expectedClass, expectedClass.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -840,9 +840,9 @@ public class WarExplodedMojoTest File expectedWEBXMLDir = new File( webAppDirectory, "WEB-INF" ); File expectedMETAINFDir = new File( webAppDirectory, "META-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertFalse( "source files found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "WEB XML not found: " + expectedWEBXMLDir.toString(), expectedWEBXMLDir.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertFalse( "source files found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "WEB XML not found: " + expectedWEBXMLDir, expectedWEBXMLDir.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); // house keeping @@ -888,13 +888,13 @@ public class WarExplodedMojoTest File expectedIncludedWARFile = new File( webAppDirectory, "/org/sample/company/testInclude.jsp" ); File expectedExcludedWarfile = new File( webAppDirectory, "/org/sample/companyExclude/test.jsp" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); // check include-exclude.war in the unit test dir under resources to verify the list of files - assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() ); - assertFalse( "manifest file found: " + expectedManifestFile.toString(), expectedManifestFile.exists() ); - assertTrue( "war file not found: " + expectedIncludedWARFile.toString(), expectedIncludedWARFile.exists() ); - assertFalse( "war file not found: " + expectedExcludedWarfile.toString(), expectedExcludedWarfile.exists() ); + assertTrue( "web xml not found: " + expectedWEBXMLFile, expectedWEBXMLFile.exists() ); + assertFalse( "manifest file found: " + expectedManifestFile, expectedManifestFile.exists() ); + assertTrue( "war file not found: " + expectedIncludedWARFile, expectedIncludedWARFile.exists() ); + assertFalse( "war file not found: " + expectedExcludedWarfile, expectedExcludedWarfile.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -932,14 +932,14 @@ public class WarExplodedMojoTest File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" ); File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); // 1st phase destination is older than source // destination starts with a value of error replaced with a blank source - assertNotEquals( "source files not updated with new copy: " + expectedWebSourceFile.toString(), + assertNotEquals( "source files not updated with new copy: " + expectedWebSourceFile, "error", FileUtils.fileRead( expectedWebSourceFile ) ); // TODO: uncomment when lastModified problem is resolved @@ -991,9 +991,9 @@ public class WarExplodedMojoTest // final name form is <artifactId>-<version>.<type> File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/lib/jarartifact.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact, expectedJarArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); @@ -1036,10 +1036,10 @@ public class WarExplodedMojoTest File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact.jar" ); File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact.jar" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); - assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() ); - assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); + assertTrue( "ejb artifact not found: " + expectedEJBArtifact, expectedEJBArtifact.exists() ); + assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact, expectedEJBDupArtifact.exists() ); // house keeping expectedWebSourceFile.delete(); diff --git a/src/test/java/org/apache/maven/plugins/war/WarInPlaceMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarInPlaceMojoTest.java index 8cf4557..33fe676 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarInPlaceMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarInPlaceMojoTest.java @@ -32,7 +32,6 @@ public class WarInPlaceMojoTest + "/target/test-classes/unit/warexplodedinplacemojo/plugin-config.xml"; protected File getTestDirectory() - throws Exception { return new File( getBasedir(), "target/test-classes/unit/warexplodedinplacemojo/test-dir" ); } @@ -49,7 +48,6 @@ public class WarInPlaceMojoTest } public void testEnvironment() - throws Exception { // see setUp } @@ -81,8 +79,8 @@ public class WarInPlaceMojoTest File expectedWEBINFDir = new File( webAppSource, "WEB-INF" ); File expectedMETAINFDir = new File( webAppSource, "META-INF" ); - assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); - assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "source files not found: " + expectedWebSourceFile, expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File, expectedWebSource2File.exists() ); assertTrue( "resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists() ); assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() ); assertTrue( "META-INF not found", expectedMETAINFDir.exists() ); diff --git a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java index 84a8ce8..91a5d2e 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java @@ -62,7 +62,6 @@ public class WarMojoTest } public void testEnvironment() - throws Exception { // see setup } diff --git a/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java b/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java index d944e6f..c4dd88e 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java @@ -59,7 +59,6 @@ public class WarOverlaysTest } public void testEnvironment() - throws Exception { // see setup } @@ -111,7 +110,7 @@ public class WarOverlaysTest assertOverlayedFile( webAppDirectory, "overlay-one", "login.jsp" ); // Ok now check that there is no more files/directories - final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } ); + final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] {MANIFEST_PATH} ); assertWebAppContent( webAppDirectory, assertedFiles, filter ); } finally @@ -149,7 +148,7 @@ public class WarOverlaysTest assertOverlayedFile( webAppDirectory, "overlay-two", "admin.jsp" ); // Ok now check that there is no more files/directories - final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } ); + final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] {MANIFEST_PATH} ); assertWebAppContent( webAppDirectory, assertedFiles, filter ); } finally @@ -293,7 +292,7 @@ public class WarOverlaysTest assertOverlayedFile( webAppDirectory, "overlay-full-1", "WEB-INF/lib/c.jar" ); // Ok now check that there is no more files/directories - final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } ); + final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] {MANIFEST_PATH} ); assertWebAppContent( webAppDirectory, assertedFiles, filter ); } finally @@ -362,7 +361,7 @@ public class WarOverlaysTest assertOverlayedFile( webAppDirectory, "overlay-full-2", "WEB-INF/lib/c.jar" ); // Ok now check that there is no more files/directories - final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } ); + final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] {MANIFEST_PATH} ); assertWebAppContent( webAppDirectory, assertedFiles, filter ); } finally @@ -432,7 +431,7 @@ public class WarOverlaysTest assertOverlayedFile( webAppDirectory, "overlay-full-2", "WEB-INF/lib/c.jar" ); // Ok now check that there is no more files/directories - final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } ); + final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] {MANIFEST_PATH} ); assertWebAppContent( webAppDirectory, assertedFiles, filter ); } finally @@ -487,7 +486,6 @@ public class WarOverlaysTest } protected ArtifactStub generateSimpleWarArtifactStub( String id ) - throws Exception { return buildWarOverlayStub( id ); } diff --git a/src/test/java/org/apache/maven/plugins/war/overlay/OverlayManagerTest.java b/src/test/java/org/apache/maven/plugins/war/overlay/OverlayManagerTest.java index 59ed9e0..0f5da10 100644 --- a/src/test/java/org/apache/maven/plugins/war/overlay/OverlayManagerTest.java +++ b/src/test/java/org/apache/maven/plugins/war/overlay/OverlayManagerTest.java @@ -72,12 +72,11 @@ public class OverlayManagerTest try { - final Overlay overlay = currentProjectOverlay; OverlayManager manager = new OverlayManager( overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, - overlay ); + currentProjectOverlay ); assertNotNull( manager.getOverlays() ); assertEquals( 2, manager.getOverlays().size() ); - assertEquals( overlay, manager.getOverlays().get( 0 ) ); + assertEquals( currentProjectOverlay, manager.getOverlays().get( 0 ) ); assertEquals( new DefaultOverlay( first ), manager.getOverlays().get( 1 ) ); } catch ( InvalidOverlayConfigurationException e ) diff --git a/src/test/java/org/apache/maven/plugins/war/stub/MavenProject4CopyConstructor.java b/src/test/java/org/apache/maven/plugins/war/stub/MavenProject4CopyConstructor.java index 831ddba..0d50ce9 100644 --- a/src/test/java/org/apache/maven/plugins/war/stub/MavenProject4CopyConstructor.java +++ b/src/test/java/org/apache/maven/plugins/war/stub/MavenProject4CopyConstructor.java @@ -25,9 +25,6 @@ import java.util.LinkedList; import java.util.List; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.model.Profile; -import org.apache.maven.project.MavenProject; public class MavenProject4CopyConstructor extends MavenProjectBasicStub diff --git a/src/test/java/org/apache/maven/plugins/war/stub/MavenProjectBasicStub.java b/src/test/java/org/apache/maven/plugins/war/stub/MavenProjectBasicStub.java index 7b2ac30..f720eed 100644 --- a/src/test/java/org/apache/maven/plugins/war/stub/MavenProjectBasicStub.java +++ b/src/test/java/org/apache/maven/plugins/war/stub/MavenProjectBasicStub.java @@ -40,7 +40,6 @@ public class MavenProjectBasicStub protected Properties properties; public MavenProjectBasicStub() - throws Exception { super( new ModelStub() ); properties = new Properties(); diff --git a/src/test/java/org/apache/maven/plugins/war/stub/ZipArtifactStub.java b/src/test/java/org/apache/maven/plugins/war/stub/ZipArtifactStub.java index 50c01d9..2e5d84b 100644 --- a/src/test/java/org/apache/maven/plugins/war/stub/ZipArtifactStub.java +++ b/src/test/java/org/apache/maven/plugins/war/stub/ZipArtifactStub.java @@ -45,26 +45,11 @@ public class ZipArtifactStub return null; } - public ArtifactHandler getArtifactHandler() - { - return super.getArtifactHandler(); - } - - public String getScope() - { - return super.getScope(); - } - public String getVersion() { return "1.0"; } - public boolean isOptional() - { - return super.isOptional(); - } - public File getFile() { return this.zip;
