use of org.jboss.as.testsuite.integration.secman.ejbs.ReadSystemPropertyRemote in project wildfly by wildfly.
the class EarModulesPPTestCase method checkPropertyEjb.
/**
* Checks access to a system property on the server using EJB.
*
* @param moduleName
* @param propertyName
* @param exceptionExpected
* @param expectedValue
* @throws Exception
*/
private void checkPropertyEjb(final String moduleName, final String propertyName, final boolean exceptionExpected, final String expectedValue) throws Exception {
LOGGER.debug("Checking if '" + propertyName + "' property is available");
ReadSystemPropertyRemote bean = lookupEjb(moduleName, EJBAPP_BASE_NAME + moduleName, ReadSystemPropertyBean.class.getSimpleName(), ReadSystemPropertyRemote.class);
assertNotNull(bean);
Exception ex = null;
String propertyValue = null;
try {
propertyValue = bean.readSystemProperty(propertyName);
} catch (Exception e) {
ex = e;
}
if (ex instanceof EJBException && ex.getCause() instanceof AccessControlException) {
assertTrue("AccessControlException came, but it was not expected", exceptionExpected);
} else if (ex != null) {
throw ex;
} else if (exceptionExpected) {
fail("AccessControlException was expected");
}
if (ex == null && expectedValue != null) {
assertEquals("System property value doesn't match the expected one.", expectedValue, propertyValue);
}
}
Aggregations