1
1
package datadog .trace .instrumentation .maven3 ;
2
2
3
- import static org .junit .Assert .assertTrue ;
3
+ import static org .junit .jupiter . api . Assertions .assertTrue ;
4
4
import static org .mockito .Mockito .mock ;
5
5
import static org .mockito .Mockito .when ;
6
6
12
12
import java .io .InputStreamReader ;
13
13
import java .io .PrintStream ;
14
14
import java .net .URISyntaxException ;
15
- import java .util .Arrays ;
16
- import java .util .Collection ;
17
15
import java .util .Collections ;
16
+ import java .util .stream .Stream ;
18
17
import org .apache .maven .execution .ExecutionEvent ;
19
18
import org .apache .maven .execution .MavenSession ;
20
19
import org .apache .maven .plugin .MojoExecution ;
21
20
import org .apache .maven .project .MavenProject ;
22
- import org .junit .Test ;
23
- import org .junit .runner . RunWith ;
24
- import org .junit .runners . Parameterized ;
21
+ import org .junit .jupiter . params . ParameterizedTest ;
22
+ import org .junit .jupiter . params . provider . Arguments ;
23
+ import org .junit .jupiter . params . provider . MethodSource ;
25
24
import org .slf4j .Logger ;
26
25
import org .slf4j .LoggerFactory ;
27
26
28
- @ RunWith (Parameterized .class )
29
27
public class MavenProjectConfiguratorTest extends AbstractMavenTest {
30
28
31
29
private static final Logger LOGGER = LoggerFactory .getLogger (MavenProjectConfiguratorTest .class );
32
30
33
- @ Parameterized .Parameters (name = "{0} - {1}" )
34
- public static Collection <Object []> surefireVersions () {
35
- return Arrays .asList (
36
- new Object [][] {
37
- {"sampleProject/pom.xml" , "test" , new String [] {"-X" , "-DargLine=-DmyArgLineProp=true" }},
38
- {
31
+ public static Stream <Arguments > surefireVersions () {
32
+ return Stream .of (
33
+ Arguments .of (
34
+ "sampleProject/pom.xml" , "test" , new String [] {"-X" , "-DargLine=-DmyArgLineProp=true" }),
35
+ Arguments .of (
39
36
"sampleProject/pom.xml" ,
40
37
"surefire:test" ,
41
- new String [] {"-X" , "-DargLine=-DmyArgLineProp=true" }
42
- },
43
- {"sampleProjectArgLine/pom.xml" , "test" , new String [] {"-X" }},
44
- {"sampleProjectArgLine/pom.xml" , "surefire:test" , new String [] {"-X" }},
45
- {"sampleProjectSurefireArgLine/pom.xml" , "test" , new String [] {"-X" }},
46
- {"sampleProjectSurefireArgLine/pom.xml" , "surefire:test" , new String [] {"-X" }},
47
- {"sampleProjectSurefireLateProcessingArgLine/pom.xml" , "test" , new String [] {"-X" }},
48
- });
38
+ new String [] {"-X" , "-DargLine=-DmyArgLineProp=true" }),
39
+ Arguments .of ("sampleProjectArgLine/pom.xml" , "test" , new String [] {"-X" }),
40
+ Arguments .of ("sampleProjectArgLine/pom.xml" , "surefire:test" , new String [] {"-X" }),
41
+ Arguments .of ("sampleProjectSurefireArgLine/pom.xml" , "test" , new String [] {"-X" }),
42
+ Arguments .of ("sampleProjectSurefireArgLine/pom.xml" , "surefire:test" , new String [] {"-X" }),
43
+ Arguments .of (
44
+ "sampleProjectSurefireLateProcessingArgLine/pom.xml" , "test" , new String [] {"-X" }));
49
45
}
50
46
51
- private final String pomPath ;
52
- private final String goal ;
53
- private final String [] additionalCmdLineArgs ;
54
-
55
- public MavenProjectConfiguratorTest (String pomPath , String goal , String [] additionalCmdLineArgs ) {
56
- this .pomPath = pomPath ;
57
- this .goal = goal ;
58
- this .additionalCmdLineArgs = additionalCmdLineArgs ;
59
- }
60
-
61
- @ Test
62
- public void testTracerInjection () throws Exception {
47
+ @ ParameterizedTest
48
+ @ MethodSource ("surefireVersions" )
49
+ public void testTracerInjection (String pomPath , String goal , String [] additionalCmdLineArgs )
50
+ throws Exception {
63
51
ByteArrayOutputStream stdOutBaos = new ByteArrayOutputStream ();
64
52
PrintStream buildOutput = new PrintStream (stdOutBaos );
65
53
@@ -85,8 +73,8 @@ public void testTracerInjection() throws Exception {
85
73
&& buildOutputLine .contains ("-DmyArgLineProp=true" );
86
74
}
87
75
88
- assertTrue ("Tracer wasn't injected" , javaAgentInjected );
89
- assertTrue ("Original argLine was not preserved" , argLinePreserved );
76
+ assertTrue (javaAgentInjected , "Tracer wasn't injected" );
77
+ assertTrue (argLinePreserved , "Original argLine was not preserved" );
90
78
91
79
} catch (Exception | Error e ) {
92
80
LOGGER .info ("Build output:\n \n " + stdOutBaos );
0 commit comments