[MNG-3503] test for shading of plexus-utils pull parser classes

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@705515 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2008-10-17 08:50:28 +00:00
parent b0e2d803c0
commit c0a5ae7668
13 changed files with 513 additions and 101 deletions

View File

@ -20,30 +20,25 @@ package org.apache.maven.it;
*/ */
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.it.Verifier; import org.apache.maven.it.util.FileUtils;
import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.it.util.ResourceExtractor;
/** /**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3503">MNG-3503</a>. * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3503">MNG-3503</a>.
*
* @todo Fill in a better description of what this test verifies!
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @author jdcasey
* *
* The first test verifies that a plugin using plexus-utils-1.1 does not cause linkage errors.
* The second test verifies that a plugin with a different implementation of the shaded classes is used instead.
*/ */
public class MavenITmng3503Xpp3ShadingTest public class MavenITmng3503Xpp3ShadingTest
extends AbstractMavenIntegrationTestCase extends AbstractMavenIntegrationTestCase
{ {
public MavenITmng3503Xpp3ShadingTest() public MavenITmng3503Xpp3ShadingTest()
{ {
super( "(2.0.9,)" ); // only test in 2.0.9+ super( "(2.0.9,2.1.0-M1),(2.1.0-M1,)" ); // only test in 2.0.9+, and not in 2.1.0-M1
} }
public void testitMNG3503 () public void testitMNG3503()
throws Exception throws Exception
{ {
// The testdir is computed from the location of this // The testdir is computed from the location of this
@ -52,32 +47,26 @@ public class MavenITmng3503Xpp3ShadingTest
Verifier verifier; Verifier verifier;
/* File dir = new File( testDir, "mng-3503-xpp3Shading-pu11" );
* We must first make sure that any artifact created verifier = new Verifier( dir.getAbsolutePath() );
* by this test has been removed from the local
* repository. Failing to do this could cause
* unstable test results. Fortunately, the verifier
* makes it easy to do this.
*/
verifier = new Verifier( testDir.getAbsolutePath() );
verifier.executeGoal( "install" ); verifier.executeGoal( "install" );
/*
* This is the simplest way to check a build
* succeeded. It is also the simplest way to create
* an IT test: make the build pass when the test
* should pass, and make the build fail when the
* test should fail. There are other methods
* supported by the verifier. They can be seen here:
* http://maven.apache.org/shared/maven-verifier/apidocs/index.html
*/
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
/*
* Reset the streams before executing the verifier
* again.
*/
verifier.resetStreams(); verifier.resetStreams();
assertEquals( "<root />", FileUtils.fileRead( new File( dir, "target/serialized.xml" ) ) );
dir = new File( testDir, "mng-3503-xpp3Shading-pu-new" );
verifier = new Verifier( dir.getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
assertEquals( "root", FileUtils.fileRead( new File( dir, "target/serialized.xml" ) ) );
} }
} }

View File

@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3503</groupId>
<artifactId>mng-3503-xpp3Shading-pu-new</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-utils-new</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>serialize</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3503</groupId>
<artifactId>mng-3503-xpp3Shading-pu11</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-utils-11</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>serialize</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>testing</groupId>
<artifactId>mng-3503-xpp3Shading</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
</project>

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<project>
<bannerLeft>
<name>Doxia</name>
<src>images/apache-maven-project-2.png</src>
</bannerLeft>
<bannerRight>
<src>images/maven-logo-2.gif</src>
</bannerRight>
<publishDate format="d MMM yyyy" position="right" />
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-stylus-skin</artifactId>
<version>1.0.1</version>
</skin>
<body>
<links>
<item name="Apache" href="http://www.apache.org/"/>
<item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
<item name="Maven 2.x" href="http://maven.apache.org/"/>
<item name="SCM" href="http://maven.apache.org/scm"/>
<item name="Wagon" href="http://maven.apache.org/wagon"/>
<item name="JXR" href="http://maven.apache.org/jxr"/>
<item name="Doxia" href="http://maven.apache.org/doxia"/>
</links>
<head>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-140879-1";
urchinTracker();
</script>
</head>
<menu ref="modules"/>
<menu ref="reports"/>
</body>
</project>

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-it-plugins</artifactId>
<groupId>org.apache.maven.its.plugins</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>maven-it-plugin-plexus-utils-11</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,50 @@
package org.apache.maven.its.plugins;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.MXSerializer;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
/**
* @goal serialize
* @phase package
*/
public class SerializeMojo
extends AbstractMojo
{
/**
* @parameter default-value="${project.build.directory}/serialized.xml"
*/
private String filename;
public void execute()
throws MojoExecutionException, MojoFailureException
{
FileWriter writer = null;
XmlSerializer s = new MXSerializer();
try
{
writer = new FileWriter( filename );
s.setOutput( writer );
Xpp3Dom dom = new Xpp3Dom( "root" );
dom.writeToSerializer( "", s );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
finally
{
IOUtil.close( writer );
}
}
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-it-plugins</artifactId>
<groupId>org.apache.maven.its.plugins</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>maven-it-plugin-plexus-utils-new</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,50 @@
package org.apache.maven.its.plugins;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.MXSerializer;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
/**
* @goal serialize
* @phase package
*/
public class SerializeMojo
extends AbstractMojo
{
/**
* @parameter default-value="${project.build.directory}/serialized.xml"
*/
private String filename;
public void execute()
throws MojoExecutionException, MojoFailureException
{
FileWriter writer = null;
XmlSerializer s = new MXSerializer();
try
{
writer = new FileWriter( filename );
s.setOutput( writer );
Xpp3Dom dom = new Xpp3Dom( "root" );
dom.writeToSerializer( "", s );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
finally
{
IOUtils.closeQuietly( writer );
}
}
}

View File

@ -0,0 +1,26 @@
package org.codehaus.plexus.util.xml;
import java.io.IOException;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
public class Xpp3Dom
{
private String root;
public Xpp3Dom( String root )
{
this.root = root;
}
public void writeToSerializer( String namespace, XmlSerializer s )
throws IOException
{
s.startDocument( "UTF-8", Boolean.FALSE );
s.startTag( namespace, root );
s.endTag( namespace, root );
s.endDocument();
}
}

View File

@ -0,0 +1,180 @@
package org.codehaus.plexus.util.xml.pull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
public class MXSerializer
implements XmlSerializer
{
private Writer output;
public void setOutput( Writer writer )
{
output = writer;
}
public XmlSerializer attribute( String namespace, String name, String value )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
return null;
}
public void cdsect( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void comment( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void docdecl( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void endDocument()
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public XmlSerializer endTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
return null;
}
public void entityRef( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void flush()
throws IOException
{
// TODO Auto-generated method stub
}
public int getDepth()
{
// TODO Auto-generated method stub
return 0;
}
public boolean getFeature( String name )
{
// TODO Auto-generated method stub
return false;
}
public String getName()
{
// TODO Auto-generated method stub
return null;
}
public String getNamespace()
{
// TODO Auto-generated method stub
return null;
}
public String getPrefix( String namespace, boolean generatePrefix )
throws IllegalArgumentException
{
// TODO Auto-generated method stub
return null;
}
public Object getProperty( String name )
{
// TODO Auto-generated method stub
return null;
}
public void ignorableWhitespace( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void processingInstruction( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void setFeature( String name, boolean state )
throws IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void setOutput( OutputStream os, String encoding )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void setPrefix( String prefix, String namespace )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void setProperty( String name, Object value )
throws IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public void startDocument( String encoding, Boolean standalone )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
}
public XmlSerializer startTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException
{
output.write( name );
return this;
}
public XmlSerializer text( String text )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
return null;
}
public XmlSerializer text( char[] buf, int start, int len )
throws IOException, IllegalArgumentException, IllegalStateException
{
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,79 @@
package org.codehaus.plexus.util.xml.pull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
public interface XmlSerializer
{
void setFeature( String name, boolean state )
throws IllegalArgumentException, IllegalStateException;
boolean getFeature( String name );
void setProperty( String name, Object value )
throws IllegalArgumentException, IllegalStateException;
Object getProperty( String name );
void setOutput( OutputStream os, String encoding )
throws IOException, IllegalArgumentException, IllegalStateException;
void setOutput( Writer writer )
throws IOException, IllegalArgumentException, IllegalStateException;
void startDocument( String encoding, Boolean standalone )
throws IOException, IllegalArgumentException, IllegalStateException;
void endDocument()
throws IOException, IllegalArgumentException, IllegalStateException;
void setPrefix( String prefix, String namespace )
throws IOException, IllegalArgumentException, IllegalStateException;
String getPrefix( String namespace, boolean generatePrefix )
throws IllegalArgumentException;
int getDepth();
String getNamespace();
String getName();
XmlSerializer startTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException;
XmlSerializer attribute( String namespace, String name, String value )
throws IOException, IllegalArgumentException, IllegalStateException;
XmlSerializer endTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException;
XmlSerializer text( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
XmlSerializer text( char[] buf, int start, int len )
throws IOException, IllegalArgumentException, IllegalStateException;
void cdsect( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void entityRef( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void processingInstruction( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void comment( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void docdecl( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void ignorableWhitespace( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
void flush()
throws IOException;
}

View File

@ -57,6 +57,8 @@ under the License.
<module>maven-it-plugin-uses-properties</module> <module>maven-it-plugin-uses-properties</module>
<module>maven-it-plugin-uses-wagon</module> <module>maven-it-plugin-uses-wagon</module>
<module>maven-it-plugin-all</module> <module>maven-it-plugin-all</module>
<module>maven-it-plugin-plexus-utils-11</module>
<module>maven-it-plugin-plexus-utils-new</module>
</modules> </modules>
<scm> <scm>