Search in sources :

Example 1 with JsrCallable

use of org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable in project jetty.project by eclipse.

the class JsrParamIdDecoderTest method testMatchDateDecoder.

@Test
public void testMatchDateDecoder() {
    DecoderMetadata metadata = new DecoderMetadata(DateDecoder.class, Date.class, MessageType.TEXT, false);
    JsrParamIdDecoder paramId = new JsrParamIdDecoder(metadata);
    JsrCallable callable = getOnMessageCallableFrom(DateTextSocket.class, "onMessage");
    Param param = new Param(0, Date.class, null);
    Assert.assertThat("Match for Decoder", paramId.process(param, callable), is(true));
}
Also used : DecoderMetadata(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata) Test(org.junit.Test)

Example 2 with JsrCallable

use of org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable in project jetty.project by eclipse.

the class ServerAnnotatedEndpointScanner_GoodSignaturesTest method testScan_Basic.

@Test
public void testScan_Basic() throws Exception {
    WebSocketContainerScope container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
    AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(container, testcase.pojo, null);
    AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
    scanner.scan();
    Assert.assertThat("Metadata", metadata, notNullValue());
    JsrCallable method = (JsrCallable) testcase.metadataField.get(metadata);
    Assert.assertThat(testcase.metadataField.toString(), method, notNullValue());
    int len = testcase.expectedParameters.length;
    for (int i = 0; i < len; i++) {
        Class<?> expectedParam = testcase.expectedParameters[i];
        Class<?> actualParam = method.getParamTypes()[i];
        Assert.assertTrue("Parameter[" + i + "] - expected:[" + expectedParam + "], actual:[" + actualParam + "]", actualParam.equals(expectedParam));
    }
}
Also used : ServerEndpointConfig(javax.websocket.server.ServerEndpointConfig) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) JsrCallable(org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable) AnnotatedEndpointScanner(org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) ServerEndpoint(javax.websocket.server.ServerEndpoint) ServerEndpoint(javax.websocket.server.ServerEndpoint) Test(org.junit.Test)

Example 3 with JsrCallable

use of org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable in project jetty.project by eclipse.

the class ClientAnnotatedEndpointScanner_GoodSignaturesTest method testScan_Basic.

@Test
public void testScan_Basic() throws Exception {
    AnnotatedClientEndpointMetadata metadata = new AnnotatedClientEndpointMetadata(container, testcase.pojo);
    AnnotatedEndpointScanner<ClientEndpoint, ClientEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
    scanner.scan();
    Assert.assertThat("Metadata", metadata, notNullValue());
    JsrCallable cm = (JsrCallable) testcase.metadataField.get(metadata);
    Assert.assertThat(testcase.metadataField.toString(), cm, notNullValue());
    int len = testcase.expectedParameters.length;
    for (int i = 0; i < len; i++) {
        Class<?> expectedParam = testcase.expectedParameters[i];
        Class<?> actualParam = cm.getParamTypes()[i];
        Assert.assertTrue("Parameter[" + i + "] - expected:[" + expectedParam + "], actual:[" + actualParam + "]", actualParam.equals(expectedParam));
    }
}
Also used : JsrCallable(org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable) AnnotatedEndpointScanner(org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner) ClientEndpointConfig(javax.websocket.ClientEndpointConfig) ClientEndpoint(javax.websocket.ClientEndpoint) AnnotatedClientEndpointMetadata(org.eclipse.jetty.websocket.jsr356.client.AnnotatedClientEndpointMetadata) ClientEndpoint(javax.websocket.ClientEndpoint) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 AnnotatedEndpointScanner (org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner)2 JsrCallable (org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable)2 ClientEndpoint (javax.websocket.ClientEndpoint)1 ClientEndpointConfig (javax.websocket.ClientEndpointConfig)1 ServerEndpoint (javax.websocket.server.ServerEndpoint)1 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)1 SimpleContainerScope (org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)1 WebSocketContainerScope (org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope)1 AnnotatedClientEndpointMetadata (org.eclipse.jetty.websocket.jsr356.client.AnnotatedClientEndpointMetadata)1 DecoderMetadata (org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata)1