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