1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.surefire.testng.conf;
20
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 import junit.framework.TestCase;
26 import org.apache.maven.surefire.api.testset.TestSetFailedException;
27
28 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER;
29 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP;
30 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER;
31
32
33
34
35 public class TestNG5141ConfiguratorTest extends TestCase {
36
37 public void testListenersOnSeparateLines() {
38 try {
39 String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER);
40 Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
41 List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP));
42 assertEquals(2, listeners.size());
43 fail();
44 } catch (TestSetFailedException e) {
45
46 }
47 }
48
49 public void testListenersOnTheSameLine() {
50 try {
51 String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER);
52 Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
53 List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP));
54 assertEquals(2, listeners.size());
55 fail();
56 } catch (TestSetFailedException e) {
57
58 }
59 }
60
61 private Map getConvertedOptions(String key, String value) throws TestSetFailedException {
62 TestNGMapConfigurator testNGMapConfigurator = new TestNG5141Configurator();
63 Map<String, String> raw = new HashMap<>();
64 raw.put(key, value);
65 return testNGMapConfigurator.getConvertedOptions(raw);
66 }
67 }