Search in sources :

Example 1 with MultiWrapper

use of org.apache.servicecomb.common.javassist.MultiWrapper in project incubator-servicecomb-java-chassis by apache.

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(org.apache.servicecomb.common.javassist.MultiWrapper) ProtobufOutput(io.protostuff.ProtobufOutput) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with MultiWrapper

use of org.apache.servicecomb.common.javassist.MultiWrapper in project incubator-servicecomb-java-chassis by apache.

the class TestArgsWrapSchema method testReadFromEmpty.

@Test
public void testReadFromEmpty() {
    MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
    Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
    Assert.assertNotNull(argsWrapSchema);
    Object object = argsWrapSchema.readFromEmpty();
    Assert.assertNull(object);
}
Also used : MultiWrapper(org.apache.servicecomb.common.javassist.MultiWrapper) Test(org.junit.Test)

Example 3 with MultiWrapper

use of org.apache.servicecomb.common.javassist.MultiWrapper in project incubator-servicecomb-java-chassis by apache.

the class TestArgsWrapSchema method testReadObject.

@Test
public void testReadObject() {
    boolean status = true;
    Input input = null;
    String[] stringArray = new String[1];
    stringArray[0] = "abc";
    MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
    Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
    try {
        Object object = argsWrapSchema.readObject(input);
        Assert.assertNull(object);
    } catch (IOException e) {
        status = true;
    }
    Assert.assertTrue(status);
}
Also used : Input(io.protostuff.Input) MultiWrapper(org.apache.servicecomb.common.javassist.MultiWrapper) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with MultiWrapper

use of org.apache.servicecomb.common.javassist.MultiWrapper in project incubator-servicecomb-java-chassis by apache.

the class ArgsWrapSchema method writeObject.

public void writeObject(Output output, Object value) throws IOException {
    MultiWrapper wrapper = (MultiWrapper) schema.newMessage();
    wrapper.writeFields((Object[]) value);
    schema.writeTo(output, wrapper);
}
Also used : MultiWrapper(org.apache.servicecomb.common.javassist.MultiWrapper)

Example 5 with MultiWrapper

use of org.apache.servicecomb.common.javassist.MultiWrapper in project incubator-servicecomb-java-chassis by apache.

the class ArgsWrapSchema method readObject.

public Object readObject(Input input) throws IOException {
    MultiWrapper wrapper = (MultiWrapper) schema.newMessage();
    schema.mergeFrom(input, wrapper);
    return wrapper.readFields();
}
Also used : MultiWrapper(org.apache.servicecomb.common.javassist.MultiWrapper)

Aggregations

MultiWrapper (org.apache.servicecomb.common.javassist.MultiWrapper)5 Test (org.junit.Test)3 IOException (java.io.IOException)2 Input (io.protostuff.Input)1 LinkedBuffer (io.protostuff.LinkedBuffer)1 ProtobufOutput (io.protostuff.ProtobufOutput)1