Package org.bladerunnerjs.testing.specutility.engine

Source Code of org.bladerunnerjs.testing.specutility.engine.AppServerBuilder

package org.bladerunnerjs.testing.specutility.engine;

import java.io.IOException;

import javax.servlet.Servlet;

import org.apache.http.client.ClientProtocolException;
import org.bladerunnerjs.appserver.ApplicationServer;
import org.bladerunnerjs.appserver.BRJSApplicationServer;
import org.bladerunnerjs.model.App;


public class AppServerBuilder
{

  BuilderChainer builderChainer;
  ApplicationServer appServer;
  SpecTest specTest;
 
  public AppServerBuilder(SpecTest specTest, ApplicationServer appServer)
  {
    this.appServer = appServer;
    this.specTest = specTest;
    builderChainer = new BuilderChainer(specTest);
  }

  public BuilderChainer started() throws Exception
  {
    appServer.start();
   
    return builderChainer;
  }
 
  public BuilderChainer stopped() throws Exception
  {
    appServer.stop();
   
    return builderChainer;
  }

  public BuilderChainer requestTimesOutFor(String urlPath) throws ClientProtocolException, IOException
  {
    String url = String.format("%s:%s%s", SpecTest.HTTP_REQUEST_PREFIX, specTest.appServerPort, urlPath);
    specTest.webappTester.requestTimesOut(url);
   
    return builderChainer;
  }

  public BuilderChainer appHasServlet(App app, Servlet servlet, String path) throws Exception
  {
    if ( !(appServer instanceof BRJSApplicationServer) )
    {
      throw new RuntimeException("appHasServlet can only be called when application server is an instance of  " + BRJSApplicationServer.class.getSimpleName());
    }
    BRJSApplicationServer brjsAppServer = (BRJSApplicationServer) appServer;
    brjsAppServer.addServlet(app, servlet, path);
   
    return builderChainer;
  }

  public BuilderChainer requestForUrlContains(String urlPath, String contains) throws ClientProtocolException, IOException
  {
    new AppServerVerifier(specTest, appServer).requestForUrlContains(urlPath, contains);
   
    return builderChainer;
  }
}
TOP

Related Classes of org.bladerunnerjs.testing.specutility.engine.AppServerBuilder

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.