本文整理匯總了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);
}