/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.stests.manac;

/**
 * Set of test with only 1 thread at a time.
 */
public abstract class A_mono extends A_manac {

    // default values
    int accounts = 20;          // 20 accounts (nb of pre-created accounts)
    int delay = 0;              // no delay added
    int loops = 1;              // 1 loop
    int amount = 10;            // withdraw value : 10 (initial value is 1000)
    int threads = 1;            // 1 thread (mono!)
    int checklevel = 2;         // check accounts after every test
    int timeout = 12;           // 12 seconds

    public A_mono(String name) {
        super(name);
    }

    public int getAccounts() {
        return accounts;
    }

    /*
     * Simplest test : 1 loop, no rollback, no delay
     */
    public void testBasic() throws Exception {
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    public void testLoop() throws Exception {
        int loops = 40;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    /*
     * test rollback
     */
    public void testRb() throws Exception {
        int amount = 2000;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    public void testDelay() throws Exception {
        int accounts = 4;
        int delay = 3;
        int loops = 6;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    public void testCreate() throws Exception {
        int accounts = 200;
        int loops = 12;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    public void testCreateRb() throws Exception {
        int accounts = 100;
        int loops = 10;
        int amount = 444;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }

    /**
     * test with a timeout shorter than the transaction
     * -> transaction will be rolled back.
     */
    public void testTimeout() throws Exception {
        int timeout = 3;
        int delay = 5;
        manac(accounts, delay, loops, amount, threads, checklevel, timeout);
    }
}
