Implemented the error handling in case of commucation failures

This commit is contained in:
Ulrich von Poblotzki
2013-10-08 17:48:22 +02:00
committed by Dave Syer
parent 386bb73169
commit f306eda703
2 changed files with 35 additions and 8 deletions

View File

@@ -0,0 +1,24 @@
package org.springframework.boot.samples.websocket.snake;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
public class SnakeTimerTests {
@Test
public void removeDysfunctionalSnakes() throws Exception {
Snake snake = mock(Snake.class);
doThrow(new IOException()).when(snake).sendMessage(anyString());
SnakeTimer.addSnake(snake);
SnakeTimer.broadcast("");
assertThat(SnakeTimer.getSnakes().size(), is(0));
}
}