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.Map;
23
24 import junit.framework.TestCase;
25 import org.apache.maven.surefire.api.testset.TestSetFailedException;
26
27 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER;
28 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP;
29 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER;
30
31
32
33
34 public class TestNG513ConfiguratorTest extends TestCase {
35
36 public void testListenersOnSeparateLines() throws Exception {
37 String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER);
38 Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
39 String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP));
40 assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
41 }
42
43 public void testListenersOnTheSameLine() throws Exception {
44 String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER);
45 Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
46 String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP));
47 assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
48 }
49
50 public void testReporter() throws Exception {
51 Map<String, Object> convertedOptions = getConvertedOptions("reporter", "classname");
52 String reporter = (String) convertedOptions.get("-reporterslist");
53 assertEquals("classname", reporter);
54 }
55
56 private Map getConvertedOptions(String key, String value) throws TestSetFailedException {
57 TestNGMapConfigurator testNGMapConfigurator = new TestNG513Configurator();
58 Map<String, String> raw = new HashMap<>();
59 raw.put(key, value);
60 return testNGMapConfigurator.getConvertedOptions(raw);
61 }
62 }