當前位置: 首頁>>代碼示例>>Java>>正文


Java PickleSerializer.serializeData方法代碼示例

本文整理匯總了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);
}
 
開發者ID:yncxcw,項目名稱:big-c,代碼行數:37,代碼來源:SerializePyroTest.java

示例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;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:15,代碼來源:TOPICKLE.java

示例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);
}
 
開發者ID:irmen,項目名稱:Pyrolite,代碼行數:37,代碼來源:SerializePyroTest.java


注:本文中的net.razorvine.pyro.serializer.PickleSerializer.serializeData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。