1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Properties;
24
25 import org.apache.maven.it.util.ResourceExtractor;
26 import org.apache.maven.shared.utils.Os;
27
28 import static org.hamcrest.CoreMatchers.anyOf;
29 import static org.hamcrest.CoreMatchers.endsWith;
30 import static org.junit.Assert.assertThat;
31
32
33
34
35 public class MavenITmng6386BaseUriPropertyTest
36 extends AbstractMavenIntegrationTestCase
37 {
38
39 public MavenITmng6386BaseUriPropertyTest()
40 {
41 super( "[3.5.4,)" );
42 }
43
44 public void testitMNG6386()
45 throws Exception
46 {
47 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6386" ).getCanonicalFile();
48
49 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
50 verifier.setAutoclean( false );
51 verifier.deleteDirectory( "target" );
52 verifier.setLogFileName( "log-basic.txt" );
53 verifier.executeGoal( "validate" );
54 verifier.verifyErrorFreeLog();
55 verifier.resetStreams();
56
57 Properties props = verifier.loadProperties( "target/profile.properties" );
58 String pomProperty = props.getProperty( "project.properties.pomProperty" );
59
60 assertEquals( testDir.toPath().toUri().toASCIIString(), pomProperty );
61
62 assertTrue( pomProperty.startsWith( "file:///" ) );
63 }
64
65 public void testitMNG6386UnicodeChars()
66 throws Exception
67 {
68 String fileEncoding = System.getProperty( "file.encoding" );
69
70
71
72
73 if ( Os.isFamily( Os.FAMILY_WINDOWS ) ||
74 "UTF-8".equalsIgnoreCase( fileEncoding ) || "UTF8".equalsIgnoreCase( fileEncoding ) )
75 {
76 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6386-это по-русский" ).getCanonicalFile();
77
78 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
79 verifier.setAutoclean( false );
80 verifier.deleteDirectory( "target" );
81 verifier.setLogFileName( "log-basic.txt" );
82 verifier.executeGoal( "validate" );
83 verifier.verifyErrorFreeLog();
84 verifier.resetStreams();
85
86 Properties props = verifier.loadProperties( "target/profile.properties" );
87 String pomProperty = props.getProperty( "project.properties.pomProperty" );
88
89 assertEquals( testDir.toPath().toUri().toASCIIString(), pomProperty );
90
91 assertTrue( pomProperty.startsWith( "file:///" ) );
92
93
94 assertThat( pomProperty, anyOf( endsWith( "%D1%8D%D1%82%D0%BE%20%D0%BF%D0%BE-%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9/" ),
95 endsWith( "%D1%8D%D1%82%D0%BE%20%D0%BF%D0%BE-%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B8%CC%86/" ) ) );
96 }
97 else
98 {
99 System.out.println();
100 System.out.println( "[WARNING] Skipping MNG-6386 Unicode Chars Test on incompatible encoding: " + fileEncoding );
101 System.out.println();
102 }
103 }
104
105 }