Example usage for com.squareup.okhttp ResponseBody create

List of usage examples for com.squareup.okhttp ResponseBody create

Introduction

In this page you can find the example usage for com.squareup.okhttp ResponseBody create.

Prototype

public static ResponseBody create(final MediaType contentType, byte[] content) 

Source Link

Document

Returns a new response body that transmits content .

Usage

From source file:retrofit.ResponseTest.java

License:Apache License

@Test
public void errorWithNullRawResponseThrows() {
    ResponseBody errorBody = ResponseBody.create(null, "Broken!");
    try {/*from  ww  w.  j av  a 2  s  . c o m*/
        Response.error(errorBody, null);
        fail();
    } catch (NullPointerException e) {
        assertThat(e).hasMessage("rawResponse == null");
    }
}

From source file:retrofit.ResponseTest.java

License:Apache License

@Test
public void errorWithSuccessRawResponseThrows() {
    ResponseBody errorBody = ResponseBody.create(null, "Broken!");
    try {/*from www . ja va  2 s. c  o  m*/
        Response.error(errorBody, successResponse);
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e).hasMessage("rawResponse should not be successful response");
    }
}