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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

<xsl:template match="text()"/>

<xsl:template match="/">/* Generated Java Source File */
<xsl:template match="/">
<xsl:variable name="generatedSource">/* Generated Java Source File */
/*******************************************************************************
* Copyright (c) quickfixengine.org All rights reserved.
*
Expand Down Expand Up @@ -63,6 +64,8 @@ public class MessageFactory implements quickfix.MessageFactory {
return null;
}
}
</xsl:variable>
<xsl:value-of select="replace(string($generatedSource), '[ \t]+(\r?\n|$)', '$1')"/>
</xsl:template>

<xsl:template name="switch-statement">
Expand Down Expand Up @@ -107,9 +110,12 @@ public class MessageFactory implements quickfix.MessageFactory {
<xsl:template mode="group-factories" match="component">
<xsl:param name="fullPath"/>
<xsl:variable name="name" select="@name"/>
<xsl:apply-templates mode="group-factories" select="key('components-by-name', $name)/group">
<xsl:with-param name="fullPath" select='$fullPath'/>
<xsl:apply-templates
mode="group-factories"
select="key('components-by-name', $name)/*[self::group or self::component]">
<xsl:with-param name="fullPath" select="$fullPath"/>
</xsl:apply-templates>
</xsl:template>


</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.quickfixj.codegenerator;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class MessageFactoryNestedComponentTest {

@TempDir
File outputDir;

@Test
public void generatesFactoryForNestedComponentGroup() throws Exception {

MessageCodeGenerator.Task task = new MessageCodeGenerator.Task();

task.setName("NestedComponentTest");
task.setSpecification(new File(
"src/test/resources/org/quickfixj/codegenerator/"
+ "MessageFactoryNestedComponent.xml"
));

task.setTransformDirectory(new File(
"src/main/resources/org/quickfixj/codegenerator"
));

task.setMessagePackage("quickfix.test");
task.setFieldPackage("quickfix.field");
task.setOutputBaseDirectory(outputDir);
task.setOverwrite(true);
task.setOrderedFields(true);
task.setDecimalGenerated(false);

new MessageCodeGenerator().generate(task);

File factoryFile = new File(
outputDir, "quickfix/test/MessageFactory.java"
);

String factory = new String(
Files.readAllBytes(factoryFile.toPath()),
StandardCharsets.UTF_8
);

assertTrue(
factory.contains(
"return new quickfix.test."
+ "TradeCaptureReport.NoUnderlyings();"
),
"Outer group should be generated"
);

assertTrue(
factory.contains(
"case quickfix.field.NoUnderlyingSecurityAltID.FIELD:"
),
"Group 457 factory case is missing"
);

assertTrue(
factory.contains(
"return new quickfix.test.TradeCaptureReport."
+ "NoUnderlyings.NoUnderlyingSecurityAltID();"
),
"Nested group factory class is missing"
);
}
}
Loading
Loading