Package org.apache.openejb.test.object

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


    //
    // EntityBean interface methods
    //================================

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

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

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

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

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

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

        /*[6] Test getUserTransaction /////////*/
        try {
            ejbContext.getUserTransaction();
            policy.allow(OperationsPolicy.Context_getUserTransaction);
        } catch (final Exception e) {
        }

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

        /*[8] Test getPrimaryKey //////////////*/
        try {
            ejbContext.getPrimaryKey();
            policy.allow(OperationsPolicy.Context_getPrimaryKey);
        } catch (final IllegalStateException ise) {
        }

        /* TO DO:
         * Check for policy.Enterprise_bean_access
View Full Code Here

    //
    // EntityBean interface methods
    //================================

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

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

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

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

        /*[3] Test getRollbackOnly ////////////*/
        try {
            ejbContext.getRollbackOnly();
            policy.allow(OperationsPolicy.Context_getRollbackOnly);
        } catch (final 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 (final IllegalStateException ise) {
        }

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

        /*[7] Test Context_getPrimaryKey ///////////////
         *
         * TODO: Write this test.
         */
        try {
            ejbContext.getPrimaryKey();
            policy.allow(OperationsPolicy.Context_getPrimaryKey);
        } catch (final IllegalStateException ise) {
        }

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

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

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

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

     * </PRE>
     */
    public void test01_setEntityContext(){
        try{

        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        final Object expected = policy;
        final Object actual = ejbObject.getAllowedOperationsReport("setEntityContext");

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

     */
    public void TODO_test02_unsetEntityContext(){
        try{

        /* TO DO:  This test needs unique functionality to work */
        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        final Object expected = policy;
        final Object actual = ejbObject.getAllowedOperationsReport("unsetEntityContext");

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

     * </PRE>
     */
    public void test03_ejbCreate(){
        try{

        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        //TODO:0:policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
        //TODO:0:policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

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

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

    //   
    // EntityBean interface methods
    //================================

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

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

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

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

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

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

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

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

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

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

            final 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 (final IllegalStateException ise) {
        } catch (final javax.naming.NamingException ne) {
        }

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

     * </PRE>
     */
    public void test04_ejbPostCreate(){
        try{

        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        //TODO:0:policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
        //TODO:0:policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.Context_getEJBObject );
        policy.allow( OperationsPolicy.Context_getPrimaryKey );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        final Object expected = policy;
        final Object actual = ejbObject.getAllowedOperationsReport("ejbPostCreate");

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

     * </PRE>
     */
    public void test05_ejbRemove(){
        try{

        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        //TODO:0:policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
        //TODO:0:policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.Context_getEJBObject );
        policy.allow( OperationsPolicy.Context_getPrimaryKey );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

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

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

     * </PRE>
     */
    public void test06_ejbFind(){
        try{

        final OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        //TODO:0:policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
        //TODO:0:policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        final Object expected = policy;
        final Object actual = ejbObject.getAllowedOperationsReport("ejbFind");

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

TOP

Related Classes of org.apache.openejb.test.object.OperationsPolicy

Copyright © 2018 www.massapicom. 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.