Skip to content

Commit

Permalink
Update error message for missing required properties, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Feb 18, 2011
1 parent cbe3189 commit 7b8a1cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public static NodeEntryImpl createFromMap(final Map<String, Object> map) throws
e.printStackTrace();
}
if (null == nodeEntry.getNodename()) {
throw new IllegalArgumentException("nodename was not specified");
throw new IllegalArgumentException("Required property 'nodename' was not specified");
}
if (null == nodeEntry.getHostname()) {
throw new IllegalArgumentException("hostname was not specified");
throw new IllegalArgumentException("Required property 'hostname' was not specified");
}

//XXX: node entry refactor will change this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ public void testShouldReadEditUrls() throws Exception{
}
}
public void testParseInvalid() throws Exception {
{
//no hostname value
testReceiver recv = new testReceiver();
ByteArrayInputStream is = new ByteArrayInputStream(
"- \n hostname: bill\n blah: test\n".getBytes());

NodesYamlParser nodesYamlParser = new NodesYamlParser(is, recv);
try {
nodesYamlParser.parse();
fail("parsing should fail");
} catch (NodeFileParserException e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertEquals("Required property 'nodename' was not specified", e.getCause().getMessage());
}

}
{
//no hostname value
testReceiver recv = new testReceiver();
Expand All @@ -272,7 +288,7 @@ public void testParseInvalid() throws Exception {
fail("parsing should fail");
} catch (NodeFileParserException e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertEquals("hostname was not specified", e.getCause().getMessage());
assertEquals("Required property 'hostname' was not specified", e.getCause().getMessage());
}

}
Expand Down

0 comments on commit 7b8a1cf

Please sign in to comment.