//@Test(expected=java.lang.IllegalArgumentException) JavaRegisterException(500,"java.lang.IllegalArgumentException", JAVA_OPTION_MATCH_SUBSTRING); ErrorAdd(FACILITY_NATIVE_JAVA, 500, SEVERITY_INFORMATIONAL); JUnit4CallFunc(ghTestObj, "doFoo", "doFoo", sBuffer); ErrorRemove(FACILITY_NATIVE_JAVA, 500); if (StrSearch(sBuffer, "java.lang.IllegalArgumentException", STR_SEARCH_FIRST) = 0) then RepMessage("method did not throw: java.lang.IllegalArgumentException", SEVERITY_ERROR); end;
The sample above tests a JUnit method that is expected to throw a java.lang.IllegalArgumentException. The function JavaRegisterException assigns the BDL error code 500 to the exception. The function ErrorAdd sets the error severity to informational because the error is expected. After that, the JUnit method doFoo is invoked, where the parameter sBuffer retrieves the error message. The ErrorRemove function sets the error handling back to its original state. It also verifies that the expected exception occurred, and throws a BDL error if this is not the case.