Skip to content

Commit bf9f533

Browse files
committed
Implements safer retrieval of properties, yielding informative test failures
1 parent 84e3a5d commit bf9f533

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ public static String getStringFromInputStream(InputStream is) {
7171
/** The prop. */
7272
protected Properties prop = new Properties();
7373

74+
public String getExistingProperty(String property) {
75+
String value = prop.getProperty(property);
76+
if(value == null) throw new IllegalStateException("A property expected to exist does not exist: " + property);
77+
return value;
78+
}
79+
public String getValidProperty(String property) {
80+
String value = getExistingProperty(property);
81+
if("".equals(value)) throw new IllegalStateException("Property " + property + " is empty. It's probably unset.");
82+
return value;
83+
}
84+
7485
/**
7586
* Sets the up.
7687
*

0 commit comments

Comments
 (0)