### Question:
SseEventSinkContextProvider implements ContextProvider<SseEventSink> { @Override public SseEventSink createContext(Message message) { final HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST); if (request == null) { throw new IllegalStateException("Unable to retrieve HTTP request from the context"); } final MessageBodyWriter<OutboundSseEvent> writer = new OutboundSseEventBodyWriter( ServerProviderFactory.getInstance(message), message.getExchange()); final AsyncResponse async = new AsyncResponseImpl(message); final Integer bufferSize = PropertyUtils.getInteger(message, SseEventSinkImpl.BUFFER_SIZE_PROPERTY); final SseEventSink sink = createSseEventSink(request, writer, async, bufferSize); message.put(SseEventSink.class, sink); return sink; }  @Override SseEventSink createContext(Message message);  }### Answer:
@Test public void testCreateSseEventSinkWithDefaultBufferSize() { final SseEventSink sink = provider.createContext(message); IntStream .range(0, 10000) .mapToObj(i -> sink.send(EVENT)) .map(CompletionStage::toCompletableFuture) .forEach(f -> assertThat(f.isDone(), equalTo(false))); final CompletableFuture<?> overflow = sink.send(EVENT).toCompletableFuture(); assertThat(overflow.isCompletedExceptionally(), equalTo(true)); exception.expect(CompletionException.class); exception.expectMessage("The buffer is full (10000), unable to queue SSE event for send."); overflow.join(); }
@Test public void testCreateSseEventSinkWithCustomBufferSize() { message.put(SseEventSinkImpl.BUFFER_SIZE_PROPERTY, 20000); final SseEventSink sink = provider.createContext(message); IntStream .range(0, 20000) .mapToObj(i -> sink.send(EVENT)) .map(CompletionStage::toCompletableFuture) .forEach(f -> assertThat(f.isDone(), equalTo(false))); final CompletableFuture<?> overflow = sink.send(EVENT).toCompletableFuture(); assertThat(overflow.isCompletedExceptionally(), equalTo(true)); exception.expect(CompletionException.class); exception.expectMessage("The buffer is full (20000), unable to queue SSE event for send."); overflow.join(); }