Skip to content

Commit

Permalink
Removing code-formats introduced from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Dec 18, 2014
1 parent e665e01 commit b73cccb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,14 @@ public void loadProperties(String restClientName){
for (Iterator<String> keys = props.getKeys(); keys.hasNext(); ){
String key = keys.next();
String prop = key;
if (prop.startsWith(getNameSpace())){
if (prop.length() <= getNameSpace().length() + 1) {
throw new RuntimeException(String.format("Property %s is invalid", prop));
try {
if (prop.startsWith(getNameSpace())){
prop = prop.substring(getNameSpace().length() + 1);
}
prop = prop.substring(getNameSpace().length() + 1);
setPropertyInternal(prop, getStringValue(props, key));
} catch (Exception ex) {
throw new RuntimeException(String.format("Property %s is invalid", prop));
}
setPropertyInternal(prop, getStringValue(props, key));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ public void testTypedValue() {
assertEquals(1000, config.get(CommonClientConfigKey.ConnectTimeout).intValue());
}

@Test(expected = RuntimeException.class)
@Test
public void shouldThrowExceptionForIncorrectProperties() {
ConfigurationManager.getConfigInstance().setProperty("myclient.ribbon.", "bar");
ConfigurationManager.getConfigInstance().setProperty("myclient.ribbon", "bar");
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.loadProperties("myclient");
String message = "";
try {
config.loadProperties("myclient");
} catch (RuntimeException ex) {
message = ex.getMessage();
}
assertEquals("Property ribbon is invalid", message);
}

@Test
Expand Down

0 comments on commit b73cccb

Please sign in to comment.