1 package org.apache.maven.surefire.its;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.VerificationException;
23 import org.apache.maven.surefire.its.fixture.OutputValidator;
24 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.Parameterized;
29 import org.junit.runners.Parameterized.Parameter;
30 import org.junit.runners.Parameterized.Parameters;
31
32 import java.util.ArrayList;
33 import java.util.List;
34
35 import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
36 import static org.apache.maven.surefire.its.fixture.IsRegex.regex;
37 import static org.fest.assertions.Assertions.assertThat;
38 import static org.fest.util.Collections.set;
39 import static org.hamcrest.CoreMatchers.startsWith;
40 import static org.junit.Assert.assertThat;
41
42 @RunWith( Parameterized.class )
43 public class JUnitPlatformEnginesIT
44 extends SurefireJUnit4IntegrationTestCase
45 {
46 @Parameter
47 public String platform;
48
49 @Parameter( 1 )
50 public String jupiter;
51
52 @Parameter( 2 )
53 public String opentest;
54
55 @Parameter( 3 )
56 public String apiguardian;
57
58 @Parameters(name = "{0}")
59 public static Iterable<Object[]> regexVersions()
60 {
61 ArrayList<Object[]> args = new ArrayList<Object[]>();
62 args.add( new Object[] { "1.0.0", "5.0.0", "1.0.0", "1.0.0" } );
63 args.add( new Object[] { "1.1.1", "5.1.1", "1.0.0", "1.0.0" } );
64 args.add( new Object[] { "1.2.0", "5.2.0", "1.1.0", "1.0.0" } );
65 args.add( new Object[] { "1.3.1", "5.3.1", "1.1.1", "1.0.0" } );
66 args.add( new Object[] { "1.4.0-SNAPSHOT", "5.4.0-SNAPSHOT", "1.1.1", "1.0.0" } );
67 return args;
68 }
69
70 @Before
71 public void setUp()
72 {
73 assumeJavaVersion( 1.8d );
74 }
75
76 @Test
77 public void testToRegex()
78 {
79 String regex = toRegex( ".[]()*" );
80 assertThat( regex )
81 .isEqualTo( "\\.\\[\\]\\(\\).*" );
82 }
83
84 @Test
85 public void platform() throws VerificationException
86 {
87 OutputValidator validator = unpack( "junit-platform", '-' + platform )
88 .sysProp( "jupiter.version", jupiter )
89 .debugLogging()
90 .executeTest()
91 .verifyErrorFree( 1 );
92
93 String testClasspath = "[DEBUG] test(compact) classpath:"
94 + " test-classes"
95 + " classes"
96 + " junit-jupiter-engine-" + jupiter + ".jar"
97 + " apiguardian-api-" + apiguardian + ".jar"
98 + " junit-platform-engine-" + platform + ".jar"
99 + " junit-platform-commons-" + platform + ".jar"
100 + " opentest4j-" + opentest + ".jar"
101 + " junit-jupiter-api-" + jupiter + ".jar";
102
103 List<String> lines = validator.loadLogLines( startsWith( "[DEBUG] test(compact) classpath" ) );
104
105 assertThat( lines )
106 .hasSize( 1 );
107
108 String line = lines.get( 0 );
109
110 assertThat( set( line ), regex( toRegex( testClasspath ) ) );
111
112 String providerClasspath = "[DEBUG] provider(compact) classpath:"
113 + " surefire-junit-platform-*.jar"
114 + " surefire-api-*.jar"
115 + " surefire-logger-api-*.jar"
116 + " common-java5-*.jar"
117 + " junit-platform-launcher-1.3.1.jar";
118
119 lines = validator.loadLogLines( startsWith( "[DEBUG] provider(compact) classpath" ) );
120
121 assertThat( lines )
122 .hasSize( 1 );
123
124 line = lines.get( 0 );
125
126 assertThat( set( line ), regex( toRegex( providerClasspath ) ) );
127
128 String bootClasspath = "[DEBUG] boot(compact) classpath:"
129 + " surefire-booter-*.jar"
130 + " surefire-api-*.jar"
131 + " surefire-logger-api-*.jar"
132 + " test-classes"
133 + " classes"
134 + " junit-jupiter-engine-" + jupiter + ".jar"
135 + " apiguardian-api-" + apiguardian + ".jar"
136 + " junit-platform-engine-" + platform + ".jar"
137 + " junit-platform-commons-" + platform + ".jar"
138 + " opentest4j-" + opentest + ".jar"
139 + " junit-jupiter-api-" + jupiter + ".jar"
140 + " surefire-junit-platform-*.jar"
141 + " junit-platform-launcher-1.3.1.jar";
142
143 lines = validator.loadLogLines( startsWith( "[DEBUG] boot(compact) classpath" ) );
144
145 assertThat( lines )
146 .hasSize( 1 );
147
148 line = lines.get( 0 );
149
150 assertThat( set( line ), regex( toRegex( bootClasspath ) ) );
151 }
152
153 private static String toRegex(String text) {
154 return text.replaceAll( "\\.", "\\\\." )
155 .replaceAll( "\\[", "\\\\[" )
156 .replaceAll( "]", "\\\\]" )
157 .replaceAll( "\\(", "\\\\(" )
158 .replaceAll( "\\)", "\\\\)" )
159 .replaceAll( "\\*", ".*" );
160 }
161 }