use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata 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));
}
use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.
the class PrimitiveDecoderMetadataSetTest method assertDecoderType.
private void assertDecoderType(Class<? extends Decoder> expectedDecoder, MessageType expectedMsgType, Class<?> type) {
PrimitiveDecoderMetadataSet primitives = new PrimitiveDecoderMetadataSet();
DecoderMetadata metadata = primitives.getMetadataByType(type);
String prefix = String.format("Metadata By Type [%s]", type.getName());
Assert.assertThat(prefix, metadata, notNullValue());
assertClassEquals(prefix + ".coderClass", metadata.getCoderClass(), expectedDecoder);
Assert.assertThat(prefix + ".messageType", metadata.getMessageType(), is(expectedMsgType));
}
use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.
the class MessageHandlerFactoryTest method testStringPartial.
@Test
public void testStringPartial() throws DeploymentException {
List<MessageHandlerMetadata> metadatas = factory.getMetadata(StringPartialHandler.class);
Assert.assertThat("Metadata.list.size", metadatas.size(), is(1));
MessageHandlerMetadata handlerMetadata = metadatas.get(0);
DecoderMetadata decoderMetadata = decoders.getMetadataFor(handlerMetadata.getMessageClass());
Assert.assertThat("Message Type", decoderMetadata.getMessageType(), is(MessageType.TEXT));
Assert.assertThat("Message Class", handlerMetadata.getMessageClass(), is((Type) String.class));
}
use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.
the class MessageHandlerFactoryTest method testByteArrayPartial.
@Test
public void testByteArrayPartial() throws DeploymentException {
List<MessageHandlerMetadata> metadatas = factory.getMetadata(ByteArrayPartialHandler.class);
Assert.assertThat("Metadata.list.size", metadatas.size(), is(1));
MessageHandlerMetadata handlerMetadata = metadatas.get(0);
DecoderMetadata decoderMetadata = decoders.getMetadataFor(handlerMetadata.getMessageClass());
Assert.assertThat("Message Type", decoderMetadata.getMessageType(), is(MessageType.BINARY));
Assert.assertThat("Message Class", handlerMetadata.getMessageClass(), is((Type) byte[].class));
}
use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.
the class DecoderFactory method init.
@Override
public void init(EndpointConfig config) {
if (LOG.isDebugEnabled()) {
LOG.debug("init({})", config);
}
if (!containerScope.isRunning()) {
throw new RuntimeException(containerScope.getClass().getName() + " is not running yet");
}
// Instantiate all declared decoders
for (DecoderMetadata metadata : metadatas) {
Wrapper wrapper = newWrapper(metadata);
activeWrappers.put(metadata.getObjectType(), wrapper);
}
// Initialize all decoders
for (Wrapper wrapper : activeWrappers.values()) {
wrapper.decoder.init(config);
}
}
Aggregations