Package play.mvc.Http

Examples of play.mvc.Http.Response


    //Loggin en el sistema de Juan Gomez familiar de Eva perez
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", from+"@B");
    loginUserParams.put("password", "secret2");
    // Login here so the following request will be authenticated:
    Response response = POST("/login", loginUserParams);
    assertStatus(StatusCode.FOUND, response);
    cookies.putAll(response.cookies);
   
    //Comprobacion de que juan gomez todavía no ha subida ninguna imagen a batzen.
    Request request = newRequest();
        request.cookies.putAll(cookies);
    response = GET(request, "/api/me/photos");
    assertStatus(StatusCode.OK, response);
    Data<Photo> photos = JsonParserHelper.toPhotoCollection(response.out.toByteArray());
    assertTrue("La usuario juan gomez no tiene ninguna foto", photos.data.size()==0);
   
    //Juan Gomez sube una imagen a batzen.
    Map<String, String> parameters = new HashMap<String, String>();
    Map<java.lang.String, java.io.File> files = new HashMap<java.lang.String, java.io.File>();
    File image = locateFile("atom-1.jpeg");
    assertNotNull("El fichero atom-1.jpeg especificado no existe", image);
    files.put("data", image);
    request = newRequest();
        request.cookies.putAll(cookies);
    response =  POST(request, "/api/me/photos", parameters, files);
    String location = response.getHeader("location");
    assertNotNull(location);
    Photo photo = JsonParserHelper.toPhoto(response.out.toByteArray());
    assertTrue("El propietario de la foto tiene que ser Juan Gomez.", photo.owner.username.equals(from));
   
    //Se verifica que Juan Gomez a subida una imagen a batzen
View Full Code Here


  public void crudTest() {
     Map<String, String> loginUserParams = new HashMap<String, String>();
     loginUserParams.put("username", "laura.garcia@B");
     loginUserParams.put("password", "secret1");
    // Login here so the following request will be authenticated:
     Response response = POST("/login", loginUserParams);
     // The following is an action that requires an authenticated user:
     response = GET("/api/users");
     assertIsOk(response);
     InputStream is = new ByteArrayInputStream(response.out.toByteArray());
     Reader reader = new InputStreamReader(is);
View Full Code Here

    familiar.access = true;
    BasicInformation basicInformation = new BasicInformation();
    familiar.basic_information = basicInformation;
    basicInformation.firstName = "Angela";
    basicInformation.lastName = "Martin";
    Response response = POST("/api/users/" + internal.id + "/familiars", "application/json", new Gson().toJson(familiar));
    assertStatus(StatusCode.CREATED, response);
    String location = response.getHeader("location");
    assertNotNull("Location header musn't be empty", location);
    response = GET(location);
    InputStream is = new ByteArrayInputStream(response.out.toByteArray());
    Reader reader = new InputStreamReader(is);
    familiar = new Gson().fromJson(reader, new TypeToken<User>(){}.getType());
View Full Code Here

    //Loggin en el sistema de Juan Gomez familiar de Eva perez
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", "juan.gomez@B");
    loginUserParams.put("password", "secret2");
    // Login here so the following request will be authenticated:
    Response response = POST("/login", loginUserParams);
    assertStatus(StatusCode.FOUND, response);
    cookies.putAll(response.cookies);
    Request request = newRequest();
        request.cookies.putAll(cookies);
    response = GET(request, "/api/me/internet/search?q=coches&offset=0&limit=8&type=images");
View Full Code Here

public class CRUDPhotosTest extends BaseTest {
 
  @Test
  public void crudTest() throws Exception {
    Response response = GET("/api/me/photos");
    assertStatus(StatusCode.FOUND, response);
    String location = response.getHeader("location");
    assertNotNull(location);
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", "eva.perez@B");
    loginUserParams.put("password", "secret1");
    // Login here so the following request will be authenticated:
    response = POST(location, loginUserParams);
    assertStatus(StatusCode.FOUND, response);
    response = GET("/api/me/photos");
    assertStatus(StatusCode.OK, response);
    InputStream is = new ByteArrayInputStream(response.out.toByteArray());
    Reader reader = new InputStreamReader(is);
    Type dataType = new TypeToken<Data<Photo>>(){}.getType();
    Data<Photo> data = new Gson().fromJson(reader, dataType);
    assertTrue("La usuario eva perez no tiene ninguna foto", data.data.size()==0);
    Map<String, String> parameters = new HashMap<String, String>();
    Map<java.lang.String, java.io.File> files = new HashMap<java.lang.String, java.io.File>();
    VirtualFile vfFile;
    File image = null;
    for (VirtualFile vf : Play.javaPath) {
      vfFile = vf.child("atom-1.jpeg");
      if(vfFile!=null && vfFile.exists()) {
        image = vfFile.getRealFile();
        break;
      }
    }
    assertNotNull("El fichero atom-1.jpeg especificado no existe", image);
    System.out.println("Exists: " + image.getAbsolutePath());
    files.put("data", image);
    response =  POST("/api/me/photos", parameters, files);
    location = response.getHeader("location");
    response = GET(location);
    assertStatus(StatusCode.OK, response);
    dataType = new TypeToken<Photo>(){}.getType();
    is = new ByteArrayInputStream(response.out.toByteArray());
    reader = new InputStreamReader(is);
View Full Code Here

  /**
   * Repository.
   */
  @Test
  public void repository() {
    Response response = GET("/rest/github/repository/feliperazeek/socialestates");
    this.basicTest(response);
  }
View Full Code Here

  /**
   * User.
   */
  @Test
  public void user() {
    Response response = GET("/rest/github/user/feliperazeek");
    this.basicTest(response);
  }
View Full Code Here

  /**
   * Repository search.
   */
  @Test
  public void repositorySearch() {
    Response response = GET("/rest/github/search/socialestates/1");
    this.basicTest(response);
  }
View Full Code Here

  /**
   * Coders impact.
   */
  @Test
  public void codersImpact() {
    Response response = GET("/rest/github/repository/feliperazeek/socialestates/coderImpacts");
    this.basicTest(response);
  }
View Full Code Here

  /**
   * Contributors.
   */
  @Test
  public void contributors() {
    Response response = GET("/rest/github/repository/feliperazeek/socialestates/contributors");
    this.basicTest(response);
  }
View Full Code Here

TOP

Related Classes of play.mvc.Http.Response

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.