Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
<version>${saxon.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
Expand Down
24 changes: 13 additions & 11 deletions src/test/java/org/quickfixj/codegenerator/GoldenFileTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.quickfixj.codegenerator;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.IOException;
Expand All @@ -12,10 +12,10 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Golden-file regression test for the code generator.
Expand All @@ -35,8 +35,8 @@
*/
public class GoldenFileTest {

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@TempDir
File tempFolder;

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

private MessageCodeGenerator generator;

@Before
@BeforeEach
public void setup() {
generator = new MessageCodeGenerator();
}
Expand All @@ -57,7 +57,8 @@ public void setup() {

@Test
public void testFix42GenerationMatchesGolden() throws Exception {
File outputDir = tempFolder.newFolder("fix42");
File outputDir = new File(tempFolder, "fix42");
Assertions.assertTrue(outputDir.mkdir());
generateCode(fix42DictFile, "FIX42", "quickfix.fix42", outputDir);
assertMatchesGolden(new File(goldenBase, "fix42"), outputDir, "FIX42");
}
Expand All @@ -68,7 +69,8 @@ public void testFix42GenerationMatchesGolden() throws Exception {

@Test
public void testFix44GenerationMatchesGolden() throws Exception {
File outputDir = tempFolder.newFolder("fix44");
File outputDir = new File(tempFolder, "fix44");
Assertions.assertTrue(outputDir.mkdir());
generateCode(fix44DictFile, "FIX44", "quickfix.fix44", outputDir);
assertMatchesGolden(new File(goldenBase, "fix44"), outputDir, "FIX44");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.quickfixj.codegenerator;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Test for issue #1084: Verify that MessageCodeGenerator correctly sets the
Expand All @@ -19,16 +18,16 @@
*/
public class NestedComponentDelimiterTest {

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@TempDir
File tempFolder;

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

@Before
@BeforeEach
public void setup() throws IOException {
generator = new MessageCodeGenerator();
}
Expand All @@ -41,7 +40,7 @@ public void testNestedComponentGroupDelimiter() throws Exception {
task.setSpecification(dictFile);
task.setTransformDirectory(schemaDirectory);
task.setMessagePackage(messagePackage);
task.setOutputBaseDirectory(tempFolder.getRoot());
task.setOutputBaseDirectory(tempFolder);
task.setFieldPackage(fieldPackage);
task.setOverwrite(true);
task.setOrderedFields(true);
Expand All @@ -50,29 +49,29 @@ public void testNestedComponentGroupDelimiter() throws Exception {
generator.generate(task);

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

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

// Verify the NoEntries group class is present
assertTrue("NoEntries group class should be present",
fileContent.contains("public static class NoEntries extends Group"));
assertTrue(fileContent.contains("public static class NoEntries extends Group"),
"NoEntries group class should be present");

// Verify the ORDER array is present
assertTrue("ORDER array should be present",
fileContent.contains("private static final int[] ORDER ="));
assertTrue(fileContent.contains("private static final int[] ORDER ="),
"ORDER array should be present");

// Verify the constructor has the correct delimiter (58 is the field number for Text)
// The constructor should be: super(20001, 58, ORDER);
assertTrue("Constructor should contain correct delimiter",
fileContent.contains("super(20001, 58, ORDER);"));
assertTrue(fileContent.contains("super(20001, 58, ORDER);"),
"Constructor should contain correct delimiter");

// Also verify it doesn't have an empty delimiter (the bug case)
assertFalse("Constructor should not have empty delimiter",
fileContent.contains("super(20001, , ORDER);"));
assertFalse(fileContent.contains("super(20001, , ORDER);"),
"Constructor should not have empty delimiter");
}

private String readFileContent(File file) throws FileNotFoundException {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/quickfixj/codegenerator/OverwriteTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.quickfixj.codegenerator;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.apache.commons.io.FileUtils;

public class OverwriteTest {
Expand All @@ -23,7 +23,7 @@ public class OverwriteTest {
private boolean decimal = true;
private MessageCodeGenerator generator;

@Before
@BeforeEach
public void setup() throws IOException {
if (outputDirectory.exists()){
FileUtils.cleanDirectory(outputDirectory);
Expand Down
Loading