Common DataWithMediaType class and common synchronization for ResponseBodyEmitter/SseEmitter

Issue: SPR-13223
Issue: SPR-13224
This commit is contained in:
Juergen Hoeller
2015-07-14 00:08:40 +02:00
parent 1fcd465f2d
commit bdb63483df
3 changed files with 125 additions and 108 deletions

View File

@@ -31,7 +31,9 @@ import static org.junit.Assert.fail;
/**
* Unit tests for {@link ResponseBodyEmitter}.
*
* @author Rossen Stoyanchev
* @author Tomasz Nurkiewicz
*/
public class ResponseBodyEmitterTests {
@@ -62,6 +64,19 @@ public class ResponseBodyEmitterTests {
verifyNoMoreInteractions(this.handler);
}
@Test
public void sendDuplicateBeforeHandlerInitialized() throws Exception {
this.emitter.send("foo", MediaType.TEXT_PLAIN);
this.emitter.send("foo", MediaType.TEXT_PLAIN);
this.emitter.complete();
verifyNoMoreInteractions(this.handler);
this.emitter.initialize(this.handler);
verify(this.handler, times(2)).send("foo", MediaType.TEXT_PLAIN);
verify(this.handler).complete();
verifyNoMoreInteractions(this.handler);
}
@Test
public void sendBeforeHandlerInitializedWithError() throws Exception {
IllegalStateException ex = new IllegalStateException();