Search in sources :

Example 26 with RestResponseChannel

use of com.github.ambry.rest.RestResponseChannel in project ambry by linkedin.

the class TtlUpdateHandlerTest method verifyTtlUpdate.

// handleGoodCaseTest()
/**
 * Verifies that the TTL of the blob is updated
 * @param restRequest the {@link RestRequest} to get a signed URL.
 * @param expectedAccount the {@link Account} that should be populated in {@link RestRequest}.
 * @param expectedContainer the {@link Container} that should be populated in {@link RestRequest}.
 * @throws Exception
 */
private void verifyTtlUpdate(RestRequest restRequest, Account expectedAccount, Container expectedContainer) throws Exception {
    assertTtl(TTL_SECS);
    RestResponseChannel restResponseChannel = new MockRestResponseChannel();
    sendRequestGetResponse(restRequest, restResponseChannel);
    assertEquals("ResponseStatus not as expected", ResponseStatus.Ok, restResponseChannel.getStatus());
    assertNotNull("Date has not been set", restResponseChannel.getHeader(RestUtils.Headers.DATE));
    assertEquals("Content-length is not as expected", 0, Integer.parseInt((String) restResponseChannel.getHeader(RestUtils.Headers.CONTENT_LENGTH)));
    assertEquals("Account not as expected", expectedAccount, restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_ACCOUNT_KEY));
    assertEquals("Container not as expected", expectedContainer, restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_CONTAINER_KEY));
    assertTtl(Utils.Infinite_Time);
}
Also used : RestResponseChannel(com.github.ambry.rest.RestResponseChannel) MockRestResponseChannel(com.github.ambry.rest.MockRestResponseChannel) MockRestResponseChannel(com.github.ambry.rest.MockRestResponseChannel)

Aggregations

RestResponseChannel (com.github.ambry.rest.RestResponseChannel)26 RestRequest (com.github.ambry.rest.RestRequest)23 MockRestResponseChannel (com.github.ambry.rest.MockRestResponseChannel)21 JSONObject (org.json.JSONObject)15 RestServiceException (com.github.ambry.rest.RestServiceException)14 Test (org.junit.Test)13 MockRestRequest (com.github.ambry.rest.MockRestRequest)12 RestMethod (com.github.ambry.rest.RestMethod)12 RequestPath (com.github.ambry.rest.RequestPath)11 RestServiceErrorCode (com.github.ambry.rest.RestServiceErrorCode)11 RestUtils (com.github.ambry.rest.RestUtils)11 ThrowingConsumer (com.github.ambry.utils.ThrowingConsumer)11 ExecutionException (java.util.concurrent.ExecutionException)11 FutureResult (com.github.ambry.router.FutureResult)10 ReadableStreamChannel (com.github.ambry.router.ReadableStreamChannel)10 ByteBuffer (java.nio.ByteBuffer)10 FrontendConfig (com.github.ambry.config.FrontendConfig)9 MetricRegistry (com.codahale.metrics.MetricRegistry)8 Account (com.github.ambry.account.Account)8 InMemAccountService (com.github.ambry.account.InMemAccountService)8