// Path: jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java
// public class TestRunnerServlet extends JsUnitServlet {
// 
//     protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//         Utility.log("TestRunnerServlet: Received request to run standalone test...");
//         StandaloneTest test = createTest();
//         TestResult result = TestRunner.run(test);
//         writeResponse(response, result);
//         Utility.log("TestRunnerServlet: ...Done");
//     }
// 
//     protected void writeResponse(HttpServletResponse response, TestResult result) throws IOException {
//         response.setContentType("text/xml");
//         OutputStream out = response.getOutputStream();
//         String resultString = result.wasSuccessful() ? "success" : "failure";
//         out.write(("<result>" + resultString + "</result>").getBytes());
//         out.close();
//     }
// 
//     protected StandaloneTest createTest() {
//         StandaloneTest standaloneTest = new StandaloneTest("testStandaloneRun");
//         standaloneTest.setServer(server);
//         return standaloneTest;
//     }
// }


import net.jsunit.servlet.JsUnitServlet;
import net.jsunit.servlet.ResultAcceptorServlet;
import net.jsunit.servlet.ResultDisplayerServlet;
import net.jsunit.servlet.TestRunnerServlet;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.handler.ResourceHandler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.start.Monitor;
import org.mortbay.util.MultiException;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
            configuration.configure(this);
            initialized = true;
        } catch (ConfigurationException ce) {
            System.err.println("Server initialization failed because property \"" + ce.getPropertyInError() + "\" has an invalid value of \"" + ce.getInvalidValue() + "\"");
            throw ce;
        }
    }

    public void start() throws MultiException {
        if (!initialized) {
            System.err.println("Cannot start server: not initialized");
            return;
        }
        try {
            setUpHttpServer();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        super.start();
        Utility.log(asString());
    }

    private void setUpHttpServer() throws IOException {
        addListener(":" + port);
        HttpContext context = getContext("/jsunit");
        ServletHandler handler;
        handler = new ServletHandler();
        handler.addServlet("JsUnitResultAcceptor", "/acceptor", ResultAcceptorServlet.class.getName());
        handler.addServlet("JsUnitResultDisplayer", "/displayer", ResultDisplayerServlet.class.getName());
// Path: jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java
// public class TestRunnerServlet extends JsUnitServlet {
// 
//     protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//         Utility.log("TestRunnerServlet: Received request to run standalone test...");
//         StandaloneTest test = createTest();
//         TestResult result = TestRunner.run(test);
//         writeResponse(response, result);
//         Utility.log("TestRunnerServlet: ...Done");
//     }
// 
//     protected void writeResponse(HttpServletResponse response, TestResult result) throws IOException {
//         response.setContentType("text/xml");
//         OutputStream out = response.getOutputStream();
//         String resultString = result.wasSuccessful() ? "success" : "failure";
//         out.write(("<result>" + resultString + "</result>").getBytes());
//         out.close();
//     }
// 
//     protected StandaloneTest createTest() {
//         StandaloneTest standaloneTest = new StandaloneTest("testStandaloneRun");
//         standaloneTest.setServer(server);
//         return standaloneTest;
//     }
// }


// Path: jsunit/java/src/net/jsunit/JsUnitServer.java
import net.jsunit.servlet.JsUnitServlet;
import net.jsunit.servlet.ResultAcceptorServlet;
import net.jsunit.servlet.ResultDisplayerServlet;
import net.jsunit.servlet.TestRunnerServlet;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.handler.ResourceHandler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.start.Monitor;
import org.mortbay.util.MultiException;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

            configuration.configure(this);
            initialized = true;
        } catch (ConfigurationException ce) {
            System.err.println("Server initialization failed because property \"" + ce.getPropertyInError() + "\" has an invalid value of \"" + ce.getInvalidValue() + "\"");
            throw ce;
        }
    }

    public void start() throws MultiException {
        if (!initialized) {
            System.err.println("Cannot start server: not initialized");
            return;
        }
        try {
            setUpHttpServer();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        super.start();
        Utility.log(asString());
    }

    private void setUpHttpServer() throws IOException {
        addListener(":" + port);
        HttpContext context = getContext("/jsunit");
        ServletHandler handler;
        handler = new ServletHandler();
        handler.addServlet("JsUnitResultAcceptor", "/acceptor", ResultAcceptorServlet.class.getName());
        handler.addServlet("JsUnitResultDisplayer", "/displayer", ResultDisplayerServlet.class.getName());
        handler.addServlet("JsUnitTestRunner", "/runner", TestRunnerServlet.class.getName());