From 8217c63a94727e73ba340247bf31ae4ba61a7e77 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 15:09:32 +0000 Subject: [PATCH 1/2] Initial plan From 2455b8d9b4aaaab1682e83a9bb564c188398d526 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 15:13:01 +0000 Subject: [PATCH 2/2] Fix XSL template and add test for nested component delimiter issue Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com> --- .../codegenerator/MessageSubclass.xsl | 2 +- .../NestedComponentDelimiterTest.java | 90 +++++++++++++++++++ .../codegenerator/NestedComponentsTest.xml | 45 ++++++++++ 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 quickfixj-codegenerator/src/test/java/org/quickfixj/codegenerator/NestedComponentDelimiterTest.java create mode 100644 quickfixj-codegenerator/src/test/resources/org/quickfixj/codegenerator/NestedComponentsTest.xml diff --git a/quickfixj-codegenerator/src/main/resources/org/quickfixj/codegenerator/MessageSubclass.xsl b/quickfixj-codegenerator/src/main/resources/org/quickfixj/codegenerator/MessageSubclass.xsl index 4333c3b62c..85ded0abf2 100644 --- a/quickfixj-codegenerator/src/main/resources/org/quickfixj/codegenerator/MessageSubclass.xsl +++ b/quickfixj-codegenerator/src/main/resources/org/quickfixj/codegenerator/MessageSubclass.xsl @@ -197,7 +197,7 @@ import quickfix.Group; - + 1). + */ +public class NestedComponentDelimiterTest { + + private File outputDirectory = new File("./target/test-output/nested-component-test"); + 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 + public void setup() throws IOException { + if (outputDirectory.exists()) { + FileUtils.cleanDirectory(outputDirectory); + } else { + outputDirectory.mkdirs(); + } + generator = new MessageCodeGenerator(); + System.out.println("Successfully created an instance of the QuickFIX source generator"); + } + + @Test + public void testNestedComponentGroupDelimiter() throws Exception { + // Generate code from the test specification + MessageCodeGenerator.Task task = new MessageCodeGenerator.Task(); + task.setName("NestedComponentsTest"); + task.setSpecification(dictFile); + task.setTransformDirectory(schemaDirectory); + task.setMessagePackage(messagePackage); + task.setOutputBaseDirectory(outputDirectory); + task.setFieldPackage(fieldPackage); + task.setOverwrite(true); + task.setOrderedFields(true); + task.setDecimalGenerated(false); + + generator.generate(task); + + // Verify that the NestedTwice component was generated + String componentPath = outputDirectory.getAbsolutePath() + "/quickfix/test/component/NestedTwice.java"; + File componentFile = new File(componentPath); + assertTrue("NestedTwice component file should exist", componentFile.exists()); + + // 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")); + + // Verify the ORDER array is present + assertTrue("ORDER array should be present", + fileContent.contains("private static final int[] ORDER =")); + + // 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);")); + + // Also verify it doesn't have an empty delimiter (the bug case) + assertFalse("Constructor should not have empty delimiter", + fileContent.contains("super(20001, , ORDER);")); + } + + private String readFileContent(File file) throws FileNotFoundException { + StringBuilder content = new StringBuilder(); + try (Scanner scanner = new Scanner(file)) { + while (scanner.hasNextLine()) { + content.append(scanner.nextLine()).append("\n"); + } + } + return content.toString(); + } +} diff --git a/quickfixj-codegenerator/src/test/resources/org/quickfixj/codegenerator/NestedComponentsTest.xml b/quickfixj-codegenerator/src/test/resources/org/quickfixj/codegenerator/NestedComponentsTest.xml new file mode 100644 index 0000000000..cc30480f10 --- /dev/null +++ b/quickfixj-codegenerator/src/test/resources/org/quickfixj/codegenerator/NestedComponentsTest.xml @@ -0,0 +1,45 @@ + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +