1 package org.apache.maven.surefire.testng.conf;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import junit.framework.TestCase;
26 import org.apache.maven.surefire.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 public class TestNG5143ConfiguratorTest
33 extends TestCase
34 {
35 public void testListenersOnSeparateLines()
36 throws Exception
37 {
38 String listenersOnSeveralLines = String.format( "%s , %n %s",
39 FIRST_LISTENER, SECOND_LISTENER);
40 Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
41 String listeners = (String) convertedOptions.get( String.format("-%s", LISTENER_PROP));
42 assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
43 }
44
45 public void testListenersOnTheSameLine()
46 throws Exception
47 {
48 String listenersOnSeveralLines = String.format( "%s,%s",
49 FIRST_LISTENER, SECOND_LISTENER);
50 Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines);
51 String listeners = (String) convertedOptions.get( String.format("-%s", LISTENER_PROP));
52 assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
53 }
54
55 public void testReporter()
56 throws Exception
57 {
58 Map<String, Object> convertedOptions = getConvertedOptions( "reporter", "classname" );
59 assertNull( "classname", convertedOptions.get( "-reporterslist" ) );
60 String reporter = (String) convertedOptions.get("-reporter" );
61 assertEquals( "classname", reporter );
62 }
63
64 private Map getConvertedOptions( String key, String value )
65 throws TestSetFailedException
66 {
67 TestNGMapConfigurator testNGMapConfigurator = new TestNG5143Configurator();
68 Map<String, String> raw = new HashMap<>();
69 raw.put( key, value );
70 return testNGMapConfigurator.getConvertedOptions( raw );
71 }
72 }