Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 84   Methods: 6
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MiniCauchoServer.java 100% 100% 100% 100%
coverage
 1    package net.sf.crispy.impl.caucho;
 2   
 3   
 4    import net.sf.crispy.impl.MiniHttpServer;
 5    import net.sf.crispy.impl.MiniServer;
 6   
 7    import org.apache.commons.logging.Log;
 8    import org.apache.commons.logging.LogFactory;
 9   
 10    import test.crispy.example.service.Echo;
 11    import test.crispy.example.service.EchoImpl;
 12   
 13    /**
 14    * Mini web server implementation with two servlets (BurlapServlet and HessianServlet).
 15    *
 16    * @author Linke
 17    *
 18    */
 19    public class MiniCauchoServer implements MiniServer {
 20   
 21    protected static final Log log = LogFactory.getLog (MiniServer.class);
 22   
 23    public static final int DEFAULT_PORT = 8091;
 24   
 25    public static final int SERVER_TYPE_BOTH = 0;
 26    public static final int SERVER_TYPE_BURLAP = 1;
 27    public static final int SERVER_TYPE_HESSIAN = 2;
 28   
 29   
 30    private MiniHttpServer server = null;
 31    private int serverType = SERVER_TYPE_BURLAP;
 32   
 33  1 public MiniCauchoServer() {
 34  1 this(SERVER_TYPE_BOTH, DEFAULT_PORT);
 35    }
 36   
 37  1 public MiniCauchoServer(int pvPort) {
 38  1 this(SERVER_TYPE_BOTH, pvPort);
 39    }
 40   
 41  6 public MiniCauchoServer(int pvServerType, int pvPort) {
 42  6 serverType = pvServerType;
 43  6 server = new MiniHttpServer(pvPort);
 44  6 server.setContext("/crispy");
 45    }
 46   
 47  4 public int getServerType() { return serverType;}
 48   
 49  13 public void addService (String pvServiceInterface, String pvServiceObject) {
 50  13 if (serverType == SERVER_TYPE_BURLAP) {
 51  6 server.addServlet("/burlap/*", BurlapServlet.class.getName(), pvServiceInterface, pvServiceObject);
 52  7 } else if (serverType == SERVER_TYPE_HESSIAN) {
 53  6 server.addServlet("/hessian/*", HessianServlet.class.getName(), pvServiceInterface, pvServiceObject);
 54    } else {
 55  1 server.addServlet("/burlap/*", BurlapServlet.class.getName(), pvServiceInterface, pvServiceObject);
 56  1 server.addServlet("/hessian/*", HessianServlet.class.getName(), pvServiceInterface, pvServiceObject);
 57    }
 58    }
 59   
 60  3 public void start() {
 61  3 try {
 62  3 server.start();
 63    } catch (Exception e) {
 64    if (log.isWarnEnabled()) {
 65    log.warn("Error by MiniCauchoServer stop: " + e);
 66    }
 67    }
 68    }
 69   
 70    public void stop() {
 71    try {
 72    server.stop();
 73    } catch (Exception e) {
 74    e.printStackTrace();
 75    }
 76    }
 77   
 78    public static void main(String[] args) {
 79    MiniCauchoServer miniServer = new MiniCauchoServer();
 80    miniServer.addService(Echo.class.getName(), EchoImpl.class.getName());
 81    miniServer.start();
 82    System.out.println("Server is started ...");
 83    }
 84    }