use of com.alibaba.com.caucho.hessian.io.Hessian2Input in project dubbo by alibaba.
the class SerializationCompareTest method testH2oPerm.
@Test
public void testH2oPerm() throws Exception {
Bean bean = new Bean();
int len = 0;
long now = System.currentTimeMillis();
for (int i = 0; i < 500; i++) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(os);
out.writeObject(bean);
out.flushBuffer();
os.close();
if (i == 0)
len = os.toByteArray().length;
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Hessian2Input in = new Hessian2Input(is);
assertEquals(in.readObject().getClass(), Bean.class);
}
System.out.println("Hessian2 write and parse 500 times in " + (System.currentTimeMillis() - now) + "ms, size " + len);
}
use of com.alibaba.com.caucho.hessian.io.Hessian2Input in project dubbo by alibaba.
the class X509Signature method unwrapHeaders.
public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException {
if (_cert == null)
throw new IOException("X509Signature.unwrap requires a certificate");
InputStream is = new SignatureInputStream(in);
Hessian2Input filter = new Hessian2Input(is);
filter.setCloseStreamOnClose(true);
return filter;
}
use of com.alibaba.com.caucho.hessian.io.Hessian2Input in project dubbo by alibaba.
the class SerializeTestBase method baseHession2Serialize.
/**
* hession2 serialize util
*
* @param data
* @param <T>
* @return
* @throws IOException
*/
protected <T> T baseHession2Serialize(T data) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bout);
out.writeObject(data);
out.flush();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
Hessian2Input input = new Hessian2Input(bin);
return (T) input.readObject();
}
use of com.alibaba.com.caucho.hessian.io.Hessian2Input in project dubbo by alibaba.
the class Java8TimeSerializerTest method testJava8Time.
private void testJava8Time(Object expected) throws IOException {
os.reset();
Hessian2Output output = new Hessian2Output(os);
output.setSerializerFactory(factory);
output.writeObject(expected);
output.flush();
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Hessian2Input input = new Hessian2Input(is);
input.setSerializerFactory(factory);
Object actual = input.readObject();
TestCase.assertEquals(expected, actual);
}
use of com.alibaba.com.caucho.hessian.io.Hessian2Input in project dubbo by alibaba.
the class X509Encryption method unwrapHeaders.
public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException {
if (_privateKey == null)
throw new IOException("X509Encryption.unwrap requires a private key");
if (_cert == null)
throw new IOException("X509Encryption.unwrap requires a certificate");
InputStream is = new EncryptInputStream(in);
Hessian2Input filter = new Hessian2Input(is);
filter.setCloseStreamOnClose(true);
return filter;
}
Aggregations