本文整理汇总了Java中net.razorvine.pyro.serializer.PickleSerializer.serializeData方法的典型用法代码示例。如果您正苦于以下问题:Java PickleSerializer.serializeData方法的具体用法?Java PickleSerializer.serializeData怎么用?Java PickleSerializer.serializeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.razorvine.pyro.serializer.PickleSerializer
的用法示例。
在下文中一共展示了PickleSerializer.serializeData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPyroClassesPickle
import net.razorvine.pyro.serializer.PickleSerializer; //导入方法依赖的package包/类
@Test
public void testPyroClassesPickle() throws IOException
{
PickleSerializer pickler = new PickleSerializer();
PyroURI uri = new PyroURI("PYRO:[email protected]:4444");
byte[] s = pickler.serializeData(uri);
Object x = pickler.deserializeData(s);
assertEquals(uri, x);
PyroProxy proxy = new PyroProxy(uri);
proxy.correlation_id = UUID.randomUUID();
proxy.pyroHmacKey = "secret".getBytes();
proxy.pyroHandshake = "apples";
proxy.pyroAttrs = new HashSet<String>();
proxy.pyroAttrs.add("attr1");
proxy.pyroAttrs.add("attr2");
s = pickler.serializeData(proxy);
x = pickler.deserializeData(s);
PyroProxy proxy2 = (PyroProxy) x;
assertEquals(uri.host, proxy2.hostname);
assertEquals(uri.objectid, proxy2.objectid);
assertEquals(uri.port, proxy2.port);
assertNull(proxy2.correlation_id); // correlation_id is not serialized on the proxy object")
assertEquals(proxy.pyroHandshake, proxy2.pyroHandshake);
assertArrayEquals(proxy.pyroHmacKey, proxy2.pyroHmacKey);
assertEquals(2, proxy2.pyroAttrs.size());
assertEquals(proxy.pyroAttrs, proxy2.pyroAttrs);
PyroException ex = new PyroException("error");
ex._pyroTraceback = "traceback";
s = pickler.serializeData(ex);
x = pickler.deserializeData(s);
PyroException ex2 = (PyroException) x;
assertEquals(ex.getMessage(), ex2.getMessage());
assertEquals("traceback", ex2._pyroTraceback);
}
示例2: apply
import net.razorvine.pyro.serializer.PickleSerializer; //导入方法依赖的package包/类
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
Object o = stack.pop();
try {
PickleSerializer serializer = new PickleSerializer();
byte[] data = serializer.serializeData(o);
stack.push(data);
} catch (IOException ioe) {
throw new WarpScriptException(ioe);
}
return stack;
}
示例3: testPyroClassesPickle
import net.razorvine.pyro.serializer.PickleSerializer; //导入方法依赖的package包/类
@Test
public void testPyroClassesPickle() throws IOException
{
PickleSerializer pickler = new PickleSerializer();
PyroURI uri = new PyroURI("PYRO:[email protected]:4444");
byte[] s = pickler.serializeData(uri);
Object x = pickler.deserializeData(s);
assertEquals(uri, x);
PyroProxy proxy = new PyroProxy(uri);
proxy.correlation_id = UUID.randomUUID();
proxy.pyroHmacKey = "secret".getBytes();
proxy.pyroHandshake = "apples";
proxy.pyroAttrs = new HashSet<String>();
proxy.pyroAttrs.add("attr1");
proxy.pyroAttrs.add("attr2");
s = pickler.serializeData(proxy);
x = pickler.deserializeData(s);
PyroProxy proxy2 = (PyroProxy) x;
assertEquals(uri.host, proxy2.hostname);
assertEquals(uri.objectid, proxy2.objectid);
assertEquals(uri.port, proxy2.port);
assertNull(proxy2.correlation_id); // correlation_id is not serialized on the proxy object")
assertEquals(proxy.pyroHandshake, proxy2.pyroHandshake);
assertArrayEquals(proxy.pyroHmacKey, proxy2.pyroHmacKey);
assertEquals(2, proxy2.pyroAttrs.size());
assertEquals(proxy.pyroAttrs, proxy2.pyroAttrs);
PyroException ex = new PyroException("error");
ex._pyroTraceback = "traceback";
s = pickler.serializeData(ex);
x = pickler.deserializeData(s);
PyroException ex2 = (PyroException) x;
assertEquals("[Pyro4.errors.PyroError] error", ex2.getMessage());
assertEquals("traceback", ex2._pyroTraceback);
}