/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2005 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 1any 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.jonasadmin.test.service.resource;

import com.meterware.httpunit.Button;
import com.meterware.httpunit.WebForm;

/**
 * Class for filling resource forms.
 * @author Paul Kemler
 */
public class ResourceUtils {

    /**
     * Modify pool properties
     * @param form the pool property form
     * @param jdbcConnCheckLevel the value of Checking level
     * @param connMaxAge the value of Maximum age
     * @param maxOpentime the value of Maximum open time
     * @param jdbcTestStatement SQL query for test statement
     * @param maxSize the value of Pool maximum
     * @param minSize the value of Pool minimum
     * @param maxWaitTime the value of Max Wait Time
     * @param maxWaiters the value of Max Waiters
     * @param samplingPeriod the value of Sampling Period
     * @throws Exception if an error occurs when button is clicked
     */
    public static void modifyPoolProperties(WebForm form, String jdbcConnCheckLevel, String connMaxAge,
            String maxOpentime, String jdbcTestStatement, String maxSize, String minSize, String maxWaitTime,
            String maxWaiters, String samplingPeriod) throws Exception {

        Button button = null;

        form.setParameter("jdbcConnCheckLevel", jdbcConnCheckLevel);
        form.setParameter("connMaxAge", connMaxAge);
        form.setParameter("maxOpentime", maxOpentime);
        form.setParameter("jdbcTestStatement", jdbcTestStatement);
        form.setParameter("maxSize", maxSize);
        form.setParameter("minSize", minSize);
        form.setParameter("maxWaitTime", maxWaitTime);
        form.setParameter("maxWaiters", maxWaiters);
        form.setParameter("samplingPeriod", samplingPeriod);

        button = form.getButtons()[0];
        button.click();
    }
}
