mirror of https://github.com/apache/maven.git
[MNG-6479] Upgrade XMLUnit to 2.2.1 (#183)
This commit is contained in:
parent
ed8bc6bc0e
commit
91fa89ea28
|
@ -71,9 +71,13 @@ under the License.
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xmlunit</groupId>
|
||||
<artifactId>xmlunit</artifactId>
|
||||
<version>1.6</version>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-matchers</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -21,21 +21,16 @@ package org.apache.maven.model.inheritance;
|
|||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.building.SimpleProblemCollector;
|
||||
import org.apache.maven.model.io.ModelParseException;
|
||||
import org.apache.maven.model.io.ModelReader;
|
||||
import org.apache.maven.model.io.ModelWriter;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.custommonkey.xmlunit.XMLAssert;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.xmlunit.matchers.CompareMatcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Hervé Boutemy
|
||||
|
@ -66,7 +61,7 @@ public class DefaultInheritanceAssemblerTest
|
|||
}
|
||||
|
||||
private Model getModel( String name )
|
||||
throws ModelParseException, IOException
|
||||
throws IOException
|
||||
{
|
||||
return reader.read( getPom( name ), null );
|
||||
}
|
||||
|
@ -80,7 +75,7 @@ public class DefaultInheritanceAssemblerTest
|
|||
/**
|
||||
* Check most classical urls inheritance: directory structure where parent POM in parent directory
|
||||
* and child directory == artifactId
|
||||
* @throws Exception
|
||||
* @throws IOException Model read problem
|
||||
*/
|
||||
public void testUrls()
|
||||
throws Exception
|
||||
|
@ -90,10 +85,10 @@ public class DefaultInheritanceAssemblerTest
|
|||
|
||||
/**
|
||||
* Flat directory structure: parent & child POMs in sibling directories, child directory == artifactId.
|
||||
* @throws Exception
|
||||
* @throws IOException Model read problem
|
||||
*/
|
||||
public void testFlatUrls()
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
testInheritance( "flat-urls" );
|
||||
}
|
||||
|
@ -112,10 +107,10 @@ public class DefaultInheritanceAssemblerTest
|
|||
* Tricky case: flat directory structure, but child directory != artifactId.
|
||||
* Model interpolation does not give same result when calculated from build or from repo...
|
||||
* This is why MNG-5000 fix in code is marked as bad practice (uses file names)
|
||||
* @throws Exception
|
||||
* @throws IOException Model read problem
|
||||
*/
|
||||
public void testFlatTrickyUrls()
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
// parent references child with artifactId (which is not directory name)
|
||||
// then relative path calculation will fail during build from disk but success when calculated from repo
|
||||
|
@ -125,46 +120,49 @@ public class DefaultInheritanceAssemblerTest
|
|||
testInheritance( "tricky-flat-artifactId-urls", false );
|
||||
//fail( "should have failed since module reference == artifactId != directory name" );
|
||||
}
|
||||
catch ( AssertionFailedError afe )
|
||||
catch ( AssertionError afe )
|
||||
{
|
||||
// expected failure: wrong relative path calculation
|
||||
assertTrue( afe.getMessage(),
|
||||
afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
|
||||
afe.getMessage().contains(
|
||||
"Expected text value 'http://www.apache.org/path/to/parent/child-artifact-id/' but was " +
|
||||
"'http://www.apache.org/path/to/parent/../child-artifact-id/'" ) );
|
||||
}
|
||||
// but ok from repo: local disk is ignored
|
||||
testInheritance( "tricky-flat-artifactId-urls", true );
|
||||
|
||||
// parent references child with directory name (which is not artifact id)
|
||||
// then relative path calculation will success during build from disk but failwhen calculated from repo
|
||||
// then relative path calculation will success during build from disk but fail when calculated from repo
|
||||
testInheritance( "tricky-flat-directory-urls", false );
|
||||
try
|
||||
{
|
||||
testInheritance( "tricky-flat-directory-urls", true );
|
||||
fail( "should have failed since module reference == directory name != artifactId" );
|
||||
}
|
||||
catch ( AssertionFailedError afe )
|
||||
catch ( AssertionError afe )
|
||||
{
|
||||
// expected failure
|
||||
assertTrue( afe.getMessage(),
|
||||
afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
|
||||
assertTrue( afe.getMessage(), afe.getMessage().contains(
|
||||
"Expected text value 'http://www.apache.org/path/to/parent/../child-artifact-id/' but was " +
|
||||
"'http://www.apache.org/path/to/parent/child-artifact-id/'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithEmptyUrl()
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
testInheritance( "empty-urls", false );
|
||||
}
|
||||
|
||||
public void testInheritance( String baseName )
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
testInheritance( baseName, false );
|
||||
testInheritance( baseName, true );
|
||||
}
|
||||
|
||||
public void testInheritance( String baseName, boolean fromRepo )
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
Model parent = getModel( baseName + "-parent" );
|
||||
|
||||
|
@ -189,17 +187,12 @@ public class DefaultInheritanceAssemblerTest
|
|||
|
||||
// check with getPom( baseName + "-expected" )
|
||||
File expected = getPom( baseName + "-expected" );
|
||||
try ( Reader control = new InputStreamReader( new FileInputStream( expected ), StandardCharsets.UTF_8 );
|
||||
Reader test = new InputStreamReader( new FileInputStream( actual ), StandardCharsets.UTF_8 ) )
|
||||
{
|
||||
XMLUnit.setIgnoreComments( true );
|
||||
XMLUnit.setIgnoreWhitespace( true );
|
||||
XMLAssert.assertXMLEqual( control, test );
|
||||
}
|
||||
}
|
||||
|
||||
assertThat( actual, CompareMatcher.isIdenticalTo( expected ).ignoreComments().ignoreWhitespace() );
|
||||
}
|
||||
|
||||
public void testModulePathNotArtifactId()
|
||||
throws Exception
|
||||
throws IOException
|
||||
{
|
||||
Model parent = getModel( "module-path-not-artifactId-parent" );
|
||||
|
||||
|
@ -215,12 +208,7 @@ public class DefaultInheritanceAssemblerTest
|
|||
|
||||
// check with getPom( "module-path-not-artifactId-effective" )
|
||||
File expected = getPom( "module-path-not-artifactId-expected" );
|
||||
try ( Reader control = new InputStreamReader( new FileInputStream( expected ), StandardCharsets.UTF_8 );
|
||||
Reader test = new InputStreamReader( new FileInputStream( actual ), StandardCharsets.UTF_8 ) )
|
||||
{
|
||||
XMLUnit.setIgnoreComments( true );
|
||||
XMLUnit.setIgnoreWhitespace( true );
|
||||
XMLAssert.assertXMLEqual( control, test );
|
||||
}
|
||||
|
||||
assertThat( actual, CompareMatcher.isIdenticalTo(expected).ignoreComments().ignoreWhitespace() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ under the License.
|
|||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>parent</name>
|
||||
<post>post@mailing.list.com</post>
|
||||
<subscribe>subscribe@mailing.list.com</subscribe>
|
||||
<unsubscribe>unsubscribe@mailing.list.com</unsubscribe>
|
||||
<post>post@mailing.list.com</post>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -66,6 +66,7 @@ under the License.
|
|||
<jxpathVersion>1.3</jxpathVersion>
|
||||
<resolverVersion>1.1.1</resolverVersion>
|
||||
<slf4jVersion>1.7.25</slf4jVersion>
|
||||
<xmlunitVersion>2.2.1</xmlunitVersion>
|
||||
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
|
||||
<!-- Control the name of the distribution and information output by mvn -->
|
||||
<distributionId>apache-maven</distributionId>
|
||||
|
@ -401,6 +402,18 @@ under the License.
|
|||
<version>${mockitoVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-core</artifactId>
|
||||
<version>${xmlunitVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-matchers</artifactId>
|
||||
<version>${xmlunitVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--bootstrap-start-comment-->
|
||||
</dependencyManagement>
|
||||
|
|
Loading…
Reference in New Issue