Examples of OperationsPolicy


Examples of org.apache.openejb.test.object.OperationsPolicy

    //
    // SessionBean interface methods
    //================================

    protected void testAllowedOperations(String methodName) {
        OperationsPolicy policy = new OperationsPolicy();

        /*[0] Test getEJBHome /////////////////*/
        try {
            ejbContext.getEJBHome();
            policy.allow(OperationsPolicy.Context_getEJBHome);
        } catch (IllegalStateException ise) {
        }

        /*[1] Test getCallerPrincipal /////////*/
        try {
            ejbContext.getCallerPrincipal();
            policy.allow(OperationsPolicy.Context_getCallerPrincipal);
        } catch (IllegalStateException ise) {
        }

        /*[2] Test isCallerInRole /////////////*/
        try {
            ejbContext.isCallerInRole("TheMan");
            policy.allow(OperationsPolicy.Context_isCallerInRole);
        } catch (IllegalStateException ise) {
        }

        /*[3] Test getRollbackOnly ////////////*/
        try {
            ejbContext.getRollbackOnly();
            policy.allow(OperationsPolicy.Context_getRollbackOnly);
        } catch (IllegalStateException ise) {
        }

        /*[4] Test setRollbackOnly ////////////*/
        try {
            ejbContext.setRollbackOnly();
            policy.allow(OperationsPolicy.Context_setRollbackOnly);
        } catch (IllegalStateException ise) {
        }

        /*[5] Test getUserTransaction /////////*/
        try {
            ejbContext.getUserTransaction();
            policy.allow(OperationsPolicy.Context_getUserTransaction);
        } catch (IllegalStateException ise) {
        }

        /*[6] Test getEJBObject ///////////////*/
        try {
            ejbContext.getEJBObject();
            policy.allow(OperationsPolicy.Context_getEJBObject);
        } catch (IllegalStateException ise) {
        }

        /*[7] Test Context_getPrimaryKey ///////////////
                  *
                  * Can't really do this
                  */

        /*[8] Test JNDI_access_to_java_comp_env ///////////////*/
        try {
            InitialContext jndiContext = new InitialContext();

            String actual = (String) jndiContext.lookup("java:comp/env/stateless/references/JNDI_access_to_java_comp_env");

            policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
        } catch (IllegalStateException ise) {
        } catch (NamingException ne) {
        }

        /*[11] Test lookup /////////*/
        try {
            ejbContext.lookup("stateless/references/JNDI_access_to_java_comp_env");
            policy.allow(OperationsPolicy.Context_lookup);
        } catch (IllegalArgumentException ise) {
        }

        /*[12] Test getTimerService/////////*/
        try {
            ejbContext.getTimerService();
            policy.allow(OperationsPolicy.Context_getTimerService);
        } catch (IllegalStateException ise) {
        }

        allowedOperationsTable.put(methodName, policy);
    }
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

    //
    // SessionBean interface methods
    //================================

  protected void testAllowedOperations(String methodName) {
    OperationsPolicy policy = new OperationsPolicy();

    /*[0] Test getEJBHome /////////////////*/
    try {
      mdbContext.getEJBHome();
      policy.allow(policy.Context_getEJBHome);
    } catch (IllegalStateException ise) {
    }

    /*[1] Test getCallerPrincipal /////////*/
    try {
      mdbContext.getCallerPrincipal();
      policy.allow( policy.Context_getCallerPrincipal );
    } catch (IllegalStateException ise) {
    }

    /*[2] Test isCallerInRole /////////////*/
    try {
      mdbContext.isCallerInRole("TheMan");
      policy.allow( policy.Context_isCallerInRole );
    } catch (IllegalStateException ise) {
    }

    /*[3] Test getRollbackOnly ////////////*/
    try {
      mdbContext.getRollbackOnly();
      policy.allow( policy.Context_getRollbackOnly );
    } catch (IllegalStateException ise) {
    }

    /*[4] Test setRollbackOnly ////////////*/
        // Rollback causes message redelivery

    /*[5] Test getUserTransaction /////////*/
    try {
      mdbContext.getUserTransaction();
      policy.allow( policy.Context_getUserTransaction );
    } catch (IllegalStateException ise) {
    }

    /*[6] Test getEJBObject ///////////////
     *
     * MDBs don't have an ejbObject
     */

    /*[7] Test Context_getPrimaryKey ///////////////
     *
     * Can't really do this
     */

    /*[8] Test JNDI_access_to_java_comp_env ///////////////*/
    try {
      InitialContext jndiContext = new InitialContext();

      String actual = (String)jndiContext.lookup("java:comp/env/stateless/references/JNDI_access_to_java_comp_env");

      policy.allow( policy.JNDI_access_to_java_comp_env );
    } catch (IllegalStateException ise) {
    } catch (javax.naming.NamingException ne) {
    }

        /*[11] Test lookup /////////*/
        try {
            mdbContext.lookup("stateless/references/JNDI_access_to_java_comp_env");
            policy.allow( policy.Context_lookup );
        } catch (IllegalArgumentException ise) {
        }

    allowedOperationsTable.put(methodName, policy);

View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test01_setSessionContext(){
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_lookup);
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("setMessageDrivenContext");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test02_ejbCreate() {
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.Context_getUserTransaction );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("ejbCreate");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * </PRE>
     */
    public void TODO_test03_ejbRemove(){
        try {
            /* TO DO:  This test needs unique functionality to work */
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_getEJBObject );
            policy.allow( OperationsPolicy.Context_getUserTransaction );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("ejbRemove");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test04_businessMethod(){
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getUserTransaction );
            policy.allow( OperationsPolicy.Context_getCallerPrincipal );
            policy.allow( OperationsPolicy.Context_isCallerInRole );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("businessMethod");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test01_setSessionContext(){
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_lookup);
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("setMessageDrivenContext");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test02_ejbCreate() {
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_lookup);
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("ejbCreate");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * </PRE>
     */
    public void TODO_test03_ejbRemove(){
        try {
            /* TO DO:  This test needs unique functionality to work */
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_getEJBObject );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("ejbRemove");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

Examples of org.apache.openejb.test.object.OperationsPolicy

     * ______________________|__________________________________________________
     * </PRE>
     */
    public void TODO_test04_businessMethod(){
        try {
            OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getRollbackOnly );
            // policy.allow( OperationsPolicy.Context_setRollbackOnly );
            policy.allow( OperationsPolicy.Context_getCallerPrincipal );
            policy.allow( OperationsPolicy.Context_isCallerInRole );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

            Object expected = policy;
            Object actual = basicMdbObject.getAllowedOperationsReport("businessMethod");

            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.