1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.surefire.its.jiras;
20
21 import org.apache.maven.surefire.its.fixture.OutputValidator;
22 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
23 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
24 import org.junit.Test;
25
26 import static org.junit.Assert.assertFalse;
27
28
29
30
31
32
33 public class Surefire1053SystemPropertiesIT extends SurefireJUnit4IntegrationTestCase {
34 @Test
35 public void checkWarningsFileEncoding() {
36 unpack().sysProp("file.encoding", "ISO-8859-1")
37 .executeTest()
38 .verifyErrorFree(1)
39 .verifyTextInLog("file.encoding cannot be set as system property, use <argLine>-D"
40 + "file.encoding=...</argLine> instead");
41 }
42
43 @Test
44 public void checkWarningsSysPropTwice() throws Exception {
45 OutputValidator validator = unpack().argLine("-DmyArg=myVal2 -Dfile.encoding=ISO-8859-1")
46 .sysProp("file.encoding", "ISO-8859-1")
47 .executeTest()
48 .verifyErrorFree(1)
49 .verifyTextInLog("The system property myArg is configured twice! "
50 + "The property appears in <argLine/> and any of <systemPropertyVariables/>, "
51 + "<systemProperties/> or user property.");
52
53 for (String line : validator.loadLogLines()) {
54 assertFalse(
55 "no warning for file.encoding not in argLine",
56 line.contains("file.encoding cannot be set as system property, use <argLine>"));
57 assertFalse(
58 "no warning for double definition of file.encoding",
59 line.contains("The system property file.encoding is configured twice!"));
60 }
61 }
62
63 private SurefireLauncher unpack() {
64 return unpack("surefire-1053-system-properties");
65 }
66 }