Package org.apache.openejb.test.object

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


     * ______________________|__________________________________________________
     * </PRE>
     */
    public void test01_setSessionContext(){
        try {
            final OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
           
            final Object expected = policy;
            final Object actual = ejbObject.getAllowedOperationsReport("setSessionContext");
           
            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here


    public void test02_ejbCreate() {
  // The singleton session bean has container managed transactions
  // so, the test Context_getUserTransaction should fail, but,
  // it does not.  Someone should see why it does not fail.
        try {
            final OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_getEJBObject );
            policy.allow( OperationsPolicy.Context_getTimerService );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
           
            final Object expected = policy;
            final Object actual = ejbObject.getAllowedOperationsReport("ejbCreate");
           
            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

     * </PRE>
     */
    public void TODO_test03_ejbRemove(){
        try {
            /* TO DO:  This test needs unique functionality to work */
            final OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_getEJBObject );
            policy.allow( OperationsPolicy.Context_getTimerService );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
       
            final Object expected = policy;
            final Object actual = ejbObject.getAllowedOperationsReport("ejbRemove");
       
            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

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

            final Object expected = policy;
            final Object actual = ejbObject.getAllowedOperationsReport("businessMethod");
       
            assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

    public void _test05_ejbTimeout(){
        try {
            ejbObject.scheduleTimer("SingletonAllowedOperationsTests");
            timerSync.waitFor("SingletonAllowedOperationsTests");

            final OperationsPolicy policy = new OperationsPolicy();
            policy.allow( OperationsPolicy.Context_getEJBHome );
            policy.allow( OperationsPolicy.Context_getCallerPrincipal );
            policy.allow( OperationsPolicy.Context_getRollbackOnly );
            policy.allow( OperationsPolicy.Context_setRollbackOnly );
            policy.allow( OperationsPolicy.Context_isCallerInRole );
            policy.allow( OperationsPolicy.Context_getEJBObject );
            policy.allow( OperationsPolicy.Context_getTimerService );
            policy.allow( OperationsPolicy.Context_lookup );
            policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

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

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

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

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

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

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

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

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

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

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

        /*[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 {
            final InitialContext jndiContext = new InitialContext();

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

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

        allowedOperationsTable.put(methodName, policy);

View Full Code Here

     * </PRE>
     */
    public void test05_ejbRemove(){  
        try{
           
        OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
//        policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.Context_getEJBObject );
        policy.allow( OperationsPolicy.Context_getPrimaryKey );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        Object expected = policy;
        Object actual = ejbObject.getAllowedOperationsReport("ejbRemove");
   
        assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

     * </PRE>
     */
    public void TODO_test07_ejbSelect(){    
        try{
           
        OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
//        policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        Object expected = policy;
        Object actual = ejbObject.getAllowedOperationsReport("ejbSelect");
       
        assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

     * </PRE>
     */
    public void test08_ejbHome(){
        try{
           
        OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
//        policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
//        policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        Object expected = policy;
        Object actual = ejbObject.getAllowedOperationsReport("ejbHome");
   
        assertNotNull("The OperationsPolicy is null", actual );
View Full Code Here

     * </PRE>
     */
    public void TODO_test09_ejbSelectInEntity(){ 
        try{
           
        OperationsPolicy policy = new OperationsPolicy();
        policy.allow( OperationsPolicy.Context_getEJBHome );
        policy.allow( OperationsPolicy.Context_getCallerPrincipal );
        policy.allow( OperationsPolicy.Context_getRollbackOnly );
        policy.allow( OperationsPolicy.Context_isCallerInRole );
//        policy.allow( OperationsPolicy.Context_setRollbackOnly );
        policy.allow( OperationsPolicy.Context_getEJBObject );
        policy.allow( OperationsPolicy.Context_getPrimaryKey );
        policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );

        Object expected = policy;
        Object actual = ejbObject.getAllowedOperationsReport("ejbSelectInEntity");
   
        assertNotNull("The OperationsPolicy 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.