Package edu.wpi.cs.wpisuitetng.network

Examples of edu.wpi.cs.wpisuitetng.network.Request


  /**
   * Test the setAsynchronous method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetAsynchronousIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setAsynchronous();
  }
View Full Code Here


  /**
   * Test the setConnectTimeout method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetConnectTimeoutIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setConnectTimeout(1000);
  }
View Full Code Here

  /**
   * Test the setReadTimeout method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetReadTimeoutIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setReadTimeout(1000);
  }
View Full Code Here

  /**
   * Test the setBody method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetBodyIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setBody("");
  }
View Full Code Here

  /**
   * Test the setHttpMethod method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetHttpMethodIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setHttpMethod(HttpMethod.GET);
  }
View Full Code Here

  /**
   * Test the setResponse method for an IllegalStateException.
   */
  @Test(expected = IllegalStateException.class)
  public void testSetResponseIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setResponse(new ResponseModel());
  }
View Full Code Here

    try {
      DummyServer server = new DummyServer(port);
      server.start();

      // Make a new POST Request.
      Request manualRequest = new Request(config, null, HttpMethod.POST)// construct the Request

      // Configure the request
      manualRequest.setBody(body)// set the request body to send to the server
      manualRequest.addObserver(requestObserver)// Add the requestObserver to the request's set of Observers

      // Send the request!
      manualRequest.send();
      synchronized (requestObserver) {
        requestObserver.wait(2000);
      }

      //assertEquals(true, (body+"\n").equals(manualRequest.getResponse().getBody()));
      assertEquals(200, manualRequest.getResponse().getStatusCode());
      assertEquals(true, "OK".equalsIgnoreCase(manualRequest.getResponse().getStatusMessage()));
     
      assertTrue(body.equals(server.getLastReceived().getBody()));
      assertEquals(manualRequest.getHttpMethod(), server.getLastReceived().getHttpMethod());
     
      server.stop();
    } //TODO switch to https
    catch (InterruptedException e) {
      // TODO Auto-generated catch block
View Full Code Here

    ResponseModel cannedResponse = new ResponseModel();
    cannedResponse.setStatusCode(400)// status code: 400
    cannedResponse.setBody(body)// body: "Some error"

    // Make a new POST Request.
    Request manualRequest = new Request(config, null, HttpMethod.POST);   // construct the Request
    manualRequest.setBody(body)// set the request body to send to the server
    manualRequest.clearAsynchronous()// make this request synchronously so that the test is blocked

    // set the canned response and start the server
    server.setResponse(cannedResponse);
    server.start();

    // Send the request!
    manualRequest.send();

    assertTrue(manualRequest.getResponse().getBody().contains(body))// check that the message in the body was read
    assertEquals(400, manualRequest.getResponse().getStatusCode());

    assertTrue(body.equals(server.getLastReceived().getBody()));
    assertEquals(manualRequest.getHttpMethod(), server.getLastReceived().getHttpMethod());

    server.stop();
  }
View Full Code Here

  }

  @Override
  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    // check the response code
    if (response.getStatusCode() == 200) {
      controller.projectSelectSuccessful(response);
    }
View Full Code Here

  }

  @Override
  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    // check the response code
    if (response.getStatusCode() == 200) {
      controller.loginSuccessful(response);
    }
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.network.Request

Copyright © 2018 www.massapicom. 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.