Search in sources :

Example 1 with ReadSystemPropertyRemote

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);
    }
}
Also used : ReadSystemPropertyRemote(org.jboss.as.testsuite.integration.secman.ejbs.ReadSystemPropertyRemote) ReadSystemPropertyBean(org.jboss.as.testsuite.integration.secman.ejbs.ReadSystemPropertyBean) AccessControlException(java.security.AccessControlException) EJBException(javax.ejb.EJBException) NamingException(javax.naming.NamingException) EJBException(javax.ejb.EJBException) AccessControlException(java.security.AccessControlException)

Aggregations

AccessControlException (java.security.AccessControlException)1 EJBException (javax.ejb.EJBException)1 NamingException (javax.naming.NamingException)1 ReadSystemPropertyBean (org.jboss.as.testsuite.integration.secman.ejbs.ReadSystemPropertyBean)1 ReadSystemPropertyRemote (org.jboss.as.testsuite.integration.secman.ejbs.ReadSystemPropertyRemote)1