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

The following examples show how to use com.caucho.hessian.io.HessianOutput#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 testBeanSerialize() throws IOException {
    TestBlackBean blackBean = new TestBlackBean().setString("sss");

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    HessianOutput hout = new HessianOutput(output);
    hout.setSerializerFactory(serializerFactory);

    try {
        hout.writeObject(blackBean);
        hout.flush();
        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 testListSerialize() throws IOException {
    TestBlackBean blackBean = new TestBlackBean().setString("sss");
    List list = new ArrayList<TestBlackBean>();
    list.add(blackBean);

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    HessianOutput hout = new HessianOutput(output);
    hout.setSerializerFactory(serializerFactory);

    try {
        hout.writeObject(list);
        hout.flush();
        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 testArraySerialize() throws IOException {
    TestBlackBean blackBean = new TestBlackBean().setString("sss");
    Object[] array = new Object[] { blackBean };

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    HessianOutput hout = new HessianOutput(output);
    hout.setSerializerFactory(serializerFactory);

    try {
        hout.writeObject(array);
        hout.flush();
        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 testMapSerialize() throws IOException {
    TestBlackBean blackBean = new TestBlackBean().setString("sss");
    Map<TestBlackBean, TestBlackBean> map = new HashMap<TestBlackBean, TestBlackBean>();
    map.put(blackBean, blackBean);

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    HessianOutput hout = new HessianOutput(output);
    hout.setSerializerFactory(serializerFactory);

    try {
        hout.writeObject(map);
        hout.flush();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
}
 
Example 5
Source File: HessianSerializeCoder.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] encode(Object object) throws IOException {
    ByteArrayOutputStream binary = new ByteArrayOutputStream();
    HessianOutput hout = new HessianOutput(binary);
    hout.setSerializerFactory(this.serializerFactory);
    hout.writeObject(object);
    return binary.toByteArray();
}