Search in sources :

Example 1 with RSocketMimeType

use of com.alibaba.rsocket.metadata.RSocketMimeType in project alibaba-rsocket-broker by alibaba.

the class RSocketEncodingFacadeImpl method addEncodingHandler.

private void addEncodingHandler(ObjectEncodingHandler objectEncodingHandler) {
    RSocketMimeType mimeType = objectEncodingHandler.mimeType();
    handlerMap.put(mimeType, objectEncodingHandler);
}
Also used : RSocketMimeType(com.alibaba.rsocket.metadata.RSocketMimeType)

Example 2 with RSocketMimeType

use of com.alibaba.rsocket.metadata.RSocketMimeType in project alibaba-rsocket-broker by alibaba.

the class RSocketEncodingFacadeImplTest method testEncoding.

@Test
public void testEncoding() {
    Map<RSocketMimeType, ByteBuf> store = new HashMap<>();
    TempAccount account = new TempAccount(1L, "leijuan", new Date());
    for (RSocketMimeType mimeType : mimeTypes) {
        ByteBuf byteBuf = encodingFacade.encodingResult(account, mimeType);
        store.put(mimeType, byteBuf);
    }
    for (RSocketMimeType mimeType : mimeTypes) {
        TempAccount result = (TempAccount) encodingFacade.decodeResult(mimeType, store.get(mimeType), TempAccount.class);
        Assertions.assertNotNull(result);
        System.out.println(result.getName());
    }
}
Also used : RSocketMimeType(com.alibaba.rsocket.metadata.RSocketMimeType) HashMap(java.util.HashMap) ByteBuf(io.netty.buffer.ByteBuf) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

RSocketMimeType (com.alibaba.rsocket.metadata.RSocketMimeType)2 ByteBuf (io.netty.buffer.ByteBuf)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1