Search in sources :

Example 11 with SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope in project jetty.project by eclipse.

the class EventDriverTest method wrap.

private EventDriver wrap(Object websocket) {
    WebSocketPolicy policy = WebSocketPolicy.newServerPolicy();
    EventDriverFactory factory = new EventDriverFactory(new SimpleContainerScope(policy));
    return factory.wrap(websocket);
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)

Example 12 with SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope in project jetty.project by eclipse.

the class ExtensionStackTest method createExtensionStack.

private ExtensionStack createExtensionStack() {
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
    WebSocketContainerScope container = new SimpleContainerScope(policy, bufferPool);
    WebSocketExtensionFactory factory = new WebSocketExtensionFactory(container);
    return new ExtensionStack(factory);
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)

Example 13 with SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope in project jetty.project by eclipse.

the class EventDriverFactoryTest method testBadNotASocket.

/**
     * Test Case for bad declaration (duplicate OnWebSocketBinary declarations)
     */
@Test
public void testBadNotASocket() {
    EventDriverFactory factory = new EventDriverFactory(new SimpleContainerScope(WebSocketPolicy.newClientPolicy()));
    try {
        NotASocket bad = new NotASocket();
        // Should toss exception
        factory.wrap(bad);
    } 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())));
    }
}
Also used : InvalidWebSocketException(org.eclipse.jetty.websocket.api.InvalidWebSocketException) NotASocket(org.eclipse.jetty.websocket.common.annotations.NotASocket) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) Test(org.junit.Test)

Aggregations

SimpleContainerScope (org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)13 WebSocketContainerScope (org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope)9 Before (org.junit.Before)5 Test (org.junit.Test)5 ServerEndpoint (javax.websocket.server.ServerEndpoint)3 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)3 WebSocketPolicy (org.eclipse.jetty.websocket.api.WebSocketPolicy)3 EventDriver (org.eclipse.jetty.websocket.common.events.EventDriver)3 EventDriverFactory (org.eclipse.jetty.websocket.common.events.EventDriverFactory)3 AnnotatedEndpointScanner (org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner)3 OutgoingFrames (org.eclipse.jetty.websocket.api.extensions.OutgoingFrames)2 LocalWebSocketSession (org.eclipse.jetty.websocket.common.io.LocalWebSocketSession)2 PrimitiveDecoderMetadataSet (org.eclipse.jetty.websocket.jsr356.decoders.PrimitiveDecoderMetadataSet)2 DecoderMetadataSet (org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 AdapterConnectCloseSocket (examples.AdapterConnectCloseSocket)1 ListenerBasicSocket (examples.ListenerBasicSocket)1 URI (java.net.URI)1 InvalidWebSocketException (org.eclipse.jetty.websocket.api.InvalidWebSocketException)1 NotASocket (org.eclipse.jetty.websocket.common.annotations.NotASocket)1