Search in sources :

Example 1 with WebSocketContainerScope

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

the class ServerAnnotatedEndpointScanner_InvalidSignaturesTest method testScan_InvalidSignature.

@Test
public void testScan_InvalidSignature() throws DeploymentException {
    WebSocketContainerScope container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
    AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(container, pojo, null);
    AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
    try {
        scanner.scan();
        Assert.fail("Expected " + InvalidSignatureException.class + " with message that references " + expectedAnnoClass + " annotation");
    } catch (InvalidSignatureException e) {
        if (LOG.isDebugEnabled())
            LOG.debug("{}:{}", e.getClass(), e.getMessage());
        Assert.assertThat("Message", e.getMessage(), containsString(expectedAnnoClass.getSimpleName()));
    }
}
Also used : InvalidSignatureException(org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException) ServerEndpointConfig(javax.websocket.server.ServerEndpointConfig) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) AnnotatedEndpointScanner(org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) ServerEndpoint(javax.websocket.server.ServerEndpoint) Test(org.junit.Test)

Example 2 with WebSocketContainerScope

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

the class DecoderFactoryTest method initDecoderFactory.

@Before
public void initDecoderFactory() {
    WebSocketContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
    DecoderFactory primitivesFactory = new DecoderFactory(containerScope, PrimitiveDecoderMetadataSet.INSTANCE);
    metadatas = new DecoderMetadataSet();
    factory = new DecoderFactory(containerScope, metadatas, primitivesFactory);
}
Also used : DecoderMetadataSet(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet) PrimitiveDecoderMetadataSet(org.eclipse.jetty.websocket.jsr356.decoders.PrimitiveDecoderMetadataSet) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) Before(org.junit.Before)

Example 3 with WebSocketContainerScope

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

the class MessageHandlerFactoryTest method init.

@Before
public void init() throws DeploymentException {
    WebSocketContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
    DecoderFactory primitivesFactory = new DecoderFactory(containerScope, PrimitiveDecoderMetadataSet.INSTANCE);
    metadatas = new DecoderMetadataSet();
    decoders = new DecoderFactory(containerScope, metadatas, primitivesFactory);
    factory = new MessageHandlerFactory();
}
Also used : DecoderMetadataSet(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet) PrimitiveDecoderMetadataSet(org.eclipse.jetty.websocket.jsr356.decoders.PrimitiveDecoderMetadataSet) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) Before(org.junit.Before)

Example 4 with WebSocketContainerScope

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

the class MessageWriterTest method setupSession.

@Before
public void setupSession() throws Exception {
    policy = WebSocketPolicy.newServerPolicy();
    policy.setInputBufferSize(1024);
    policy.setMaxTextMessageBufferSize(1024);
    // Container
    WebSocketContainerScope containerScope = new SimpleContainerScope(policy, bufferPool);
    // Event Driver factory
    EventDriverFactory factory = new EventDriverFactory(containerScope);
    // local socket
    EventDriver driver = factory.wrap(new TrackingSocket("local"));
    // remote socket
    socket = new TrackingSocket("remote");
    OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
    session = new LocalWebSocketSession(containerScope, testname, driver);
    session.setPolicy(policy);
    // talk to our remote socket
    session.setOutgoingHandler(socketPipe);
    // start session
    session.start();
    // open connection
    session.open();
}
Also used : EventDriver(org.eclipse.jetty.websocket.common.events.EventDriver) LocalWebSocketSession(org.eclipse.jetty.websocket.common.io.LocalWebSocketSession) EventDriverFactory(org.eclipse.jetty.websocket.common.events.EventDriverFactory) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) OutgoingFrames(org.eclipse.jetty.websocket.api.extensions.OutgoingFrames) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) Before(org.junit.Before)

Example 5 with WebSocketContainerScope

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

the class WebSocketCdiListener method lifeCycleStarting.

@Override
public void lifeCycleStarting(LifeCycle event) {
    if (event instanceof WebSocketContainerScope) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("started websocket container [{}]", event);
        }
        ContainerListener listener = new ContainerListener((WebSocketContainerScope) event);
        if (event instanceof ContainerLifeCycle) {
            ContainerLifeCycle container = (ContainerLifeCycle) event;
            container.addLifeCycleListener(listener);
            container.addEventListener(listener);
        } else {
            throw new RuntimeException("Unable to setup CDI against non-container: " + event.getClass().getName());
        }
    }
}
Also used : WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle)

Aggregations

WebSocketContainerScope (org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope)10 SimpleContainerScope (org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)9 Before (org.junit.Before)5 ServerEndpoint (javax.websocket.server.ServerEndpoint)3 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)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 WebSocketPolicy (org.eclipse.jetty.websocket.api.WebSocketPolicy)2 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 Test (org.junit.Test)2 URI (java.net.URI)1 ContainerLifeCycle (org.eclipse.jetty.util.component.ContainerLifeCycle)1 EventDriverImpl (org.eclipse.jetty.websocket.common.events.EventDriverImpl)1 InvalidSignatureException (org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException)1 DummyConnection (org.eclipse.jetty.websocket.common.test.DummyConnection)1 ClientContainer (org.eclipse.jetty.websocket.jsr356.ClientContainer)1