Search in sources :

Example 1 with SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope 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 SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope 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 SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope 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 SimpleContainerScope

use of org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope 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 SimpleContainerScope

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

the class EventDriverFactoryTest method testListenerBasicSocket.

/**
     * Test Case for no exceptions and 5 methods (implement WebSocketListener)
     */
@Test
public void testListenerBasicSocket() {
    EventDriverFactory factory = new EventDriverFactory(new SimpleContainerScope(WebSocketPolicy.newClientPolicy()));
    ListenerBasicSocket socket = new ListenerBasicSocket();
    EventDriver driver = factory.wrap(socket);
    String classId = ListenerBasicSocket.class.getSimpleName();
    Assert.assertThat("EventDriver for " + classId, driver, instanceOf(JettyListenerEventDriver.class));
}
Also used : ListenerBasicSocket(examples.ListenerBasicSocket) Matchers.containsString(org.hamcrest.Matchers.containsString) 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