Test Not A Socket
This commit is contained in:
parent
7e93c2a409
commit
891ab0b858
|
@ -3,6 +3,7 @@ package org.eclipse.jetty.websocket.annotations;
|
|||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketListener;
|
||||
import org.eclipse.jetty.websocket.frames.BaseFrame;
|
||||
import org.eclipse.jetty.websocket.frames.TextFrame;
|
||||
import org.junit.Assert;
|
||||
|
@ -111,13 +112,32 @@ public class EventMethodsCacheTest
|
|||
|
||||
assertNoEventMethod("NoopSocket.onBinary",methods.onBinary);
|
||||
assertNoEventMethod("NoopSocket.onClose",methods.onClose);
|
||||
assertNoEventMethod("NoopSocket.onConnect", methods.onConnect);
|
||||
assertNoEventMethod("NoopSocket.onConnect",methods.onConnect);
|
||||
assertNoEventMethod("NoopSocket.onException",methods.onException);
|
||||
assertNoEventMethod("NoopSocket.onText",methods.onText);
|
||||
|
||||
Assert.assertThat("MyEchoSocket.getOnFrames()",methods.getOnFrames().size(),is(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Case for bad declaration (duplicate OnWebSocketBinary declarations)
|
||||
*/
|
||||
@Test
|
||||
public void testDiscoverNotASocket()
|
||||
{
|
||||
EventMethodsCache cache = new EventMethodsCache();
|
||||
try
|
||||
{
|
||||
// Should toss exception
|
||||
cache.getMethods(NotASocket.class);
|
||||
}
|
||||
catch (InvalidWebSocketException e)
|
||||
{
|
||||
// Validate that we have clear error message to the developer
|
||||
Assert.assertThat(e.getMessage(),allOf(containsString(WebSocketListener.class.getSimpleName()),containsString(WebSocket.class.getSimpleName())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Case for no exceptions and 3 methods
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.eclipse.jetty.websocket.annotations;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
|
||||
/**
|
||||
* (Test Case)
|
||||
* <p>
|
||||
* Intentionally not specifying the @WebSocket annotation here
|
||||
*/
|
||||
public class NotASocket
|
||||
{
|
||||
@OnWebSocketConnect
|
||||
public void onConnect(WebSocketConnection conn)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue