Package com.sun.jini.test.share

Examples of com.sun.jini.test.share.TestParticipant


public class JoinIdempotentTest extends TxnManagerTest {

    public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        TestParticipant part = null;

        startTxnMgr();

        part = new TestParticipantImpl();

        try {
            mgr = manager();

            if (DEBUG) {
                System.out.println("JoinIdempotentTest: run: mgr = " + mgr);
            }
            cr = TransactionFactory.create(mgr, Lease.FOREVER);
            part.setBehavior(OP_JOIN);
            part.setBehavior(OP_INCR_CRASHCOUNT);
            part.setBehavior(OP_JOIN_IDEMPOTENT);
            part.behave(cr.transaction);
        } catch (CrashCountException cce) {
            if (DEBUG) {
                cce.printStackTrace();
                logger.log(Level.INFO, cce.getMessage());
            }

            try {
                part.clearBehavior(OP_JOIN_IDEMPOTENT);
                part.clearBehavior(OP_INCR_CRASHCOUNT);
                cr.transaction.abort();
            } catch (Exception e) {

                // ignore any exceptions at this point
            }
        }

        mgr = manager();

        if (DEBUG) {
            System.out.println("JoinIdempotentTest: run: mgr = " + mgr);
        }
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        part.setBehavior(OP_JOIN);
        part.setBehavior(OP_VOTE_NOTCHANGED);
        part.behave(cr.transaction);
        cr.transaction.commit();

        return;
    }
View Full Code Here


    public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        ServerTransaction str = null;
        TestParticipant part = null;
        int state = 0;

        startTxnMgr();

        part = new TestParticipantImpl();

        try {
            mgr = manager();

            if (DEBUG) {
                System.out.println("CommitExpiredTest: run: mgr = " + mgr);
            }
            cr = TransactionFactory.create(mgr, FORTY_SECONDS);
            str = (ServerTransaction) cr.transaction;
            part.setBehavior(OP_JOIN);
            part.setBehavior(OP_VOTE_PREPARED);
            part.behave(cr.transaction);

            try {
                Thread.sleep(FORTY_SECONDS + SLOP);
            } catch (InterruptedException ie) {}
View Full Code Here

    boolean DEBUG = true;

    public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        TestParticipant part = null;

        startTxnMgr();

        part = new TestParticipantImpl();

        mgr = manager();

        if (DEBUG) {
            logger.log(Level.INFO, "PrepareTimeoutTest: run: mgr = " + mgr);
        }
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        part.setBehavior(OP_JOIN);
        part.setBehavior(OP_TIMEOUT_PREPARE);
        part.setBehavior(OP_VOTE_NOTCHANGED);
        part.behave(cr.transaction);
        cr.transaction.commit();
        part.clearBehavior(OP_VOTE_NOTCHANGED);

        mgr = manager();

        if (DEBUG) {
            logger.log(Level.INFO, "PrepareTimeoutTest: run: mgr = " + mgr);
        }
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        part.setBehavior(OP_JOIN);
        part.setBehavior(OP_TIMEOUT_PREPARE);
        part.setBehavior(OP_VOTE_PREPARED);
        part.behave(cr.transaction);
        cr.transaction.commit();
        part.clearBehavior(OP_VOTE_PREPARED);

        try {
            mgr = manager();

            if (DEBUG) {
                logger.log(Level.INFO, "PrepareTimeoutTest: run: mgr = " + mgr);
            }
            cr = TransactionFactory.create(mgr, Lease.FOREVER);
            part.setBehavior(OP_JOIN);
            part.setBehavior(OP_TIMEOUT_PREPARE);
            part.setBehavior(OP_VOTE_ABORTED);
            part.behave(cr.transaction);
            cr.transaction.commit();
      throw new TestException("CannotCommitException is not raised");
       } catch (CannotCommitException cce) {
            cce.printStackTrace();

            // Expected exception. Test passed.
            try {
                part.clearBehavior(OP_VOTE_ABORTED);
            } catch (RemoteException re1) {
                logger.log(Level.INFO,
         "PrepareTimeoutTest: run: " + re1.getMessage());
                re1.printStackTrace();
            }
View Full Code Here

    public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        ServerTransaction str = null;
        TestParticipant[] parts = null;
        TestParticipant tp = null;

        startTxnMgr();

        // Create a number of TestParticipants
        logger.log(Level.INFO,
       "RollForwardErrorTest: creating " + NUM_PARTICIPANTS
                + " participants");
        parts = TxnTestUtils.createParticipants(NUM_PARTICIPANTS);

        /*
         * All Participants will join and vote prepared.  One, randomly
         * chosen Participant will throw an exception when asked
         * to roll forward.  There are two major cases for this,
         * the first time a RemoteException is thrown.  The second
         * time, a TransactionException is thrown.
         */
        mgr = manager();

        if (DEBUG) {
            logger.log(Level.INFO, "RollForwardErrorTest: run: mgr = " + mgr);
        }
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        str = (ServerTransaction) cr.transaction;
        logger.log(Level.INFO, "RollForwardErrorTest: setting behavior for "
                + NUM_PARTICIPANTS + " participants");
        TxnTestUtils.setBulkBehavior(OP_JOIN, parts);
        TxnTestUtils.setBulkBehavior(OP_VOTE_PREPARED, parts);
        tp = TxnTestUtils.chooseOne(parts);
        tp.setBehavior(OP_EXCEPTION_ON_COMMIT);
        tp.setBehavior(EXCEPTION_REMOTE);
        TxnTestUtils.doBulkBehavior(cr.transaction, parts);
        logger.log(Level.INFO, "RollForwardErrorTest: commiting the txn");
        cr.transaction.commit();

        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        str = (ServerTransaction) cr.transaction;
        logger.log(Level.INFO, "RollForwardErrorTest: setting behavior for "
                + NUM_PARTICIPANTS + " participants");
        tp.clearBehavior(EXCEPTION_REMOTE);
        tp.setBehavior(EXCEPTION_TRANSACTION);
        TxnTestUtils.doBulkBehavior(cr.transaction, parts);
        logger.log(Level.INFO, "RollForwardErrorTest: commiting the txn");
        cr.transaction.commit();

        return;
View Full Code Here

    
     
     public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        TestParticipant part = null;

        startTxnMgr();

        part = new TestParticipantImpl();

        mgr = manager();

        logger.log(Level.INFO, "PrepareAndCommitExceptionTest: run: mgr = "
            + mgr);
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        logger.log(Level.INFO, "Created: cr = " + cr);       
        part.setBehavior(OP_JOIN);
        logger.log(Level.INFO, "Configured participant to join");       
        part.setBehavior(OP_EXCEPTION_ON_PREPARECOMMIT);
        logger.log(Level.INFO, "Configured participant to throw an exception");               
        part.setBehavior(EXCEPTION_REMOTE);       
        logger.log(Level.INFO, "Configured participant to throw RE 1st");               
        part.setBehavior(EXCEPTION_TRANSACTION);
        logger.log(Level.INFO, "Configured participant to throw UTE 2nd");                               
        logger.log(Level.INFO, "Configuring participant to behave");
        part.behave(cr.transaction);
        Clearer clearer = new Clearer(part);
        Thread t = new Thread(clearer);
        logger.log(Level.INFO, "Running clearer thread");                       
        t.start();
        logger.log(Level.INFO, "Committing transaction");                       
View Full Code Here

    
     
     public void run() throws Exception {
        TransactionManager mgr = null;
        Transaction.Created cr = null;
        TestParticipant part = null;

        startTxnMgr();

        part = new TestParticipantImpl();

        mgr = manager();

        logger.log(Level.INFO, "PrepareAndCommitExceptionTest2: run: mgr = " + mgr);
        cr = TransactionFactory.create(mgr, Lease.FOREVER);
        logger.log(Level.INFO, "Created: cr = " + cr);       
        part.setBehavior(OP_JOIN);
        logger.log(Level.INFO, "Configured participant to join");       
        part.setBehavior(OP_EXCEPTION_ON_PREPARECOMMIT);
        logger.log(Level.INFO, "Configured participant to throw an exception");               
        part.setBehavior(EXCEPTION_REMOTE);       
        logger.log(Level.INFO, "Configured participant to throw RE 1st");               
        part.setBehavior(EXCEPTION_TRANSACTION);
        logger.log(Level.INFO, "Configured participant to throw UTE 2nd");                               
        logger.log(Level.INFO, "Configuring participant to behave");
        part.behave(cr.transaction);
        Clearer clearer = new Clearer(part);
        Thread t = new Thread(clearer);
        logger.log(Level.INFO, "Running clearer thread");                       
        t.start();
        logger.log(Level.INFO, "Committing transaction");                       
View Full Code Here

TOP

Related Classes of com.sun.jini.test.share.TestParticipant

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.