Skip to content

Commit 166362c

Browse files
authored
Merge pull request #10 from quickfix-j/copilot/check-unneeded-dependencies
chore: migrate tests to JUnit 5, remove junit-vintage-engine
2 parents 872a75a + 1c1fbfd commit 166362c

4 files changed

Lines changed: 37 additions & 36 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
<version>${saxon.version}</version>
9090
</dependency>
9191
<dependency>
92-
<groupId>org.junit.vintage</groupId>
93-
<artifactId>junit-vintage-engine</artifactId>
92+
<groupId>org.junit.jupiter</groupId>
93+
<artifactId>junit-jupiter</artifactId>
9494
<version>${junit.jupiter.version}</version>
9595
<scope>test</scope>
9696
</dependency>

src/test/java/org/quickfixj/codegenerator/GoldenFileTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.quickfixj.codegenerator;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.fail;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.fail;
55

66
import java.io.File;
77
import java.io.IOException;
@@ -12,10 +12,10 @@
1212
import java.util.stream.Collectors;
1313
import java.util.stream.Stream;
1414

15-
import org.junit.Before;
16-
import org.junit.Rule;
17-
import org.junit.Test;
18-
import org.junit.rules.TemporaryFolder;
15+
import org.junit.jupiter.api.Assertions;
16+
import org.junit.jupiter.api.BeforeEach;
17+
import org.junit.jupiter.api.Test;
18+
import org.junit.jupiter.api.io.TempDir;
1919

2020
/**
2121
* Golden-file regression test for the code generator.
@@ -35,8 +35,8 @@
3535
*/
3636
public class GoldenFileTest {
3737

38-
@Rule
39-
public TemporaryFolder tempFolder = new TemporaryFolder();
38+
@TempDir
39+
File tempFolder;
4040

4141
private File schemaDirectory = new File("./src/main/resources/org/quickfixj/codegenerator");
4242
private File goldenBase = new File("./src/test/resources/golden");
@@ -46,7 +46,7 @@ public class GoldenFileTest {
4646

4747
private MessageCodeGenerator generator;
4848

49-
@Before
49+
@BeforeEach
5050
public void setup() {
5151
generator = new MessageCodeGenerator();
5252
}
@@ -57,7 +57,8 @@ public void setup() {
5757

5858
@Test
5959
public void testFix42GenerationMatchesGolden() throws Exception {
60-
File outputDir = tempFolder.newFolder("fix42");
60+
File outputDir = new File(tempFolder, "fix42");
61+
Assertions.assertTrue(outputDir.mkdir());
6162
generateCode(fix42DictFile, "FIX42", "quickfix.fix42", outputDir);
6263
assertMatchesGolden(new File(goldenBase, "fix42"), outputDir, "FIX42");
6364
}
@@ -68,7 +69,8 @@ public void testFix42GenerationMatchesGolden() throws Exception {
6869

6970
@Test
7071
public void testFix44GenerationMatchesGolden() throws Exception {
71-
File outputDir = tempFolder.newFolder("fix44");
72+
File outputDir = new File(tempFolder, "fix44");
73+
Assertions.assertTrue(outputDir.mkdir());
7274
generateCode(fix44DictFile, "FIX44", "quickfix.fix44", outputDir);
7375
assertMatchesGolden(new File(goldenBase, "fix44"), outputDir, "FIX44");
7476
}

src/test/java/org/quickfixj/codegenerator/NestedComponentDelimiterTest.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package org.quickfixj.codegenerator;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

55
import java.io.File;
66
import java.io.FileNotFoundException;
77
import java.io.IOException;
88
import java.util.Scanner;
99

10-
import org.junit.Before;
11-
import org.junit.Rule;
12-
import org.junit.Test;
13-
import org.junit.rules.TemporaryFolder;
10+
import org.junit.jupiter.api.BeforeEach;
11+
import org.junit.jupiter.api.Test;
12+
import org.junit.jupiter.api.io.TempDir;
1413

1514
/**
1615
* Test for issue #1084: Verify that MessageCodeGenerator correctly sets the
@@ -19,16 +18,16 @@
1918
*/
2019
public class NestedComponentDelimiterTest {
2120

22-
@Rule
23-
public TemporaryFolder tempFolder = new TemporaryFolder();
21+
@TempDir
22+
File tempFolder;
2423

2524
private File dictFile = new File("./src/test/resources/org/quickfixj/codegenerator/NestedComponentsTest.xml");
2625
private File schemaDirectory = new File("./src/main/resources/org/quickfixj/codegenerator");
2726
private String fieldPackage = "quickfix.field";
2827
private String messagePackage = "quickfix.test";
2928
private MessageCodeGenerator generator;
3029

31-
@Before
30+
@BeforeEach
3231
public void setup() throws IOException {
3332
generator = new MessageCodeGenerator();
3433
}
@@ -41,7 +40,7 @@ public void testNestedComponentGroupDelimiter() throws Exception {
4140
task.setSpecification(dictFile);
4241
task.setTransformDirectory(schemaDirectory);
4342
task.setMessagePackage(messagePackage);
44-
task.setOutputBaseDirectory(tempFolder.getRoot());
43+
task.setOutputBaseDirectory(tempFolder);
4544
task.setFieldPackage(fieldPackage);
4645
task.setOverwrite(true);
4746
task.setOrderedFields(true);
@@ -50,29 +49,29 @@ public void testNestedComponentGroupDelimiter() throws Exception {
5049
generator.generate(task);
5150

5251
// Verify that the NestedTwice component was generated
53-
String componentPath = tempFolder.getRoot().getAbsolutePath() + "/quickfix/test/component/NestedTwice.java";
52+
String componentPath = tempFolder.getAbsolutePath() + "/quickfix/test/component/NestedTwice.java";
5453
File componentFile = new File(componentPath);
55-
assertTrue("NestedTwice component file should exist", componentFile.exists());
54+
assertTrue(componentFile.exists(), "NestedTwice component file should exist");
5655

5756
// Read the generated file and check for the correct constructor
5857
String fileContent = readFileContent(componentFile);
5958

6059
// Verify the NoEntries group class is present
61-
assertTrue("NoEntries group class should be present",
62-
fileContent.contains("public static class NoEntries extends Group"));
60+
assertTrue(fileContent.contains("public static class NoEntries extends Group"),
61+
"NoEntries group class should be present");
6362

6463
// Verify the ORDER array is present
65-
assertTrue("ORDER array should be present",
66-
fileContent.contains("private static final int[] ORDER ="));
64+
assertTrue(fileContent.contains("private static final int[] ORDER ="),
65+
"ORDER array should be present");
6766

6867
// Verify the constructor has the correct delimiter (58 is the field number for Text)
6968
// The constructor should be: super(20001, 58, ORDER);
70-
assertTrue("Constructor should contain correct delimiter",
71-
fileContent.contains("super(20001, 58, ORDER);"));
69+
assertTrue(fileContent.contains("super(20001, 58, ORDER);"),
70+
"Constructor should contain correct delimiter");
7271

7372
// Also verify it doesn't have an empty delimiter (the bug case)
74-
assertFalse("Constructor should not have empty delimiter",
75-
fileContent.contains("super(20001, , ORDER);"));
73+
assertFalse(fileContent.contains("super(20001, , ORDER);"),
74+
"Constructor should not have empty delimiter");
7675
}
7776

7877
private String readFileContent(File file) throws FileNotFoundException {

src/test/java/org/quickfixj/codegenerator/OverwriteTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package org.quickfixj.codegenerator;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

55
import java.io.File;
66
import java.io.FileNotFoundException;
77
import java.io.IOException;
88
import java.util.Scanner;
99

1010
import org.apache.maven.plugin.MojoExecutionException;
11-
import org.junit.Before;
12-
import org.junit.Test;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Test;
1313
import org.apache.commons.io.FileUtils;
1414

1515
public class OverwriteTest {
@@ -23,7 +23,7 @@ public class OverwriteTest {
2323
private boolean decimal = true;
2424
private MessageCodeGenerator generator;
2525

26-
@Before
26+
@BeforeEach
2727
public void setup() throws IOException {
2828
if (outputDirectory.exists()){
2929
FileUtils.cleanDirectory(outputDirectory);

0 commit comments

Comments
 (0)