Java Code Examples for com.caucho.hessian.io.HessianInput#setSerializerFactory()

The following examples show how to use com.caucho.hessian.io.HessianInput#setSerializerFactory() . 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: Hessian1BlackListTest.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
@Test
public void testBeanDeserialize() throws IOException {
    byte[] bs = new byte[] { 77, 116, 0, 31, 99, 111, 109, 46, 97, 108, 105, 112, 97, 121, 46, 115, 116, 99,
            46, 98, 108, 46, 84, 101, 115, 116, 66, 108, 97, 99, 107, 66, 101, 97, 110, 83, 0, 6, 115, 116,
            114, 105, 110, 103, 83, 0, 3, 115, 115, 115, 122 };

    ByteArrayInputStream input = new ByteArrayInputStream(bs, 0, bs.length);
    HessianInput hin = new HessianInput(input);
    hin.setSerializerFactory(serializerFactory);

    try {
        hin.readObject();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 2
Source File: Hessian1BlackListTest.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
@Test
public void testListDeserialize() throws IOException {
    byte[] bs = new byte[] { 86, 108, 0, 0, 0, 1, 77, 116, 0, 31, 99, 111, 109, 46, 97, 108, 105, 112, 97,
            121, 46, 115, 116, 99, 46, 98, 108, 46, 84, 101, 115, 116, 66, 108, 97, 99, 107, 66, 101, 97,
            110, 83, 0, 6, 115, 116, 114, 105, 110, 103, 83, 0, 3, 115, 115, 115, 122, 122 };

    ByteArrayInputStream input = new ByteArrayInputStream(bs, 0, bs.length);
    HessianInput hin = new HessianInput(input);
    hin.setSerializerFactory(serializerFactory);

    try {
        hin.readObject();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 3
Source File: Hessian1BlackListTest.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
@Test
public void testArrayDeserialize() throws IOException {
    byte[] bs = new byte[] { 86, 116, 0, 7, 91, 111, 98, 106, 101, 99, 116, 108, 0, 0, 0, 1, 77, 116, 0, 31, 99,
            111, 109, 46, 97, 108, 105, 112, 97, 121, 46, 115, 116, 99, 46, 98, 108, 46, 84, 101, 115, 116, 66,
            108, 97, 99, 107, 66, 101, 97, 110, 83, 0, 6, 115, 116, 114, 105, 110, 103, 83, 0, 3, 115, 115, 115,
            122, 122 };

    ByteArrayInputStream input = new ByteArrayInputStream(bs, 0, bs.length);
    HessianInput hin = new HessianInput(input);
    hin.setSerializerFactory(serializerFactory);

    try {
        hin.readObject();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 4
Source File: Hessian1BlackListTest.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
@Test
public void testMapDeserialize() throws IOException {
    byte[] bs = new byte[] { 77, 116, 0, 0, 77, 116, 0, 31, 99, 111, 109, 46, 97, 108, 105, 112, 97,
            121, 46, 115, 116, 99, 46, 98, 108, 46, 84, 101, 115, 116, 66, 108, 97, 99, 107, 66, 101, 97,
            110, 83, 0, 6, 115, 116, 114, 105, 110, 103, 83, 0, 3, 115, 115, 115, 122, 82, 0, 0, 0, 1, 122 };

    ByteArrayInputStream input = new ByteArrayInputStream(bs, 0, bs.length);
    HessianInput hin = new HessianInput(input);
    hin.setSerializerFactory(serializerFactory);

    try {
        hin.readObject();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 5
Source File: ArrayInjectTest.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
@Test
public void testHessian1Array() throws IOException {
    SerializerFactory factory = new SerializerFactory();
    String s = "567400075b6f626a6563746e025674001e5b636f6d2e73756e2e726f777365742e4a646263526f77536574496d706c6e014fad786f6d2e73756e2e726f777365742e4a646263526f77536574496d706cac07636f6d6d616e640355524c0a64617461536f757263650a726f77536574547970650b73686f7744656c657465640c717565727954696d656f7574076d6178526f77730c6d61784669656c6453697a650b636f6e63757272656e637908726561644f6e6c791065736361706550726f63657373696e670969736f6c6174696f6e08666574636844697209666574636853697a6504636f6e6e02707302727306726f77734d44057265734d440d694d61746368436f6c756d6e730f7374724d61746368436f6c756d6e730c62696e61727953747265616d0d756e69636f646553747265616d0b617363696953747265616d0a6368617253747265616d036d6170096c697374656e65727306706172616d736f904e4e4ecbec46909090cbf0545492cbe8904e4e4e4e4e567400106a6176612e7574696c2e566563746f726e0a8f8f8f8f8f8f8f8f8f8f7a76929a4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e7692904d7400136a6176612e7574696c2e486173687461626c657a7a4a027a";
    byte[] bs = hex2byte(s.getBytes());
    Assert.assertTrue(s.equalsIgnoreCase(byte2hex(bs)));

    ByteArrayInputStream input = new ByteArrayInputStream(bs, 0, bs.length);
    HessianInput hin = new HessianInput(input);
    hin.setSerializerFactory(factory);

    try {
        hin.readObject();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 6
Source File: HessianSerializeCoder.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public Object decode(byte[] bytes, Class<?> returnType) throws IOException {
    if (bytes == null) {
        return null;
    }
    HessianInput input = new HessianInput(new ByteArrayInputStream(bytes));
    input.setSerializerFactory(this.serializerFactory);
    return input.readObject(returnType);
}