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.api.testset.TestSetFailedException;
24
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER;
30 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP;
31 import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER;
32
33
34
35
36 public class TestNG5141ConfiguratorTest extends TestCase
37 {
38
39 public void testListenersOnSeparateLines()
40 {
41 try
42 {
43 String listenersOnSeveralLines = String.format( "%s , %n %s", FIRST_LISTENER, SECOND_LISTENER );
44 Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines );
45 List listeners = (List) convertedOptions.get( String.format( "-%s", LISTENER_PROP ) );
46 assertEquals( 2, listeners.size() );
47 fail();
48 }
49 catch ( TestSetFailedException e )
50 {
51
52 }
53 }
54
55 public void testListenersOnTheSameLine()
56 {
57 try
58 {
59 String listenersOnSeveralLines = String.format( "%s,%s", FIRST_LISTENER, SECOND_LISTENER );
60 Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines );
61 List listeners = (List) convertedOptions.get( String.format( "-%s", LISTENER_PROP ) );
62 assertEquals( 2, listeners.size() );
63 fail();
64 }
65 catch ( TestSetFailedException e )
66 {
67
68 }
69 }
70
71 private Map getConvertedOptions( String key, String value ) throws TestSetFailedException
72 {
73 TestNGMapConfigurator testNGMapConfigurator = new TestNG5141Configurator();
74 Map<String, String> raw = new HashMap<>();
75 raw.put( key, value );
76 return testNGMapConfigurator.getConvertedOptions( raw );
77 }
78 }