Skip to content

Commit ff0f6e0

Browse files
authored
Merge pull request #735 from quickfix-j/chrjohn-empty-message
`DataDictionary`: removed check for empty message body
2 parents f0d3c19 + 61ead21 commit ff0f6e0

File tree

2 files changed

+8
-113
lines changed

2 files changed

+8
-113
lines changed

quickfixj-base/src/main/java/quickfix/DataDictionary.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ private void load(InputStream inputStream, DocumentBuilderFactory factory) throw
11551155
private int getIntegerAttributeIfDefined(final Element documentElement, final String attribute) throws ConfigError {
11561156
try {
11571157
return documentElement.hasAttribute(attribute)
1158-
? Integer.valueOf(documentElement.getAttribute(attribute)) : 0;
1158+
? Integer.parseInt(documentElement.getAttribute(attribute)) : 0;
11591159
} catch (NumberFormatException e) {
11601160
throw new ConfigError("Attribute " + attribute + " could not be parsed as Integer.", e);
11611161
}
@@ -1168,8 +1168,9 @@ public int getNumMessageCategories() {
11681168
private void load(Document document, String msgtype, Node node) throws ConfigError {
11691169
String name;
11701170
final NodeList fieldNodes = node.getChildNodes();
1171-
if (countElementNodes(fieldNodes) == 0) {
1172-
throw new ConfigError("No fields found: msgType=" + msgtype);
1171+
1172+
if (countElementNodes(fieldNodes) == 0 && (msgtype == HEADER_ID || msgtype == TRAILER_ID)) {
1173+
throw new ConfigError("No fields found in " + msgtype);
11731174
}
11741175

11751176
for (int j = 0; j < fieldNodes.getLength(); j++) {

quickfixj-base/src/test/java/quickfix/DataDictionaryTest.java

Lines changed: 4 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -205,59 +205,6 @@ public void testHeaderTrailerRequired() throws Exception {
205205
assertFalse("Unknown trailer field shows up as required", dd.isRequiredTrailerField(666));
206206
}
207207

208-
@Test
209-
public void testMessageWithNoChildren40() throws Exception {
210-
String data = "";
211-
data += "<fix major=\"4\" minor=\"0\">";
212-
data += " <header>";
213-
data += " <field name=\"BeginString\" required=\"Y\"/>";
214-
data += " </header>";
215-
data += " <trailer>";
216-
data += " <field name=\"CheckSum\" required=\"Y\"/>";
217-
data += " </trailer>";
218-
data += " <fields>";
219-
data += " <field number=\"1\" name=\"Account\" type=\"STRING\"/>";
220-
data += " <field number=\"8\" name=\"BeginString\" type=\"STRING\"/>";
221-
data += " <field number=\"10\" name=\"CheckSum\" type=\"STRING\"/>";
222-
data += " </fields>";
223-
data += " <messages>";
224-
data += " <message name=\"MessageWithNoChildren\" msgtype=\"msg\" msgcat=\"custom\"/>";
225-
data += " </messages>";
226-
data += "</fix>";
227-
228-
expectedException.expect(ConfigError.class);
229-
expectedException.expectMessage("No fields found: msgType=msg");
230-
231-
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
232-
}
233-
234-
@Test
235-
public void testMessageWithTextElement40() throws Exception {
236-
String data = "";
237-
data += "<fix major=\"4\" minor=\"0\">";
238-
data += " <header>";
239-
data += " <field name=\"BeginString\" required=\"Y\"/>";
240-
data += " </header>";
241-
data += " <trailer>";
242-
data += " <field name=\"CheckSum\" required=\"Y\"/>";
243-
data += " </trailer>";
244-
data += " <fields>";
245-
data += " <field number=\"1\" name=\"Account\" type=\"STRING\"/>";
246-
data += " <field number=\"8\" name=\"BeginString\" type=\"STRING\"/>";
247-
data += " <field number=\"10\" name=\"CheckSum\" type=\"STRING\"/>";
248-
data += " </fields>";
249-
data += " <messages>";
250-
data += " <message name=\"MessageWithNoChildren\" msgtype=\"msg\" msgcat=\"custom\">";
251-
data += " </message>";
252-
data += " </messages>";
253-
data += "</fix>";
254-
255-
expectedException.expect(ConfigError.class);
256-
expectedException.expectMessage("No fields found: msgType=msg");
257-
258-
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
259-
}
260-
261208
@Test
262209
public void testMessagesWithNoChildren40() throws Exception {
263210
String data = "";
@@ -328,7 +275,7 @@ public void testHeaderWithNoChildren40() throws Exception {
328275
data += "</fix>";
329276

330277
expectedException.expect(ConfigError.class);
331-
expectedException.expectMessage("No fields found: msgType=HEADER");
278+
expectedException.expectMessage("No fields found in HEADER");
332279

333280
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
334281
}
@@ -355,7 +302,7 @@ public void testHeaderWithTextElement40() throws Exception {
355302
data += "</fix>";
356303

357304
expectedException.expect(ConfigError.class);
358-
expectedException.expectMessage("No fields found: msgType=HEADER");
305+
expectedException.expectMessage("No fields found in HEADER");
359306

360307
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
361308
}
@@ -381,7 +328,7 @@ public void testTrailerWithNoChildren40() throws Exception {
381328
data += "</fix>";
382329

383330
expectedException.expect(ConfigError.class);
384-
expectedException.expectMessage("No fields found: msgType=TRAILER");
331+
expectedException.expectMessage("No fields found in TRAILER");
385332

386333
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
387334
}
@@ -408,7 +355,7 @@ public void testTrailerWithTextElement40() throws Exception {
408355
data += "</fix>";
409356

410357
expectedException.expect(ConfigError.class);
411-
expectedException.expectMessage("No fields found: msgType=TRAILER");
358+
expectedException.expectMessage("No fields found in TRAILER");
412359

413360
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
414361
}
@@ -462,59 +409,6 @@ public void testFieldsWithTextElement40() throws Exception {
462409
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
463410
}
464411

465-
@Test
466-
public void testMessageWithNoChildren50() throws Exception {
467-
String data = "";
468-
data += "<fix major=\"5\" minor=\"0\">";
469-
data += " <header>";
470-
data += " <field name=\"BeginString\" required=\"Y\"/>";
471-
data += " </header>";
472-
data += " <trailer>";
473-
data += " <field name=\"CheckSum\" required=\"Y\"/>";
474-
data += " </trailer>";
475-
data += " <fields>";
476-
data += " <field number=\"1\" name=\"Account\" type=\"STRING\"/>";
477-
data += " <field number=\"8\" name=\"BeginString\" type=\"STRING\"/>";
478-
data += " <field number=\"10\" name=\"CheckSum\" type=\"STRING\"/>";
479-
data += " </fields>";
480-
data += " <messages>";
481-
data += " <message name=\"MessageWithNoChildren\" msgtype=\"msg\" msgcat=\"custom\"/>";
482-
data += " </messages>";
483-
data += "</fix>";
484-
485-
expectedException.expect(ConfigError.class);
486-
expectedException.expectMessage("No fields found: msgType=msg");
487-
488-
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
489-
}
490-
491-
@Test
492-
public void testMessageWithTextElement50() throws Exception {
493-
String data = "";
494-
data += "<fix major=\"5\" minor=\"0\">";
495-
data += " <header>";
496-
data += " <field name=\"BeginString\" required=\"Y\"/>";
497-
data += " </header>";
498-
data += " <trailer>";
499-
data += " <field name=\"CheckSum\" required=\"Y\"/>";
500-
data += " </trailer>";
501-
data += " <fields>";
502-
data += " <field number=\"1\" name=\"Account\" type=\"STRING\"/>";
503-
data += " <field number=\"8\" name=\"BeginString\" type=\"STRING\"/>";
504-
data += " <field number=\"10\" name=\"CheckSum\" type=\"STRING\"/>";
505-
data += " </fields>";
506-
data += " <messages>";
507-
data += " <message name=\"MessageWithNoChildren\" msgtype=\"msg\" msgcat=\"custom\">";
508-
data += " </message>";
509-
data += " </messages>";
510-
data += "</fix>";
511-
512-
expectedException.expect(ConfigError.class);
513-
expectedException.expectMessage("No fields found: msgType=msg");
514-
515-
new DataDictionary(new ByteArrayInputStream(data.getBytes()));
516-
}
517-
518412
@Test
519413
public void testMessagesWithNoChildren50() throws Exception {
520414
String data = "";

0 commit comments

Comments
 (0)