Java Code Examples for org.eclipse.jetty.http.HttpStatus#NOT_FOUND_404

The following examples show how to use org.eclipse.jetty.http.HttpStatus#NOT_FOUND_404 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LeaseBlobManager.java    From samza with Apache License 2.0 6 votes vote down vote up
/**
 * Acquires a lease on a blob. The lease ID is NULL initially.
 * @param leaseTimeInSec The time in seconds you want to acquire the lease for.
 * @param leaseId Proposed ID you want to acquire the lease with, null if not proposed.
 * @return String that represents lease ID.  Null if acquireLease is unsuccessful because the blob is leased already.
 * @throws AzureException If a Azure storage service error occurred. This includes the case where the blob you're trying to lease does not exist.
 */
public String acquireLease(int leaseTimeInSec, String leaseId) {
  try {
    String id = leaseBlob.acquireLease(leaseTimeInSec, leaseId);
    LOG.info("Acquired lease with lease id = " + id);
    return id;
  } catch (StorageException storageException) {
    int httpStatusCode = storageException.getHttpStatusCode();
    if (httpStatusCode == HttpStatus.CONFLICT_409) {
      LOG.info("The blob you're trying to acquire is leased already.", storageException.getMessage());
    } else if (httpStatusCode == HttpStatus.NOT_FOUND_404) {
      LOG.error("The blob you're trying to lease does not exist.", storageException);
      throw new AzureException(storageException);
    } else {
      LOG.error("Error acquiring lease!", storageException);
      throw new AzureException(storageException);
    }
  }
  return null;
}
 
Example 2
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/size")
@ApiOperation(value = "Reading per domain mail size limitation")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "No value defined"),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetQuotaSize() {
    service.get(SIZE_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        Optional<QuotaSizeLimit> maxSizeQuota = domainQuotaService.getMaxSizeQuota(domain);
        if (maxSizeQuota.isPresent()) {
            return maxSizeQuota;
        }
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 3
Source File: DomainsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{destinationDomain}/aliases/{sourceDomain}")
@ApiOperation(value = "Remove an alias for a specific domain")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "sourceDomain", paramType = "path"),
    @ApiImplicitParam(required = true, dataType = "string", name = "destinationDomain", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK", response = List.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public void defineRemoveAlias(Service service) {
    service.delete(SPECIFIC_ALIAS, this::removeDomainAlias, jsonTransformer);
}
 
Example 4
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@ApiOperation(
    value = "Reading count and size at the same time",
    notes = "If there is no limitation for count and/or size, the returned value will be -1"
)
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = QuotaDomainDTO.class),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetQuota() {
    service.get(QUOTA_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        return domainQuotaService.getQuota(domain);
    }, jsonTransformer);
}
 
Example 5
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/size")
@ApiOperation(value = "Reading per user mail size limitation")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "No value defined"),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetQuotaSize() {
    service.get(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        Optional<QuotaSizeLimit> maxSizeQuota = userQuotaService.getMaxSizeQuota(username);
        if (maxSizeQuota.isPresent()) {
            return maxSizeQuota;
        }
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 6
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/size")
@ApiOperation(value = "Removing per domain mail size limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaSize() {
    service.delete(SIZE_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        domainQuotaService.remoteMaxQuotaSize(domain);
        return Responses.returnNoContent(response);
    });
}
 
Example 7
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@ApiOperation(
    value = "Reading count and size at the same time",
    notes = "If there is no limitation for count and/or size, the returned value will be -1"
)
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = QuotaDetailsDTO.class),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetQuota() {
    service.get(QUOTA_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        return userQuotaService.getQuota(username);
    }, jsonTransformer);
}
 
Example 8
Source File: MailQueueRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{mailQueueName}")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "mailQueueName", paramType = "path")
})
@ApiOperation(
    value = "Get a MailQueue details"
)
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = MailQueueDTO.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for getting the mail queue."),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The MailQueue does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void getMailQueue(Service service) {
    service.get(BASE_URL + SEPARATOR + MAIL_QUEUE_NAME,
        (request, response) -> getMailQueue(request),
        jsonTransformer);
}
 
Example 9
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/size")
@ApiOperation(value = "Updating per user mail size limitation")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer nor -1."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuotaSize() {
    service.put(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        QuotaSizeLimit quotaSize = Quotas.quotaSize(request.body());
        userQuotaService.defineMaxSizeQuota(username, quotaSize);
        return Responses.returnNoContent(response);
    });
}
 
Example 10
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{encodedPath}")
@ApiOperation(value = "Reading the information of a repository, such as size (can take some time to compute)")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "The repository information", response = List.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The repository does not exist", response = ErrorResponder.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
})
public void defineGetMailRepository() {
    service.get(MAIL_REPOSITORIES + "/:encodedPath", (request, response) -> {
        MailRepositoryPath path = decodedRepositoryPath(request);
        try {
            long size = repositoryStoreService.size(path)
                .orElseThrow(() -> repositoryNotFound(request.params("encodedPath"), path));
            return new ExtendedMailRepositoryResponse(path, size);
        } catch (MailRepositoryStore.MailRepositoryStoreException e) {
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500)
                .type(ErrorResponder.ErrorType.SERVER_ERROR)
                .cause(e)
                .message("Error while retrieving mail repository information")
                .haltError();
        }
    }, jsonTransformer);
}
 
Example 11
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Produces("application/json, message/rfc822")
@Path("/{encodedPath}/mails/{mailKey}")
@ApiOperation(value = "Retrieving a specific mail details (this endpoint can accept both \"application/json\" or \"message/rfc822\")")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "The list of all mails in a repository", response = List.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Not found - Could not retrieve the given mail.")
})
public void defineGetMail() {
    service.get(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", Constants.JSON_CONTENT_TYPE,
        (request, response) ->
            getMailAsJson(decodedRepositoryPath(request), new MailKey(request.params("mailKey")), request),
        jsonTransformer);

    service.get(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", Constants.RFC822_CONTENT_TYPE,
        (request, response) -> writeMimeMessage(
            getMailAsMimeMessage(
                decodedRepositoryPath(request),
                new MailKey(request.params("mailKey"))),
            response.raw()));
}
 
Example 12
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/count")
@ApiOperation(value = "Updating per domain mail count limitation")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuotaCount() {
    service.put(COUNT_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        QuotaCountLimit quotaCount = Quotas.quotaCount(request.body());
        domainQuotaService.setMaxCountQuota(domain, quotaCount);
        return Responses.returnNoContent(response);
    });
}
 
Example 13
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PUT
@ApiOperation(value = "Updating count and size at the same time")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataTypeClass = QuotaDTO.class, paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer or not unlimited value (-1)."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuota() {
    service.put(QUOTA_ENDPOINT, ((request, response) -> {
        try {
            Domain domain = checkDomainExist(request);
            QuotaDTO quotaDTO = jsonExtractor.parse(request.body());
            ValidatedQuotaDTO validatedQuotaDTO = quotaDTOValidator.validatedQuotaDTO(quotaDTO);
            domainQuotaService.defineQuota(domain, validatedQuotaDTO);
            return Responses.returnNoContent(response);
        } catch (IllegalArgumentException e) {
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.BAD_REQUEST_400)
                .type(ErrorType.INVALID_ARGUMENT)
                .message("Quota should be positive or unlimited (-1)")
                .cause(e)
                .haltError();
        }
    }));
}
 
Example 14
Source File: MailQueueRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PATCH
@Path("/{mailQueueName}/mails")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        dataType = "string",
        name = "mailQueueName",
        paramType = "path"),
    @ApiImplicitParam(
        required = false,
        dataType = "boolean",
        name = DELAYED_QUERY_PARAM,
        paramType = "query",
        example = "?delayed=true",
        value = "Whether the mails are delayed in the mail queue or not (already sent).")
})
@ApiOperation(
    value = "Force delayed mails delivery"
)
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for getting the mail queue."),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The MailQueue does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void forceDelayedMailsDelivery(Service service) {
    service.patch(BASE_URL + SEPARATOR + MAIL_QUEUE_NAME + MAILS,
        this::forceDelayedMailsDelivery,
        jsonTransformer);
}
 
Example 15
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/count")
@ApiOperation(value = "Removing per user mail count limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaCount() {
    service.delete(COUNT_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        userQuotaService.deleteMaxCountQuota(username);
        return Responses.returnNoContent(response);
    });
}
 
Example 16
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/size")
@ApiOperation(value = "Removing per user mail size limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaSize() {
    service.delete(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        userQuotaService.deleteMaxSizeQuota(username);
        return Responses.returnNoContent(response);
    });
}
 
Example 17
Source File: DLPConfigurationRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PUT
@Path("/{senderDomain}")
@ApiOperation(value = "Store a DLP configuration for given senderDomain")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "senderDomain", paramType = "path"),
    @ApiImplicitParam(required = true, dataTypeClass = DLPConfigurationDTO.class, paramType = "body")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. DLP configuration is stored."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid senderDomain or payload in request",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist.",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.",
        response = ErrorResponder.ErrorDetail.class)
})
public void defineStore(Service service) {
    service.put(SPECIFIC_DLP_RULE_DOMAIN, (request, response) -> {
        Domain senderDomain = parseDomain(request);
        DLPConfigurationDTO dto = jsonExtractor.parse(request.body());

        DLPRules rules = constructRules(dto);

        dlpConfigurationStore.store(senderDomain, rules);

        return Responses.returnNoContent(response);
    });
}
 
Example 18
Source File: DLPConfigurationRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/{senderDomain}")
@ApiOperation(value = "Return a DLP configuration for a given senderDomain")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "senderDomain", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "OK. DLP configuration is returned", response = DLPConfigurationDTO.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid senderDomain in request",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist.",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.",
        response = ErrorResponder.ErrorDetail.class)
})
public void defineList(Service service) {
    service.get(SPECIFIC_DLP_RULE_DOMAIN, (request, response) -> {
        Domain senderDomain = parseDomain(request);
        DLPRules dlpConfigurations = Mono.from(dlpConfigurationStore.list(senderDomain)).block();

        DLPConfigurationDTO dto = DLPConfigurationDTO.toDTO(dlpConfigurations);
        response.status(HttpStatus.OK_200);
        response.header(CONTENT_TYPE, JSON_CONTENT_TYPE);
        return dto;
    }, jsonTransformer);
}
 
Example 19
Source File: UserMailboxesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiOperation(value = "Deleting user mailboxes.")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The user does not have any mailbox", response = String.class),
        @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteUserMailboxes() {
    service.delete(USER_MAILBOXES_BASE, (request, response) -> {
        try {
            userMailboxesService.deleteMailboxes(getUsernameParam(request));
            return Responses.returnNoContent(response);
        } catch (IllegalStateException e) {
            LOGGER.info("Invalid delete on user mailboxes", e);
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.NOT_FOUND_404)
                .type(ErrorType.NOT_FOUND)
                .message("Invalid delete on user mailboxes")
                .cause(e)
                .haltError();
        }
    });
}
 
Example 20
Source File: AudioServletTest.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void requestToMultitimeStreamCannotBeDoneAfterTheTimeoutOfTheStreamHasExipred() throws Exception {
    final int streamTimeout = 1;

    AudioStream audioStream = getByteArrayAudioStream(testByteArray, AudioFormat.CONTAINER_NONE,
            AudioFormat.CODEC_MP3);

    final long beg = System.currentTimeMillis();

    String url = serveStream(audioStream, streamTimeout);

    Request request = getHttpRequest(url);

    ContentResponse response = request.send();

    final long end = System.currentTimeMillis();

    if (response.getStatus() == HttpStatus.NOT_FOUND_404) {
        assertThat("Response status 404 is only allowed if streamTimeout is exceeded.",
                TimeUnit.MILLISECONDS.toSeconds(end - beg), greaterThan((long) streamTimeout));
    } else {
        assertThat("The response status was not as expected", response.getStatus(), is(HttpStatus.OK_200));
        assertThat("The response content was not as expected", response.getContent(), is(testByteArray));
        assertThat("The response media type was not as expected", response.getMediaType(),
                is(MEDIA_TYPE_AUDIO_MPEG));

        assertThat("The audio stream was not added to the multitime streams",
                audioServlet.getMultiTimeStreams().containsValue(audioStream), is(true));
    }

    waitForAssert(() -> {
        try {
            request.send();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        assertThat("The audio stream was not removed from multitime streams",
                audioServlet.getMultiTimeStreams().containsValue(audioStream), is(false));
    });

    response = request.send();
    assertThat("The response status was not as expected", response.getStatus(), is(HttpStatus.NOT_FOUND_404));
}