Java Code Examples for com.alibaba.dubbo.common.serialize.ObjectInput#readBytes()

The following examples show how to use com.alibaba.dubbo.common.serialize.ObjectInput#readBytes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 2
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 3
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 4
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 5
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 6
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 7
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 8
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {}
}
 
Example 9
Source File: AbstractSerializationTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 10
Source File: AbstractSerializationTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {}
}
 
Example 11
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 12
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {}
}
 
Example 13
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 14
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {}
}
 
Example 15
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example 16
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_BytesRange() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    byte[] expectedArray = new byte[9];
    System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
    assertArrayEquals(expectedArray, deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {}
}