View Javadoc
1   package org.apache.maven.it;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.Properties;
24  
25  import org.apache.maven.it.util.ResourceExtractor;
26  
27  /**
28   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-2254">MNG-2254</a>:
29   * it tests that pom.xml encoding is properly detected.
30   *
31   * @author <a href="mailto:herve.boutemy@free.fr">Hervé Boutemy</a>
32   *
33   */
34  public class MavenITmng2254PomEncodingTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng2254PomEncodingTest()
39      {
40          super( "(2.0.7,)" ); // 2.0.8+
41      }
42  
43      /**
44       * Verify that the encoding declaration of the POM is respected.
45       *
46       * @throws Exception in case of failure
47       */
48      public void testitMNG2254 ()
49          throws Exception
50      {
51          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2254" );
52  
53          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
54          verifier.setAutoclean( false );
55          verifier.deleteDirectory( "utf-8/target" );
56          verifier.deleteDirectory( "latin-1/target" );
57          verifier.executeGoal( "validate" );
58          verifier.verifyErrorFreeLog();
59          verifier.resetStreams();
60  
61          Properties utf8 = verifier.loadProperties( "utf-8/target/pom.properties" );
62          assertEquals( "TEST-CHARS: \u00DF\u0131\u03A3\u042F\u05D0\u20AC", utf8.getProperty( "project.description" ) );
63  
64          Properties latin1 = verifier.loadProperties( "latin-1/target/pom.properties" );
65          assertEquals( "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", latin1.getProperty( "project.description" ) );
66      }
67  
68  }