/*
 * 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;

import java.rmi.RemoteException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.transaction.RollbackException;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.objectweb.jonas.stests.util.JTestCase;

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

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

    /*
     * Simplest test : 1 loop, no rollback, no delay
     */
    public void test_a4_d0_l1_m10_t1() throws Exception {
	manac(4, 0, 1, 10, 1);
    }

    /*
     * Simple test with more loop: 20 loop, no rollback, no delay
     */
    public void test_a4_d0_l20_m10_t1() throws Exception {
	manac(4, 0, 20, 10, 1);
    }
    /*
     * test rollback
     */
    public void test_a4_d0_l1_mrollback_t1() throws Exception {
	manac(4, 0, 1, initialValue + 1, 1);
    }

    /*
     * more accounts
     */
    public void test_amax_d0_l1_m10_t1() throws Exception {
	manac(maxAccounts, 0, 1, 10, 1);
    }

    /*
     * 10 accounts, 20 loops
     */
    public void test_a10_d0_l20_m10_t1() throws Exception {
	manac(10, 0, 20, 10, 1);
    }

    /*
     * more loops to get some rollbacks
     */
    public void test_a6_d0_l50_m400_t1() throws Exception {
	manac(6, 0, 50, 400, 1);
    }

    public static Test suite() {
	return new TestSuite(F_mono.class);
    }

    public static void main (String args[]) {
	String testtorun = null;
	// Get args
	for (int argn = 0; argn < args.length; argn++) {
	    String s_arg = args[argn];
	    Integer i_arg;
	    if (s_arg.equals("-n")) {
		testtorun = args[++argn];
	    }
	}
	if (testtorun == null) {
	    junit.textui.TestRunner.run(suite());
	} else {
	    junit.textui.TestRunner.run(new F_mono(testtorun));
	}
    }
}
