Package play.mvc.Http

Examples of play.mvc.Http.Response


        Fixtures.deleteAll();
    }

    @Test
    public void testThatIndexPageWorks() {
        Response response = GET("/");
        assertIsOk(response);
        assertContentType("text/html", response);
        assertCharset("utf-8", response);
    }
View Full Code Here


    }

    @Test
    public void testYML() {
    Fixtures.load("data.yml");
        Response response = GET("/api/albums.xml");
        assertIsOk(response);
    }
View Full Code Here


    @Test
    public void testJsonApi() {
        //preconditions
    Response artists = GET("/api/artists.json");
        assertFalse(artists.out.toString().contains("john"));

    Response albums = GET("/api/albums.json");
        assertFalse(albums.out.toString().contains("album1"));

    String album1 = "{ \"name\":\"album1\", \"artist\":{ \"name\":\"john\" }, \"releaseDate\":\"12 sept. 2010 00:00:00\", \"genre\":\"ROCK\" }";
        POST("/api/album", "application/json", album1);
View Full Code Here

        assertTrue(albums.out.toString().contains("album1"));
    }

  @Test
    public void testXmlApi() {
        Response artists = GET("/api/artists.xml");
        assertFalse(artists.out.toString().contains("john"));

    Response albums = GET("/api/albums.xml");
        assertFalse(albums.out.toString().contains("album1"));

    String album1 = "<album><artist><name>john</name></artist><name>album1</name><release-date>2010</release-date><genre>ROCK</genre><nvVotes>0</nvVotes></album>";
        POST("/api/album", "application/xml", album1);
       
View Full Code Here

public class ApplicationTest extends FunctionalTest {

    @Test
    public void testThatIndexPageWorks() {
        Response response = GET("/");
        assertIsOk(response);
        assertContentType("text/html", response);
        assertCharset(play.Play.defaultWebEncoding, response);
    }
View Full Code Here

    @Test
    public void shouldRedirectToLatestAfterSave() {
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("vibe.message", "TheMessage");
        Response response = POST("/vibes", parameters);

        assertStatus(302, response);
        assertHeaderEquals("Location", "/vibes", response);
    }
View Full Code Here

    String password = "secret1";
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", username);
    loginUserParams.put("password", password);
    // Login here so the following request will be authenticated:
    Response response = POST("/login", loginUserParams);
    assertStatus(StatusCode.FOUND, response);
    Map<String, Cookie> cookies = new HashMap<String, Cookie>();
    cookies.putAll(response.cookies);
    Request request = newRequest();
        request.cookies.putAll(cookies);
        response = GET(request, api_base);
        assertStatus(StatusCode.OK, response);
        InputStream is = new ByteArrayInputStream(response.out.toByteArray());
    Reader reader = new InputStreamReader(is);
        User user = new Gson().fromJson(reader, User.class);
        assertTrue("El nombre del usuario ha de ser eduardo.perrino ", username.startsWith(user.username));
        user.basic_information.firstName = "Juan lucas";
        request = newRequest();
        request.cookies.putAll(cookies);
        response = FunctionalTest.PUT(request, api_base,"application/json", new Gson().toJson(user, User.class));
        assertStatus(StatusCode.OK, response);
        String location = response.getHeader("location");
        assertNotNull(location);
        request = newRequest();
        request.cookies.putAll(cookies);
        response = GET(request, api_base);
        assertStatus(StatusCode.OK, response);
View Full Code Here

    //La interna eva perez se loguea en el sistema
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", from+"@B");
    loginUserParams.put("password", "secret1");
    // 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 eva perez 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("Eva perez no ha subido ninguna foto", photos.data.size()==0);
   
    //Eva perez 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("buscador.png");
    assertNotNull("El fichero buscador.png 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 Eva perez.", photo.owner.username.equals(from));
   
    //Se verifica que Juan Gomez a subida una imagen a batzen
View Full Code Here

  public void crudubscriber() {
    Map<String, String> loginUserParams = new HashMap<String, String>();
    loginUserParams.put("username", "root");
    loginUserParams.put("password", "m4f2010");
    // Login here so the following request will be authenticated:
    Response response = POST("/login", loginUserParams);
    assertStatus(StatusCode.FOUND, response);
    Map<String, Cookie> cookies = new HashMap<String, Cookie>();
    cookies.putAll(response.cookies);
    Request request = newRequest();
        request.cookies.putAll(cookies);
    //Create
    String name = "olympia";
    Subscriber subscriber = new Subscriber();
    subscriber.name = name;
    ContactInformation contact_information = new ContactInformation();
    contact_information.email = "lucas@olympia.com";
    subscriber.contact_information = contact_information;
    response = POST(request,
        "/api/subscribers", "application/json", gson.toJson(subscriber));
    assertStatus(StatusCode.CREATED, response);
    String location = response.getHeader("location");
    assertNotNull("Location header musn't be empty", location);
    response = GET(location);
    subscriber = parseJSON(response.out.toByteArray());
    assertEquals(subscriber.name, name);
    //Update
View Full Code Here

  }
 
 
 
  private static void checkDetail(Subscriber originalSubscriber) {
    Response response = GET("/api/subscribers/" + originalSubscriber.id);
    assertIsOk(response);
    assertContentType("application/json", response);
    assertCharset("utf-8", response);
    Subscriber remoteSubscriber = parseJSON(response.out.toByteArray());
    assertEquals("Debe ser el mismo subscriber", remoteSubscriber.id, originalSubscriber.id);
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.