11package datadog .trace .instrumentation .maven3 ;
22
3- import static org .junit .Assert .assertTrue ;
3+ import static org .junit .jupiter . api . Assertions .assertTrue ;
44import static org .mockito .Mockito .mock ;
55import static org .mockito .Mockito .when ;
66
1212import java .io .InputStreamReader ;
1313import java .io .PrintStream ;
1414import java .net .URISyntaxException ;
15- import java .util .Arrays ;
16- import java .util .Collection ;
1715import java .util .Collections ;
16+ import java .util .stream .Stream ;
1817import org .apache .maven .execution .ExecutionEvent ;
1918import org .apache .maven .execution .MavenSession ;
2019import org .apache .maven .plugin .MojoExecution ;
2120import 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 ;
2524import org .slf4j .Logger ;
2625import org .slf4j .LoggerFactory ;
2726
28- @ RunWith (Parameterized .class )
2927public class MavenProjectConfiguratorTest extends AbstractMavenTest {
3028
3129 private static final Logger LOGGER = LoggerFactory .getLogger (MavenProjectConfiguratorTest .class );
3230
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 (
3936 "sampleProject/pom.xml" ,
4037 "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" }));
4945 }
5046
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 {
6351 ByteArrayOutputStream stdOutBaos = new ByteArrayOutputStream ();
6452 PrintStream buildOutput = new PrintStream (stdOutBaos );
6553
@@ -85,8 +73,8 @@ public void testTracerInjection() throws Exception {
8573 && buildOutputLine .contains ("-DmyArgLineProp=true" );
8674 }
8775
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" );
9078
9179 } catch (Exception | Error e ) {
9280 LOGGER .info ("Build output:\n \n " + stdOutBaos );
0 commit comments