Package test.juju.reattore.loadtest.controller.impl

Source Code of test.juju.reattore.loadtest.controller.impl.TestSystem

/*  Reattore HTTP Server

    Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    $Id: TestSystem.java,v 1.4 2003/01/21 22:43:12 michaelh Exp $
*/

package test.juju.reattore.loadtest.controller.impl;

import junit.framework.*;
import java.net.URL;
import juju.reattore.core.reactor.impl.CombinedReactor;
import juju.reattore.loadtest.controller.*;
import juju.reattore.loadtest.controller.impl.*;

public class TestSystem
    extends TestCase {

    private Controller controller;
    private MockChooser chooser;
    private CombinedReactor reactor;
    private ReactorThread reactorThread;
    private MockServer server;

    protected void setUp()
        throws Exception {

        chooser = new MockChooser();
        chooser.addTarget(new URL("http://localhost:8081/"));

        reactor = new CombinedReactor();
        controller = new BaseController(chooser, reactor);

        server = new MockServer(8081);
        server.start();

        reactorThread = new ReactorThread(reactor);
        reactorThread.start();
    }

    protected void tearDown() {
        reactorThread.end();
        server.end();
    }

    public void testGo() {
        controller.go(10.0, 2.0);

        reactorThread.end();
        server.end();

        assertEquals(20, chooser.getNumHits());
        assertEquals(20, server.getNumHits());
    }

    public void testZeroRun() {
        controller.go(10.0, 0.0);

        reactorThread.end();
        server.end();

        assertEquals(1, chooser.getNumHits());
        assertEquals(1, server.getNumHits());
    }

    public void testGo2() {
        controller.go(5, 0.1);

        reactorThread.end();
        server.end();

        assertEquals(5, chooser.getNumHits());
        assertEquals(5, server.getNumHits());
    }

    public void testZeroRun2() {
        controller.go(0, 0.0);

        reactorThread.end();
        server.end();

        assertEquals(1, chooser.getNumHits());
        assertEquals(1, server.getNumHits());
    }

    public void testOneRun() {
        controller.go(1, 0.0);

        reactorThread.end();
        server.end();

        assertEquals(1, chooser.getNumHits());
        assertEquals(1, server.getNumHits());
    }

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

Related Classes of test.juju.reattore.loadtest.controller.impl.TestSystem

TOP
Copyright © 2018 www.massapi.com. 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.