[MNG-1803] Provide line number information when there are errors processing a pom.xml

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@949706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-05-31 10:22:33 +00:00
parent 46ae5b81c4
commit 9480bebbf4
3 changed files with 127 additions and 0 deletions

View File

@ -459,6 +459,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng1957JdkActivationWithVersionRangeTest.class );
suite.addTestSuite( MavenITmng1908LegacySnapshotUpdateTest.class );
suite.addTestSuite( MavenITmng1830ShowVersionTest.class );
suite.addTestSuite( MavenITmng1803PomValidationErrorIncludesLineNumberTest.class );
suite.addTestSuite( MavenITmng1751ForcedMetadataUpdateDuringDeploymentTest.class );
suite.addTestSuite( MavenITmng1703PluginMgmtDepInheritanceTest.class );
suite.addTestSuite( MavenITmng1701DuplicatePluginTest.class );

View File

@ -0,0 +1,84 @@
package org.apache.maven.it;
/*
* 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.
*/
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
import java.util.Iterator;
import java.util.List;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-1803">MNG-1803</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng1803PomValidationErrorIncludesLineNumberTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng1803PomValidationErrorIncludesLineNumberTest()
{
super( "[3.0-beta-1,)" );
}
/**
* Verify that POM errors indicate the line and column number in the input file.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-1803" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
try
{
verifier.executeGoal( "validate" );
}
catch ( Exception e )
{
// expected
}
finally
{
verifier.resetStreams();
}
boolean foundError = false;
List lines = verifier.loadLines( verifier.getLogFileName(), null );
for ( Iterator it = lines.iterator(); it.hasNext(); )
{
String line = it.next().toString();
if ( line.indexOf( ":bad/id:" ) >= 0 )
{
assertTrue( "Line number not found in: " + line, line.indexOf( "38" ) > 0 );
assertTrue( "Column number not found in: " + line, line.indexOf( "19" ) > 0 );
foundError = true;
break;
}
}
assertTrue( "Build output did not mention validaton error!", foundError );
}
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng1803</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-1803</name>
<description>
Verify that POM errors indicate the line and column number in the input file.
</description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng1803</groupId>
<artifactId>:::bad/id:::</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
</project>