From 43e824ecee81833d8d7c6f92536e27cd683e9cae Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 24 Feb 2009 19:26:42 +0000 Subject: [PATCH] [MNG-2362] Deployed POM is not valid XML o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@747519 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...MavenITmng2362DeployedPomEncodingTest.java | 100 ++++++++++++++++++ .../test/resources/mng-2362/latin-1/main.jar | Bin 0 -> 345 bytes .../test/resources/mng-2362/latin-1/pom.xml | 71 +++++++++++++ .../src/test/resources/mng-2362/pom.xml | 40 +++++++ .../test/resources/mng-2362/utf-8/main.jar | Bin 0 -> 345 bytes .../src/test/resources/mng-2362/utf-8/pom.xml | 71 +++++++++++++ 7 files changed, 283 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2362DeployedPomEncodingTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-2362/latin-1/main.jar create mode 100644 its/core-it-suite/src/test/resources/mng-2362/latin-1/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-2362/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-2362/utf-8/main.jar create mode 100644 its/core-it-suite/src/test/resources/mng-2362/utf-8/pom.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 527bfe7b2e..dbdf7d7908 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -244,6 +244,7 @@ public class IntegrationTestSuite suite.addTestSuite( MavenITmng2591MergeInheritedPluginConfigTest.class ); suite.addTestSuite( MavenITmng2562TimestampTest.class ); suite.addTestSuite( MavenITmng2539PluginDependenciesComeFromPluginReposTest.class ); + suite.addTestSuite( MavenITmng2362DeployedPomEncodingTest.class ); suite.addTestSuite( MavenITmng2339BadProjectInterpolationTest.class ); suite.addTestSuite( MavenITmng2318LocalParentResolutionTest.class ); suite.addTestSuite( MavenITmng2293CustomPluginParamImplTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2362DeployedPomEncodingTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2362DeployedPomEncodingTest.java new file mode 100644 index 0000000000..5fb44bf277 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2362DeployedPomEncodingTest.java @@ -0,0 +1,100 @@ +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.FileUtils; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; + +/** + * This is a test set for MNG-2362. + * + * @author Benjamin Bentmann + */ +public class MavenITmng2362DeployedPomEncodingTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng2362DeployedPomEncodingTest() + { + super( "[2.0.5,)" ); + } + + /** + * Verify that installed/deployed POMs retain their original file encoding and don't get messed up by some + * transformation that erroneously uses the platform's default encoding for reading/writing them. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2362" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "utf-8/target" ); + verifier.deleteDirectory( "latin-1/target" ); + verifier.deleteArtifacts( "org.apache.maven.its.mng2362" ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + File pomFile; + + pomFile = new File( verifier.getArtifactPath( "org.apache.maven.its.mng2362", "utf-8", "0.1", "pom" ) ); + assertPomUtf8( pomFile ); + + pomFile = new File( testDir, "utf-8/target/repo/org/apache/maven/its/mng2362/utf-8/0.1/utf-8-0.1.pom" ); + assertPomUtf8( pomFile ); + + pomFile = new File( verifier.getArtifactPath( "org.apache.maven.its.mng2362", "latin-1", "0.1", "pom" ) ); + assertPomLatin1( pomFile ); + + pomFile = new File( testDir, "latin-1/target/repo/org/apache/maven/its/mng2362/latin-1/0.1/latin-1-0.1.pom" ); + assertPomLatin1( pomFile ); + } + + private void assertPomUtf8( File pomFile ) + throws Exception + { + String pom = FileUtils.fileRead( pomFile, "UTF-8" ); + String chars = "\u00DF\u0131\u03A3\u042F\u05D0\u20AC"; + assertPom( pomFile, pom, chars ); + } + + private void assertPomLatin1( File pomFile ) + throws Exception + { + String pom = FileUtils.fileRead( pomFile, "ISO-8859-1" ); + String chars = "\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF"; + assertPom( pomFile, pom, chars ); + } + + private void assertPom( File pomFile, String pom, String chars ) + throws Exception + { + String prefix = "TEST-CHARS: "; + int pos = pom.indexOf( prefix ); + assertTrue( "Corrupt data " + pom.substring( pos, pos + prefix.length() + chars.length() ) + " in " + pomFile, + pom.indexOf( prefix + chars ) >= 0 ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-2362/latin-1/main.jar b/its/core-it-suite/src/test/resources/mng-2362/latin-1/main.jar new file mode 100644 index 0000000000000000000000000000000000000000..51ee566df605c08b934a3cd873449c9daa08c327 GIT binary patch literal 345 zcmWIWW@Zs#-~d96fCwuFB*4kQ!r%MB z$s^J;v@=+yKhyk?rY8PWJX~!0l4oMt70*;(XMQUBSi}f+i13u?8}2}BKsdmgkx7IB v)gLfNg8YFB;0^=%3SBF*u^?X{fGv;-*NWt)0B=?{kSZo1tOe4?KpX}D1BXL2 literal 0 HcmV?d00001 diff --git a/its/core-it-suite/src/test/resources/mng-2362/latin-1/pom.xml b/its/core-it-suite/src/test/resources/mng-2362/latin-1/pom.xml new file mode 100644 index 0000000000..e4b2321344 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-2362/latin-1/pom.xml @@ -0,0 +1,71 @@ + + + + + + + + 4.0.0 + + org.apache.maven.its.mng2362 + latin-1 + 0.1 + + Maven Integration Test :: MNG-2362 + + TEST-CHARS: + + + + + maven-core-it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-artifact + 2.1-SNAPSHOT + + + test + validate + + main.jar + + + set + attach-pom + install + deploy + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-2362/pom.xml b/its/core-it-suite/src/test/resources/mng-2362/pom.xml new file mode 100644 index 0000000000..4bf0910084 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-2362/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng2362 + test + 0.1 + pom + + Maven Integration Test :: MNG-2362 + + Verify that installed/deployed POMs retain their original file encoding and don't get messed up by some + transformation that erroneously uses the platform's default encoding for reading/writing them. + + + + utf-8 + latin-1 + + diff --git a/its/core-it-suite/src/test/resources/mng-2362/utf-8/main.jar b/its/core-it-suite/src/test/resources/mng-2362/utf-8/main.jar new file mode 100644 index 0000000000000000000000000000000000000000..51ee566df605c08b934a3cd873449c9daa08c327 GIT binary patch literal 345 zcmWIWW@Zs#-~d96fCwuFB*4kQ!r%MB z$s^J;v@=+yKhyk?rY8PWJX~!0l4oMt70*;(XMQUBSi}f+i13u?8}2}BKsdmgkx7IB v)gLfNg8YFB;0^=%3SBF*u^?X{fGv;-*NWt)0B=?{kSZo1tOe4?KpX}D1BXL2 literal 0 HcmV?d00001 diff --git a/its/core-it-suite/src/test/resources/mng-2362/utf-8/pom.xml b/its/core-it-suite/src/test/resources/mng-2362/utf-8/pom.xml new file mode 100644 index 0000000000..b807d3ae96 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-2362/utf-8/pom.xml @@ -0,0 +1,71 @@ + + + + + + + + 4.0.0 + + org.apache.maven.its.mng2362 + utf-8 + 0.1 + + Maven Integration Test :: MNG-2362 + + TEST-CHARS: ßıΣЯא€ + + + + + maven-core-it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-artifact + 2.1-SNAPSHOT + + + test + validate + + main.jar + + + set + attach-pom + install + deploy + + + + + + +