You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2010/09/21 22:34:53 UTC
svn commit: r999612 [8/10] - in /maven/plugins/trunk/maven-assembly-plugin:
./ src/main/java/org/apache/maven/plugin/assembly/
src/main/java/org/apache/maven/plugin/assembly/archive/
src/main/java/org/apache/maven/plugin/assembly/archive/archiver/ src/...
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilterTest.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilterTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilterTest.java Tue Sep 21 20:34:50 2010
@@ -62,101 +62,110 @@ public class ComponentsXmlArchiverFileFi
{
private ComponentsXmlArchiverFileFilter filter;
- private TestFileManager fileManager = new TestFileManager( "componentsXmlArchiverFileFilter.test", ".zip" );
+ private final TestFileManager fileManager = new TestFileManager( "componentsXmlArchiverFileFilter.test", ".zip" );
+ @Override
public void setUp()
{
filter = new ComponentsXmlArchiverFileFilter();
}
- public void tearDown()
- throws IOException
+ @Override
+ public void tearDown() throws IOException
{
fileManager.cleanUp();
}
- public void testAddComponentsXml_ShouldAddComponentWithoutRoleHint()
- throws IOException, XmlPullParserException
+ public void testAddComponentsXml_ShouldAddComponentWithoutRoleHint() throws IOException, XmlPullParserException
{
- Reader reader = writeComponentsXml( Collections.singletonList( new ComponentDef( "role", null,
- "org.apache.maven.Impl" ) ) );
+ final Reader reader =
+ writeComponentsXml( Collections.singletonList( new ComponentDef( "role", null, "org.apache.maven.Impl" ) ) );
filter.addComponentsXml( reader );
assertFalse( filter.components.isEmpty() );
- Xpp3Dom componentDom = (Xpp3Dom) filter.components.get( "role" );
+ final Xpp3Dom componentDom = filter.components.get( "role" );
- assertEquals( "role", componentDom.getChild( "role" ).getValue() );
+ assertEquals( "role", componentDom.getChild( "role" )
+ .getValue() );
assertNull( componentDom.getChild( "role-hint" ) );
- assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" ).getValue() );
+ assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
+ .getValue() );
}
- public void testAddComponentsXml_ShouldAddComponentWithRoleHint()
- throws IOException, XmlPullParserException
+ public void testAddComponentsXml_ShouldAddComponentWithRoleHint() throws IOException, XmlPullParserException
{
- Reader reader = writeComponentsXml( Collections.singletonList( new ComponentDef( "role", "hint",
- "org.apache.maven.Impl" ) ) );
+ final Reader reader =
+ writeComponentsXml( Collections.singletonList( new ComponentDef( "role", "hint", "org.apache.maven.Impl" ) ) );
filter.addComponentsXml( reader );
assertFalse( filter.components.isEmpty() );
- Xpp3Dom componentDom = (Xpp3Dom) filter.components.get( "rolehint" );
+ final Xpp3Dom componentDom = filter.components.get( "rolehint" );
- assertEquals( "role", componentDom.getChild( "role" ).getValue() );
- assertEquals( "hint", componentDom.getChild( "role-hint" ).getValue() );
- assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" ).getValue() );
+ assertEquals( "role", componentDom.getChild( "role" )
+ .getValue() );
+ assertEquals( "hint", componentDom.getChild( "role-hint" )
+ .getValue() );
+ assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
+ .getValue() );
}
- public void testAddComponentsXml_ShouldAddTwoComponentsWithRoleHints()
- throws IOException, XmlPullParserException
+ public void testAddComponentsXml_ShouldAddTwoComponentsWithRoleHints() throws IOException, XmlPullParserException
{
- List defs = new ArrayList();
+ final List<ComponentDef> defs = new ArrayList<ComponentDef>();
defs.add( new ComponentDef( "role", "hint", "org.apache.maven.Impl" ) );
defs.add( new ComponentDef( "role", "hint2", "org.apache.maven.Impl2" ) );
- Reader reader = writeComponentsXml( defs );
+ final Reader reader = writeComponentsXml( defs );
filter.addComponentsXml( reader );
assertFalse( filter.components.isEmpty() );
- Xpp3Dom componentDom = (Xpp3Dom) filter.components.get( "rolehint" );
+ Xpp3Dom componentDom = filter.components.get( "rolehint" );
- assertEquals( "role", componentDom.getChild( "role" ).getValue() );
- assertEquals( "hint", componentDom.getChild( "role-hint" ).getValue() );
- assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" ).getValue() );
-
- componentDom = (Xpp3Dom) filter.components.get( "rolehint2" );
-
- assertEquals( "role", componentDom.getChild( "role" ).getValue() );
- assertEquals( "hint2", componentDom.getChild( "role-hint" ).getValue() );
- assertEquals( "org.apache.maven.Impl2", componentDom.getChild( "implementation" ).getValue() );
+ assertEquals( "role", componentDom.getChild( "role" )
+ .getValue() );
+ assertEquals( "hint", componentDom.getChild( "role-hint" )
+ .getValue() );
+ assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
+ .getValue() );
+
+ componentDom = filter.components.get( "rolehint2" );
+
+ assertEquals( "role", componentDom.getChild( "role" )
+ .getValue() );
+ assertEquals( "hint2", componentDom.getChild( "role-hint" )
+ .getValue() );
+ assertEquals( "org.apache.maven.Impl2", componentDom.getChild( "implementation" )
+ .getValue() );
}
public void testAddToArchive_ShouldWriteComponentWithoutHintToFile()
throws IOException, ArchiverException, JDOMException
{
- Xpp3Dom dom = createComponentDom( new ComponentDef( "role", null, "impl" ) );
+ final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", null, "impl" ) );
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<String, Xpp3Dom>();
filter.components.put( "role", dom );
- FileCatchingArchiver fca = new FileCatchingArchiver();
+ final FileCatchingArchiver fca = new FileCatchingArchiver();
filter.finalizeArchiveCreation( fca );
assertEquals( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH, fca.getDestFileName() );
- SAXBuilder builder = new SAXBuilder( false );
+ final SAXBuilder builder = new SAXBuilder( false );
- Document doc = builder.build( fca.getFile() );
+ final Document doc = builder.build( fca.getFile() );
- XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
- XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
- XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
+ final XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
+ final XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
+ final XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
assertEquals( "role", ( (Text) role.selectSingleNode( doc ) ).getText() );
assertNull( hint.selectSingleNode( doc ) );
@@ -166,64 +175,63 @@ public class ComponentsXmlArchiverFileFi
public void testAddToArchive_ShouldWriteComponentWithHintToFile()
throws IOException, ArchiverException, JDOMException
{
- Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
+ final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<String, Xpp3Dom>();
filter.components.put( "rolehint", dom );
- FileCatchingArchiver fca = new FileCatchingArchiver();
+ final FileCatchingArchiver fca = new FileCatchingArchiver();
filter.finalizeArchiveCreation( fca );
assertEquals( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH, fca.getDestFileName() );
- SAXBuilder builder = new SAXBuilder( false );
+ final SAXBuilder builder = new SAXBuilder( false );
- Document doc = builder.build( fca.getFile() );
+ final Document doc = builder.build( fca.getFile() );
- XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
- XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
- XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
+ final XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
+ final XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
+ final XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
assertEquals( "role", ( (Text) role.selectSingleNode( doc ) ).getText() );
assertEquals( "hint", ( (Text) hint.selectSingleNode( doc ) ).getText() );
assertEquals( "impl", ( (Text) implementation.selectSingleNode( doc ) ).getText() );
}
- public void testAddToArchive_ShouldWriteTwoComponentToFile()
- throws IOException, ArchiverException, JDOMException
+ public void testAddToArchive_ShouldWriteTwoComponentToFile() throws IOException, ArchiverException, JDOMException
{
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<String, Xpp3Dom>();
- Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
+ final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
filter.components.put( "rolehint", dom );
- Xpp3Dom dom2 = createComponentDom( new ComponentDef( "role", "hint2", "impl" ) );
+ final Xpp3Dom dom2 = createComponentDom( new ComponentDef( "role", "hint2", "impl" ) );
filter.components.put( "rolehint2", dom2 );
- FileCatchingArchiver fca = new FileCatchingArchiver();
+ final FileCatchingArchiver fca = new FileCatchingArchiver();
filter.finalizeArchiveCreation( fca );
assertEquals( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH, fca.getDestFileName() );
- SAXBuilder builder = new SAXBuilder( false );
+ final SAXBuilder builder = new SAXBuilder( false );
- Document doc = builder.build( fca.getFile() );
+ final Document doc = builder.build( fca.getFile() );
- XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
- XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
- XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
+ final XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
+ final XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
+ final XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
assertEquals( "role", ( (Text) role.selectSingleNode( doc ) ).getText() );
assertEquals( "hint", ( (Text) hint.selectSingleNode( doc ) ).getText() );
assertEquals( "impl", ( (Text) implementation.selectSingleNode( doc ) ).getText() );
- XPath role2 = XPath.newInstance( "//component[position()=2]/role/text()" );
- XPath hint2 = XPath.newInstance( "//component[position()=2]/role-hint/text()" );
- XPath implementation2 = XPath.newInstance( "//component[position()=2]/implementation/text()" );
+ final XPath role2 = XPath.newInstance( "//component[position()=2]/role/text()" );
+ final XPath hint2 = XPath.newInstance( "//component[position()=2]/role-hint/text()" );
+ final XPath implementation2 = XPath.newInstance( "//component[position()=2]/implementation/text()" );
assertEquals( "role", ( (Text) role2.selectSingleNode( doc ) ).getText() );
assertEquals( "hint2", ( (Text) hint2.selectSingleNode( doc ) ).getText() );
@@ -234,54 +242,54 @@ public class ComponentsXmlArchiverFileFi
public void testAddToArchive_ShouldWriteTwoComponentToArchivedFile()
throws IOException, ArchiverException, JDOMException
{
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<String, Xpp3Dom>();
- Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
+ final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
filter.components.put( "rolehint", dom );
- Xpp3Dom dom2 = createComponentDom( new ComponentDef( "role", "hint2", "impl" ) );
+ final Xpp3Dom dom2 = createComponentDom( new ComponentDef( "role", "hint2", "impl" ) );
filter.components.put( "rolehint2", dom2 );
- ZipArchiver archiver = new ZipArchiver();
+ final ZipArchiver archiver = new ZipArchiver();
- File archiveFile = fileManager.createTempFile();
+ final File archiveFile = fileManager.createTempFile();
archiver.setDestFile( archiveFile );
- File descriptorFile = fileManager.createTempFile();
+ final File descriptorFile = fileManager.createTempFile();
archiver.setArchiveFinalizers( Collections.singletonList( filter ) );
archiver.createArchive();
- ZipFile zf = new ZipFile( archiveFile );
+ final ZipFile zf = new ZipFile( archiveFile );
- ZipEntry ze = zf.getEntry( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH );
+ final ZipEntry ze = zf.getEntry( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH );
assertNotNull( ze );
- FileOutputStream fileStream = new FileOutputStream( descriptorFile );
+ final FileOutputStream fileStream = new FileOutputStream( descriptorFile );
IOUtil.copy( zf.getInputStream( ze ), fileStream );
IOUtil.close( fileStream );
- SAXBuilder builder = new SAXBuilder( false );
+ final SAXBuilder builder = new SAXBuilder( false );
- Document doc = builder.build( descriptorFile );
+ final Document doc = builder.build( descriptorFile );
- XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
- XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
- XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
+ final XPath role = XPath.newInstance( "//component[position()=1]/role/text()" );
+ final XPath hint = XPath.newInstance( "//component[position()=1]/role-hint/text()" );
+ final XPath implementation = XPath.newInstance( "//component[position()=1]/implementation/text()" );
assertEquals( "role", ( (Text) role.selectSingleNode( doc ) ).getText() );
assertEquals( "hint", ( (Text) hint.selectSingleNode( doc ) ).getText() );
assertEquals( "impl", ( (Text) implementation.selectSingleNode( doc ) ).getText() );
- XPath role2 = XPath.newInstance( "//component[position()=2]/role/text()" );
- XPath hint2 = XPath.newInstance( "//component[position()=2]/role-hint/text()" );
- XPath implementation2 = XPath.newInstance( "//component[position()=2]/implementation/text()" );
+ final XPath role2 = XPath.newInstance( "//component[position()=2]/role/text()" );
+ final XPath hint2 = XPath.newInstance( "//component[position()=2]/role-hint/text()" );
+ final XPath implementation2 = XPath.newInstance( "//component[position()=2]/implementation/text()" );
assertEquals( "role", ( (Text) role2.selectSingleNode( doc ) ).getText() );
assertEquals( "hint2", ( (Text) hint2.selectSingleNode( doc ) ).getText() );
@@ -289,42 +297,41 @@ public class ComponentsXmlArchiverFileFi
}
- private Xpp3Dom createComponentDom( ComponentDef def )
+ private Xpp3Dom createComponentDom( final ComponentDef def )
{
- Xpp3Dom dom = new Xpp3Dom( "component" );
+ final Xpp3Dom dom = new Xpp3Dom( "component" );
- Xpp3Dom role = new Xpp3Dom( "role" );
+ final Xpp3Dom role = new Xpp3Dom( "role" );
role.setValue( def.role );
dom.addChild( role );
- String hint = def.roleHint;
+ final String hint = def.roleHint;
if ( hint != null )
{
- Xpp3Dom roleHint = new Xpp3Dom( "role-hint" );
+ final Xpp3Dom roleHint = new Xpp3Dom( "role-hint" );
roleHint.setValue( hint );
dom.addChild( roleHint );
}
- Xpp3Dom impl = new Xpp3Dom( "implementation" );
+ final Xpp3Dom impl = new Xpp3Dom( "implementation" );
impl.setValue( def.implementation );
dom.addChild( impl );
return dom;
}
- private Reader writeComponentsXml( List componentDefs )
- throws IOException
+ private Reader writeComponentsXml( final List<ComponentDef> componentDefs ) throws IOException
{
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
- PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer );
+ final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer );
xmlWriter.startElement( "component-set" );
xmlWriter.startElement( "components" );
- for ( Iterator it = componentDefs.iterator(); it.hasNext(); )
+ for ( final Iterator<ComponentDef> it = componentDefs.iterator(); it.hasNext(); )
{
- ComponentDef def = (ComponentDef) it.next();
+ final ComponentDef def = it.next();
xmlWriter.startElement( "component" );
@@ -332,7 +339,7 @@ public class ComponentsXmlArchiverFileFi
xmlWriter.writeText( def.role );
xmlWriter.endElement();
- String roleHint = def.roleHint;
+ final String roleHint = def.roleHint;
if ( roleHint != null )
{
xmlWriter.startElement( "role-hint" );
@@ -361,7 +368,7 @@ public class ComponentsXmlArchiverFileFi
String implementation;
- ComponentDef( String role, String roleHint, String implementation )
+ ComponentDef( final String role, final String roleHint, final String implementation )
{
this.role = role;
this.roleHint = roleHint;
@@ -378,32 +385,29 @@ public class ComponentsXmlArchiverFileFi
private String destFileName;
- public void addDirectory( File directory )
- throws ArchiverException
+ public void addDirectory( final File directory ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addDirectory( File directory, String prefix )
- throws ArchiverException
+ public void addDirectory( final File directory, final String prefix ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addDirectory( File directory, String[] includes, String[] excludes )
+ public void addDirectory( final File directory, final String[] includes, final String[] excludes )
throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addDirectory( File directory, String prefix, String[] includes, String[] excludes )
- throws ArchiverException
+ public void addDirectory( final File directory, final String prefix, final String[] includes,
+ final String[] excludes ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addFile( File inputFile, String destFileName )
- throws ArchiverException
+ public void addFile( final File inputFile, final String destFileName ) throws ArchiverException
{
this.inputFile = inputFile;
this.destFileName = destFileName;
@@ -419,14 +423,13 @@ public class ComponentsXmlArchiverFileFi
return destFileName;
}
- public void addFile( File inputFile, String destFileName, int permissions )
+ public void addFile( final File inputFile, final String destFileName, final int permissions )
throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void createArchive()
- throws ArchiverException, IOException
+ public void createArchive() throws ArchiverException, IOException
{
throw new UnsupportedOperationException( "not supported" );
}
@@ -446,6 +449,7 @@ public class ComponentsXmlArchiverFileFi
throw new UnsupportedOperationException( "not supported" );
}
+ @SuppressWarnings( "rawtypes" )
public Map getFiles()
{
throw new UnsupportedOperationException( "not supported" );
@@ -456,51 +460,49 @@ public class ComponentsXmlArchiverFileFi
throw new UnsupportedOperationException( "not supported" );
}
- public void setDefaultDirectoryMode( int mode )
+ public void setDefaultDirectoryMode( final int mode )
{
throw new UnsupportedOperationException( "not supported" );
}
- public void setDefaultFileMode( int mode )
+ public void setDefaultFileMode( final int mode )
{
throw new UnsupportedOperationException( "not supported" );
}
- public void setDestFile( File destFile )
+ public void setDestFile( final File destFile )
{
throw new UnsupportedOperationException( "not supported" );
}
- public void setIncludeEmptyDirs( boolean includeEmptyDirs )
+ public void setIncludeEmptyDirs( final boolean includeEmptyDirs )
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addArchivedFileSet( File archiveFile )
- throws ArchiverException
+ public void addArchivedFileSet( final File archiveFile ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addArchivedFileSet( File archiveFile, String prefix )
- throws ArchiverException
+ public void addArchivedFileSet( final File archiveFile, final String prefix ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addArchivedFileSet( File archiveFile, String[] includes, String[] excludes )
+ public void addArchivedFileSet( final File archiveFile, final String[] includes, final String[] excludes )
throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addArchivedFileSet( File archiveFile, String prefix, String[] includes, String[] excludes )
- throws ArchiverException
+ public void addArchivedFileSet( final File archiveFile, final String prefix, final String[] includes,
+ final String[] excludes ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void setForced( boolean forced )
+ public void setForced( final boolean forced )
{
throw new UnsupportedOperationException( "not supported" );
}
@@ -515,49 +517,42 @@ public class ComponentsXmlArchiverFileFi
throw new UnsupportedOperationException( "not supported" );
}
- public void setDotFileDirectory( File dotFileDirectory )
+ public void setDotFileDirectory( final File dotFileDirectory )
{
}
- public void addArchivedFileSet( ArchivedFileSet fileSet )
- throws ArchiverException
+ public void addArchivedFileSet( final ArchivedFileSet fileSet ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addFileSet( FileSet fileSet )
- throws ArchiverException
+ public void addFileSet( final FileSet fileSet ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addResource( PlexusIoResource resource,
- String destFileName,
- int permissions )
+ public void addResource( final PlexusIoResource resource, final String destFileName, final int permissions )
throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public void addResources( PlexusIoResourceCollection resources )
- throws ArchiverException
+ public void addResources( final PlexusIoResourceCollection resources ) throws ArchiverException
{
throw new UnsupportedOperationException( "not supported" );
}
- public ResourceIterator getResources()
- throws ArchiverException
+ public ResourceIterator getResources() throws ArchiverException
{
- return new ResourceIterator(){
+ return new ResourceIterator()
+ {
- public boolean hasNext()
- throws ArchiverException
+ public boolean hasNext() throws ArchiverException
{
return false;
}
- public ArchiveEntry next()
- throws ArchiverException
+ public ArchiveEntry next() throws ArchiverException
{
throw new NoSuchElementException();
}
@@ -570,7 +565,7 @@ public class ComponentsXmlArchiverFileFi
return Archiver.DUPLICATES_ADD;
}
- public void setDuplicateBehavior( String duplicate )
+ public void setDuplicateBehavior( final String duplicate )
{
}
@@ -594,12 +589,12 @@ public class ComponentsXmlArchiverFileFi
throw new UnsupportedOperationException( "not supported" );
}
- public void setDirectoryMode( int mode )
+ public void setDirectoryMode( final int mode )
{
throw new UnsupportedOperationException( "not supported" );
}
- public void setFileMode( int mode )
+ public void setFileMode( final int mode )
{
throw new UnsupportedOperationException( "not supported" );
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java Tue Sep 21 20:34:50 2010
@@ -37,21 +37,21 @@ import java.util.Collections;
import java.util.List;
public class FileFormatterTest
-extends PlexusTestCase
+ extends PlexusTestCase
{
- private Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
+ private final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
- private TestFileManager fileManager = new TestFileManager( "fileFormatterTest.", "" );
+ private final TestFileManager fileManager = new TestFileManager( "fileFormatterTest.", "" );
- private MockManager mockManager = new MockManager();
+ private final MockManager mockManager = new MockManager();
private AssemblerConfigurationSource configSource;
private MockControl configSourceControl;
- public void setUp()
- throws Exception
+ @Override
+ public void setUp() throws Exception
{
super.setUp();
@@ -61,55 +61,52 @@ extends PlexusTestCase
configSource = (AssemblerConfigurationSource) configSourceControl.getMock();
}
- public void tearDown()
- throws IOException
+ @Override
+ public void tearDown() throws IOException
{
fileManager.cleanUp();
}
- public void testTemporaryRootDirectoryNotExist()
- throws IOException, AssemblyFormattingException
+ public void testTemporaryRootDirectoryNotExist() throws IOException, AssemblyFormattingException
{
- File basedir = fileManager.createTempDir();
- File tempRoot = new File(basedir, "tempdir");
+ final File basedir = fileManager.createTempDir();
+ final File tempRoot = new File( basedir, "tempdir" );
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( tempRoot );
- File file = fileManager.createFile( basedir, "one.txt", "This is a\ntest." );
+ final File file = fileManager.createFile( basedir, "one.txt", "This is a\ntest." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, false, "dos" );
-
- assertTrue( !file.equals(result) );
+ final File result = new FileFormatter( configSource, logger ).format( file, false, "dos" );
+ assertTrue( !file.equals( result ) );
mockManager.verifyAll();
}
- public void testShouldNotTransformOneFile()
- throws IOException, AssemblyFormattingException
+ public void testShouldNotTransformOneFile() throws IOException, AssemblyFormattingException
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( basedir );
- // Model model = new Model();
- // model.setArtifactId( "artifact" );
- // model.setGroupId( "group" );
- // model.setVersion( "version" );
+ // Model model = new Model();
+ // model.setArtifactId( "artifact" );
+ // model.setGroupId( "group" );
+ // model.setVersion( "version" );
//
- // MavenProject project = new MavenProject( model );
+ // MavenProject project = new MavenProject( model );
//
- // configSource.getProject();
- // configSourceControl.setReturnValue( project );
+ // configSource.getProject();
+ // configSourceControl.setReturnValue( project );
- File file = fileManager.createFile( basedir, "one.txt", "This is a test." );
+ final File file = fileManager.createFile( basedir, "one.txt", "This is a test." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, false, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, false, null );
assertEquals( file, result );
@@ -117,19 +114,18 @@ extends PlexusTestCase
}
// TODO: Should not be appending line-ending at the end if there is none in the source.
- public void testShouldConvertCRLFLineEndingsInFile()
- throws IOException, AssemblyFormattingException
+ public void testShouldConvertCRLFLineEndingsInFile() throws IOException, AssemblyFormattingException
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( basedir );
- File file = fileManager.createFile( basedir, "one.txt", "This is a\ntest." );
+ final File file = fileManager.createFile( basedir, "one.txt", "This is a\ntest." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, false, "dos" );
+ final File result = new FileFormatter( configSource, logger ).format( file, false, "dos" );
assertEquals( "This is a\r\ntest.\r\n", fileManager.getFileContents( result ) );
@@ -137,62 +133,60 @@ extends PlexusTestCase
}
// TODO: Should not be appending line-ending at the end if there is none in the source.
- public void testShouldConvertLFLineEndingsInFile()
- throws IOException, AssemblyFormattingException
+ public void testShouldConvertLFLineEndingsInFile() throws IOException, AssemblyFormattingException
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( basedir );
- File file = fileManager.createFile( basedir, "one.txt", "This is a\r\ntest." );
+ final File file = fileManager.createFile( basedir, "one.txt", "This is a\r\ntest." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, false, "unix" );
+ final File result = new FileFormatter( configSource, logger ).format( file, false, "unix" );
assertEquals( "This is a\ntest.\n", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldFilterProjectExpressionInFile()
- throws Exception
+ public void testShouldFilterProjectExpressionInFile() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- enableBasicFilteringConfiguration( basedir, Collections.EMPTY_LIST );
+ enableBasicFilteringConfiguration( basedir, null );
- File file = fileManager.createFile( basedir, "one.txt", "This is a test for project: ${artifactId} @artifactId@." );
+ final File file =
+ fileManager.createFile( basedir, "one.txt", "This is a test for project: ${artifactId} @artifactId@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "This is a test for project: artifact artifact.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldFilterExpressionInPropertiesFileWithWindowsEscapes()
- throws Exception
+ public void testShouldFilterExpressionInPropertiesFileWithWindowsEscapes() throws Exception
{
- File sourceDir = fileManager.createTempDir();
- MavenProject project = createBasicMavenProject();
- Build build = new Build();
+ final File sourceDir = fileManager.createTempDir();
+ final MavenProject project = createBasicMavenProject();
+ final Build build = new Build();
// project.build.outputDirectory = C:\out\deeper
build.setOutputDirectory( "C:\\out\\deeper" );
- project.setBuild(build);
+ project.setBuild( build );
enableBasicFilteringConfiguration( project, sourceDir );
- File file = fileManager.createFile(sourceDir, "one.properties", "out=${project.build.outputDirectory}");
+ final File file = fileManager.createFile( sourceDir, "one.properties", "out=${project.build.outputDirectory}" );
mockManager.replayAll();
- File result = new FileFormatter(configSource, logger).format(file, true, null);
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
// expect: C:\\out\\deeper
assertEquals( "out=C:\\\\out\\\\deeper", fileManager.getFileContents( result ) );
@@ -200,176 +194,173 @@ extends PlexusTestCase
mockManager.verifyAll();
}
- public void testShouldFilterExpressionInPropertiesFileWithoutWindowsEscapes()
- throws Exception
+ public void testShouldFilterExpressionInPropertiesFileWithoutWindowsEscapes() throws Exception
{
- File sourceDir = fileManager.createTempDir();
- MavenProject project = createBasicMavenProject();
- Build build = new Build();
+ final File sourceDir = fileManager.createTempDir();
+ final MavenProject project = createBasicMavenProject();
+ final Build build = new Build();
build.setOutputDirectory( "C:\\out\\deeper" );
- project.setBuild(build);
+ project.setBuild( build );
enableBasicFilteringConfiguration( project, sourceDir );
- File file = fileManager.createFile(sourceDir, "one.txt", "project.basedirA=${project.build.outputDirectory}");
+ final File file =
+ fileManager.createFile( sourceDir, "one.txt", "project.basedirA=${project.build.outputDirectory}" );
mockManager.replayAll();
- File result = new FileFormatter(configSource, logger).format(file, true, null);
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
- assertEquals("project.basedirA=C:\\out\\deeper",fileManager.getFileContents(result));
+ assertEquals( "project.basedirA=C:\\out\\deeper", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
-
- public void testShouldFilterExpressionFromFiltersFileInFile()
- throws Exception
+ public void testShouldFilterExpressionFromFiltersFileInFile() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
enableBasicFilteringConfiguration( basedir, Collections.singletonList( filterProps.getCanonicalPath() ) );
- File file = fileManager.createFile( basedir, "one.txt", "This is a test for project: ${property} @property@." );
+ final File file =
+ fileManager.createFile( basedir, "one.txt", "This is a test for project: ${property} @property@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "This is a test for project: Test Test.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldFilterExpressionFromFiltersFileInPropertiesFileWithoutWindowsEscapes()
- throws Exception
+ public void testShouldFilterExpressionFromFiltersFileInPropertiesFileWithoutWindowsEscapes() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "property=C:\\\\Test" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "property=C:\\\\Test" );
enableBasicFilteringConfiguration( basedir, Collections.singletonList( filterProps.getCanonicalPath() ) );
- File file = fileManager.createFile( basedir, "one.properties", "project: ${property} @property@." );
+ final File file = fileManager.createFile( basedir, "one.properties", "project: ${property} @property@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "project: C:\\\\Test C:\\\\Test.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldFilterExpressionFromFiltersFileInNonPropertiesFileWithoutWindowsEscapes()
- throws Exception
+ public void testShouldFilterExpressionFromFiltersFileInNonPropertiesFileWithoutWindowsEscapes() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "property=C:\\\\Test" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "property=C:\\\\Test" );
enableBasicFilteringConfiguration( basedir, Collections.singletonList( filterProps.getCanonicalPath() ) );
- File file = fileManager.createFile( basedir, "one.txt", "This is a test for project: ${property} @property@." );
+ final File file =
+ fileManager.createFile( basedir, "one.txt", "This is a test for project: ${property} @property@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "This is a test for project: C:\\Test C:\\Test.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldNotIgnoreFirstWordInDotNotationExpressions()
- throws Exception
+ public void testShouldNotIgnoreFirstWordInDotNotationExpressions() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- enableBasicFilteringConfiguration( basedir, Collections.EMPTY_LIST );
+ enableBasicFilteringConfiguration( basedir, null );
- File file = fileManager.createFile( basedir, "one.txt", "testing ${bean.id} which used to resolve to project.id" );
+ final File file =
+ fileManager.createFile( basedir, "one.txt", "testing ${bean.id} which used to resolve to project.id" );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "testing ${bean.id} which used to resolve to project.id", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldFilterExpressionsFromTwoFiltersFilesInFile()
- throws Exception
+ public void testShouldFilterExpressionsFromTwoFiltersFilesInFile() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
- File filterProps2 = fileManager.createFile( basedir, "filter2.properties", "otherProperty=OtherValue" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
+ final File filterProps2 = fileManager.createFile( basedir, "filter2.properties", "otherProperty=OtherValue" );
- List filters = new ArrayList();
+ final List<String> filters = new ArrayList<String>();
filters.add( filterProps.getCanonicalPath() );
filters.add( filterProps2.getCanonicalPath() );
enableBasicFilteringConfiguration( basedir, filters );
- File file = fileManager.createFile( basedir, "one.txt",
- "property: ${property} @property@ otherProperty: ${otherProperty} @otherProperty@." );
+ final File file =
+ fileManager.createFile( basedir, "one.txt",
+ "property: ${property} @property@ otherProperty: ${otherProperty} @otherProperty@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "property: Test Test otherProperty: OtherValue OtherValue.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldOverrideOneFilterValueWithAnotherAndFilterFile()
- throws Exception
+ public void testShouldOverrideOneFilterValueWithAnotherAndFilterFile() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
- File filterProps2 = fileManager.createFile( basedir, "filter2.properties", "property=OtherValue" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "property=Test" );
+ final File filterProps2 = fileManager.createFile( basedir, "filter2.properties", "property=OtherValue" );
- List filters = new ArrayList();
+ final List<String> filters = new ArrayList<String>();
filters.add( filterProps.getCanonicalPath() );
filters.add( filterProps2.getCanonicalPath() );
enableBasicFilteringConfiguration( basedir, filters );
- File file = fileManager.createFile( basedir, "one.txt", "property: ${property} @property@." );
+ final File file = fileManager.createFile( basedir, "one.txt", "property: ${property} @property@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "property: OtherValue OtherValue.", fileManager.getFileContents( result ) );
mockManager.verifyAll();
}
- public void testShouldOverrideProjectValueWithFilterValueAndFilterFile()
- throws Exception
+ public void testShouldOverrideProjectValueWithFilterValueAndFilterFile() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- File filterProps = fileManager.createFile( basedir, "filter.properties", "artifactId=Test" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "artifactId=Test" );
- List filters = new ArrayList();
+ final List<String> filters = new ArrayList<String>();
filters.add( filterProps.getCanonicalPath() );
enableBasicFilteringConfiguration( basedir, filters );
- File file = fileManager.createFile( basedir, "one.txt", "project artifact-id: ${artifactId} @artifactId@." );
+ final File file =
+ fileManager.createFile( basedir, "one.txt", "project artifact-id: ${artifactId} @artifactId@." );
mockManager.replayAll();
- File result = new FileFormatter( configSource, logger ).format( file, true, null );
+ final File result = new FileFormatter( configSource, logger ).format( file, true, null );
assertEquals( "project artifact-id: Test Test.", fileManager.getFileContents( result ) );
@@ -378,7 +369,7 @@ extends PlexusTestCase
private MavenProject createBasicMavenProject()
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact" );
model.setGroupId( "group" );
model.setVersion( "version" );
@@ -386,8 +377,7 @@ extends PlexusTestCase
return new MavenProject( model );
}
- private void enableBasicFilteringConfiguration( MavenProject project, File basedir )
- throws Exception
+ private void enableBasicFilteringConfiguration( final MavenProject project, final File basedir ) throws Exception
{
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( basedir );
@@ -405,11 +395,15 @@ extends PlexusTestCase
configSourceControl.setReturnValue( Collections.EMPTY_LIST );
}
- private void enableBasicFilteringConfiguration( File basedir, List filterFilenames )
- throws Exception
+ private void enableBasicFilteringConfiguration( final File basedir, final List<String> filterFilenames )
+ throws Exception
{
- MavenProject project = createBasicMavenProject();
- project.getBuild().setFilters( filterFilenames );
+ final MavenProject project = createBasicMavenProject();
+ if ( filterFilenames != null )
+ {
+ project.getBuild()
+ .setFilters( filterFilenames );
+ }
enableBasicFilteringConfiguration( project, basedir );
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java Tue Sep 21 20:34:50 2010
@@ -38,7 +38,7 @@ import java.util.Collections;
import java.util.List;
public class FileSetFormatterTest
-extends PlexusTestCase
+ extends PlexusTestCase
{
private MockManager mockManager;
@@ -51,8 +51,8 @@ extends PlexusTestCase
private MockControl configSourceControl;
- public void setUp()
- throws Exception
+ @Override
+ public void setUp() throws Exception
{
super.setUp();
@@ -68,79 +68,78 @@ extends PlexusTestCase
configSource = (AssemblerConfigurationSource) configSourceControl.getMock();
}
- public void tearDown()
- throws IOException
+ @Override
+ public void tearDown() throws IOException
{
fileManager.cleanUp();
}
public void testShouldReturnOriginalUnalteredDirectoryWhenLineEndingIsNull()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertEquals( dir, result );
}
public void testShouldReturnOriginalUnalteredDirectoryWhenLineEndingIsKeep()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_KEEP );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertEquals( dir, result );
}
public void testShouldReturnOriginalUnalteredDirectoryWhenIncludedFileSetIsEmpty()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_LF );
fs.setDirectory( dir.getCanonicalPath() );
fs.addExclude( "**/*" );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertEquals( dir, result );
}
- public void testShouldConvertLineEndingsOnTwoFiles()
- throws AssemblyFormattingException, IOException
+ public void testShouldConvertLineEndingsOnTwoFiles() throws AssemblyFormattingException, IOException
{
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- String filename1 = "one.txt";
- String filename2 = "two.txt";
+ final String filename1 = "one.txt";
+ final String filename2 = "two.txt";
fileManager.createFile( dir, filename1, "Hello\nThis is a test." );
fileManager.createFile( dir, filename2, "Hello\nThis is also a test." );
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_CRLF );
fs.setDirectory( dir.getCanonicalPath() );
fs.addInclude( "**/*.txt" );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertFalse( dir.equals( result ) );
@@ -156,25 +155,25 @@ extends PlexusTestCase
}
public void testShouldConvertLineEndingsOnOneFileWithAnotherExplicitlyExcluded()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- String filename1 = "one.txt";
- String filename2 = "two.txt";
+ final String filename1 = "one.txt";
+ final String filename2 = "two.txt";
fileManager.createFile( dir, filename1, "Hello\nThis is a test." );
fileManager.createFile( dir, filename2, "Hello\nThis is also a test." );
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_CRLF );
fs.setDirectory( dir.getCanonicalPath() );
fs.addExclude( "**/two.txt" );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertFalse( dir.equals( result ) );
@@ -190,25 +189,25 @@ extends PlexusTestCase
}
public void testShouldConvertLineEndingsOnOneExplicitlyIncludedFile()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- String filename1 = "one.txt";
- String filename2 = "two.txt";
+ final String filename1 = "one.txt";
+ final String filename2 = "two.txt";
fileManager.createFile( dir, filename1, "Hello\nThis is a test." );
fileManager.createFile( dir, filename2, "Hello\nThis is also a test." );
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_CRLF );
fs.setDirectory( dir.getCanonicalPath() );
fs.addInclude( "**/one.txt" );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertFalse( dir.equals( result ) );
try
@@ -223,24 +222,24 @@ extends PlexusTestCase
}
public void testShouldConvertLineEndingsOnOneFileAndIgnoreFileWithinDefaultExcludedDir()
- throws AssemblyFormattingException, IOException
+ throws AssemblyFormattingException, IOException
{
- File dir = fileManager.createTempDir();
+ final File dir = fileManager.createTempDir();
- String filename1 = "one.txt";
- String filename2 = "CVS/two.txt";
+ final String filename1 = "one.txt";
+ final String filename2 = "CVS/two.txt";
fileManager.createFile( dir, filename1, "Hello\nThis is a test." );
fileManager.createFile( dir, filename2, "Hello\nThis is also a test." );
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setLineEnding( AssemblyFileUtils.LINE_ENDING_CRLF );
fs.setDirectory( dir.getCanonicalPath() );
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( dir, fs );
+ final File result = formatter.formatFileSetForAssembly( dir, fs );
assertFalse( dir.equals( result ) );
@@ -255,21 +254,20 @@ extends PlexusTestCase
}
}
- public void testShouldFilterSeveralFiles()
- throws Exception
+ public void testShouldFilterSeveralFiles() throws Exception
{
- File basedir = fileManager.createTempDir();
+ final File basedir = fileManager.createTempDir();
- String filename1 = "one.txt";
- String filename2 = "two.txt";
+ final String filename1 = "one.txt";
+ final String filename2 = "two.txt";
// this file will be filtered with a project expression
fileManager.createFile( basedir, filename1, "This is the filtered artifactId: ${project.artifactId}." );
// this one fill be filtered with a filter file
fileManager.createFile( basedir, filename2, "This is the filtered 'foo' property: ${foo}." );
- File filterProps = fileManager.createFile( basedir, "filter.properties", "foo=bar" );
+ final File filterProps = fileManager.createFile( basedir, "filter.properties", "foo=bar" );
- FileSet fs = new FileSet();
+ final FileSet fs = new FileSet();
fs.setFiltered( true );
fs.setDirectory( basedir.getCanonicalPath() );
fs.addInclude( "**/*.txt" );
@@ -278,8 +276,8 @@ extends PlexusTestCase
mockManager.replayAll();
- FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
- File result = formatter.formatFileSetForAssembly( basedir, fs );
+ final FileSetFormatter formatter = new FileSetFormatter( configSource, logger );
+ final File result = formatter.formatFileSetForAssembly( basedir, fs );
assertFalse( result.equals( basedir ) );
@@ -296,25 +294,27 @@ extends PlexusTestCase
}
}
- private void enableBasicFilteringConfiguration( File basedir, List filterFilenames )
- throws Exception
+ private void enableBasicFilteringConfiguration( final File basedir, final List<String> filterFilenames )
+ throws Exception
{
configSource.getTemporaryRootDirectory();
configSourceControl.setReturnValue( basedir );
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact" );
model.setGroupId( "group" );
model.setVersion( "version" );
- MavenProject project = new MavenProject( model );
- project.getBuild().setFilters( filterFilenames );
+ final MavenProject project = new MavenProject( model );
+ project.getBuild()
+ .setFilters( filterFilenames );
configSource.getProject();
configSourceControl.setReturnValue( project, MockControl.ONE_OR_MORE );
configSource.getMavenFileFilter();
- configSourceControl.setReturnValue( lookup( "org.apache.maven.shared.filtering.MavenFileFilter" ), MockControl.ONE_OR_MORE );
+ configSourceControl.setReturnValue( lookup( "org.apache.maven.shared.filtering.MavenFileFilter" ),
+ MockControl.ONE_OR_MORE );
configSource.getMavenSession();
configSourceControl.setReturnValue( null, MockControl.ONE_OR_MORE );
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java Tue Sep 21 20:34:50 2010
@@ -19,12 +19,6 @@ package org.apache.maven.plugin.assembly
* under the License.
*/
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
@@ -39,16 +33,22 @@ import org.codehaus.plexus.logging.conso
import org.easymock.MockControl;
import org.easymock.classextension.MockClassControl;
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
public class AssemblyInterpolatorTest
extends TestCase
{
private AssemblyInterpolator interpolator;
-
- private AssemblerConfigurationSource configSourceStub = new ConfigSourceStub();
- public void setUp()
- throws IOException
+ private final AssemblerConfigurationSource configSourceStub = new ConfigSourceStub();
+
+ @Override
+ public void setUp() throws IOException
{
interpolator = new AssemblyInterpolator();
@@ -58,99 +58,97 @@ public class AssemblyInterpolatorTest
public void testDependencySetOutputFileNameMappingsAreNotInterpolated()
throws IOException, AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- MavenProject project = new MavenProject( model );
+ final MavenProject project = new MavenProject( model );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
// artifactId is blacklisted, but packaging is not.
- String outputFileNameMapping = "${artifactId}.${packaging}";
+ final String outputFileNameMapping = "${artifactId}.${packaging}";
- DependencySet set = new DependencySet();
+ final DependencySet set = new DependencySet();
set.setOutputFileNameMapping( outputFileNameMapping );
assembly.addDependencySet( set );
- Assembly outputAssembly = interpolator.interpolate( assembly, project, configSourceStub );
+ final Assembly outputAssembly = interpolator.interpolate( assembly, project, configSourceStub );
- List outputDependencySets = outputAssembly.getDependencySets();
+ final List<DependencySet> outputDependencySets = outputAssembly.getDependencySets();
assertEquals( 1, outputDependencySets.size() );
- DependencySet outputSet = (DependencySet) outputDependencySets.get( 0 );
+ final DependencySet outputSet = outputDependencySets.get( 0 );
assertEquals( "${artifactId}.${packaging}", outputSet.getOutputFileNameMapping() );
}
- public void testDependencySetOutputDirectoryIsNotInterpolated()
- throws IOException, AssemblyInterpolationException
+ public void testDependencySetOutputDirectoryIsNotInterpolated() throws IOException, AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
- String outputDirectory = "${artifactId}.${packaging}";
+ final String outputDirectory = "${artifactId}.${packaging}";
- DependencySet set = new DependencySet();
+ final DependencySet set = new DependencySet();
set.setOutputDirectory( outputDirectory );
assembly.addDependencySet( set );
- Assembly outputAssembly = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
+ final Assembly outputAssembly =
+ interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
- List outputDependencySets = outputAssembly.getDependencySets();
+ final List<DependencySet> outputDependencySets = outputAssembly.getDependencySets();
assertEquals( 1, outputDependencySets.size() );
- DependencySet outputSet = (DependencySet) outputDependencySets.get( 0 );
+ final DependencySet outputSet = outputDependencySets.get( 0 );
assertEquals( "${artifactId}.${packaging}", outputSet.getOutputDirectory() );
}
- public void testShouldResolveModelGroupIdInAssemblyId()
- throws AssemblyInterpolationException
+ public void testShouldResolveModelGroupIdInAssemblyId() throws AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
assembly.setId( "assembly.${groupId}" );
- Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
+ final Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
assertEquals( "assembly.group.id", result.getId() );
}
- public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId()
- throws AssemblyInterpolationException
+ public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId() throws AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- Properties props = new Properties();
+ final Properties props = new Properties();
props.setProperty( "groupId", "other.id" );
model.setProperties( props );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
assembly.setId( "assembly.${groupId}" );
- Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
+ final Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
assertEquals( "assembly.other.id", result.getId() );
}
@@ -158,87 +156,84 @@ public class AssemblyInterpolatorTest
public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId()
throws AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- Properties props = new Properties();
+ final Properties props = new Properties();
props.setProperty( "groupId", "other.id" );
model.setProperties( props );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
assembly.setId( "assembly.${groupId}" );
-
- MockManager mm = new MockManager();
-
- MockControl sessionControl = MockClassControl.createControl( MavenSession.class );
- MavenSession session = (MavenSession) sessionControl.getMock();
-
+
+ final MockManager mm = new MockManager();
+
+ final MockControl sessionControl = MockClassControl.createControl( MavenSession.class );
+ final MavenSession session = (MavenSession) sessionControl.getMock();
+
mm.add( sessionControl );
-
- Properties execProps = new Properties();
+
+ final Properties execProps = new Properties();
execProps.setProperty( "groupId", "still.another.id" );
-
+
session.getExecutionProperties();
sessionControl.setReturnValue( execProps, MockControl.ZERO_OR_MORE );
-
- MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
- AssemblerConfigurationSource cs = (AssemblerConfigurationSource) csControl.getMock();
-
+
+ final MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
+ final AssemblerConfigurationSource cs = (AssemblerConfigurationSource) csControl.getMock();
+
mm.add( csControl );
-
+
cs.getMavenSession();
csControl.setReturnValue( session, MockControl.ZERO_OR_MORE );
-
+
mm.replayAll();
- Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), cs );
+ final Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), cs );
assertEquals( "assembly.still.another.id", result.getId() );
-
+
mm.verifyAll();
mm.clear();
}
- public void testShouldNotTouchUnresolvedExpression()
- throws AssemblyInterpolationException
+ public void testShouldNotTouchUnresolvedExpression() throws AssemblyInterpolationException
{
- Model model = new Model();
+ final Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
model.setPackaging( "jar" );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
assembly.setId( "assembly.${unresolved}" );
- Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
+ final Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
assertEquals( "assembly.${unresolved}", result.getId() );
}
- public void testShouldInterpolateMultiDotProjectExpression()
- throws AssemblyInterpolationException
+ public void testShouldInterpolateMultiDotProjectExpression() throws AssemblyInterpolationException
{
- Build build = new Build();
+ final Build build = new Build();
build.setFinalName( "final-name" );
- Model model = new Model();
+ final Model model = new Model();
model.setBuild( build );
- Assembly assembly = new Assembly();
+ final Assembly assembly = new Assembly();
assembly.setId( "assembly.${project.build.finalName}" );
- Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
+ final Assembly result = interpolator.interpolate( assembly, new MavenProject( model ), configSourceStub );
assertEquals( "assembly.final-name", result.getId() );
}
-
}