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
27 import com.google.common.base.Charsets;
28 import com.google.common.base.Joiner;
29 import com.google.common.io.Files;
30
31
32
33
34
35
36 public class MavenITmng6255FixConcatLines
37 extends AbstractMavenIntegrationTestCase
38 {
39 public MavenITmng6255FixConcatLines()
40 {
41 super( "[3.5.3,)" );
42 }
43
44 protected MavenITmng6255FixConcatLines( String constraint )
45 {
46 super( constraint );
47 }
48
49
50
51
52
53
54
55
56 public void disabledJvmConfigFileCR()
57 throws Exception
58 {
59 runWithLineEndings( "\r" );
60 }
61
62
63
64
65
66
67 public void testJvmConfigFileLF()
68 throws Exception
69 {
70 runWithLineEndings( "\n" );
71 }
72
73
74
75
76
77
78 public void testJvmConfigFileCRLF()
79 throws Exception
80 {
81 runWithLineEndings( "\r\n" );
82 }
83
84 protected void runWithLineEndings( String lineEndings )
85 throws Exception
86 {
87 File baseDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6255" );
88 File mvnDir = new File( baseDir, ".mvn" );
89
90 File jvmConfig = new File( mvnDir, "jvm.config" );
91 createJvmConfigFile( jvmConfig, lineEndings, "-Djvm.config=ok", "-Xms256m", "-Xmx512m" );
92
93 Verifier verifier = newVerifier( baseDir.getAbsolutePath() );
94 verifier.getCliOptions().add( "-Dexpression.outputFile=" + new File( baseDir, "expression.properties" ).getAbsolutePath() );
95 verifier.setForkJvm( true );
96 verifier.executeGoal( "validate" );
97 verifier.verifyErrorFreeLog();
98 verifier.resetStreams();
99
100 Properties props = verifier.loadProperties( "expression.properties" );
101 assertEquals( "ok", props.getProperty( "project.properties.jvm-config" ) );
102 }
103
104 protected void createJvmConfigFile( File jvmConfig, String lineEndings, String...lines )
105 throws Exception
106 {
107 String content = Joiner.on(lineEndings).join(lines);
108 Files.write( content, jvmConfig, Charsets.UTF_8 );
109 }
110 }