Search in sources :

Example 11 with LinkedBuffer

use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.

the class HighwayClient method createLogin.

@Override
public TcpOutputStream createLogin() {
    try {
        LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
        ProtobufOutput output = new ProtobufOutput(linkedBuffer);
        RequestHeader header = new RequestHeader();
        header.setMsgType(MsgType.LOGIN);
        header.writeObject(output);
        LoginRequest login = new LoginRequest();
        login.setProtocol(HighwayTransport.NAME);
        login.writeObject(output);
        HighwayOutputStream os = new HighwayOutputStream();
        os.write(header, LoginRequest.getLoginRequestSchema(), login);
        return os;
    } catch (Throwable e) {
        throw new Error("impossible.", e);
    }
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) ProtobufOutput(io.protostuff.ProtobufOutput) RequestHeader(io.servicecomb.transport.highway.message.RequestHeader) LoginRequest(io.servicecomb.transport.highway.message.LoginRequest)

Example 12 with LinkedBuffer

use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.

the class TestArgsNotWrapSchema method testWriteObjectToSchema.

@Test
public void testWriteObjectToSchema() {
    boolean status = true;
    LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
    ProtobufOutput output = new ProtobufOutput(linkedBuffer);
    String[] stringArray = new String[1];
    stringArray[0] = "abc";
    try {
        argsNotWrapSchema.writeObject(output, stringArray);
    } catch (Exception e) {
        status = false;
    }
    Assert.assertTrue(status);
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) ProtobufOutput(io.protostuff.ProtobufOutput) Test(org.junit.Test)

Example 13 with LinkedBuffer

use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.

the class TestArgsNotWrapSchema method testWriteObject.

@Test
public void testWriteObject() {
    boolean status = true;
    LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
    ProtobufOutput output = new ProtobufOutput(linkedBuffer);
    String[] stringArray = new String[1];
    try {
        argsNotWrapSchema.writeObject(output, stringArray);
    } catch (Exception e) {
        status = false;
    }
    Assert.assertTrue(status);
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) ProtobufOutput(io.protostuff.ProtobufOutput) Test(org.junit.Test)

Example 14 with LinkedBuffer

use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.

the class TestArgsWrapSchema method testWriteObject.

@Test
public void testWriteObject() {
    boolean status = true;
    LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
    ProtobufOutput output = new ProtobufOutput(linkedBuffer);
    String[] stringArray = new String[1];
    stringArray[0] = "abc";
    MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
    Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
    try {
        argsWrapSchema.writeObject(output, stringArray);
    } catch (IOException e) {
        status = true;
    }
    Assert.assertTrue(status);
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) MultiWrapper(io.servicecomb.common.javassist.MultiWrapper) ProtobufOutput(io.protostuff.ProtobufOutput) IOException(java.io.IOException) Test(org.junit.Test)

Example 15 with LinkedBuffer

use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.

the class TestProtobufSchemaUtils method toByteArray.

private byte[] toByteArray(WrapSchema schema, Object value) throws Exception {
    LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
    ProtobufOutput output = new ProtobufOutput(linkedBuffer);
    schema.writeObject(output, value);
    return output.toByteArray();
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) ProtobufOutput(io.protostuff.ProtobufOutput)

Aggregations

LinkedBuffer (io.protostuff.LinkedBuffer)21 ProtobufOutput (io.protostuff.ProtobufOutput)19 Test (org.junit.Test)7 IOException (java.io.IOException)4 BufferOutputStream (io.servicecomb.foundation.vertx.stream.BufferOutputStream)3 RpcException (com.jim.framework.rpc.exception.RpcException)2 ByteArrayInput (io.protostuff.ByteArrayInput)2 Schema (io.protostuff.Schema)2 RuntimeSchema (io.protostuff.runtime.RuntimeSchema)2 Buffer (io.vertx.core.buffer.Buffer)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Input (io.protostuff.Input)1 ModelProtostuff (io.protostuff.runtime.model.ModelProtostuff)1 MultiWrapper (io.servicecomb.common.javassist.MultiWrapper)1 LoginRequest (io.servicecomb.transport.highway.message.LoginRequest)1 RequestHeader (io.servicecomb.transport.highway.message.RequestHeader)1 List (java.util.List)1 MultiWrapper (org.apache.servicecomb.common.javassist.MultiWrapper)1 BufferOutputStream (org.apache.servicecomb.foundation.vertx.stream.BufferOutputStream)1