public void PyroClassesPickle() { var pickler = new PickleSerializer(); var uri = new PyroURI("PYRO:something@localhost:4444"); byte[] s = pickler.serializeData(uri); object x = pickler.deserializeData(s); Assert.AreEqual(uri, x); var proxy = new PyroProxy(uri); proxy.correlation_id = Guid.NewGuid(); proxy.pyroHandshake = "apples"; proxy.pyroHmacKey = Encoding.UTF8.GetBytes("secret"); 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; Assert.AreEqual(uri.host, proxy2.hostname); Assert.AreEqual(uri.objectid, proxy2.objectid); Assert.AreEqual(uri.port, proxy2.port); Assert.IsNull(proxy2.correlation_id, "correlation_id is not serialized on the proxy object"); Assert.AreEqual(proxy.pyroHandshake, proxy2.pyroHandshake); Assert.AreEqual(proxy.pyroHmacKey, proxy2.pyroHmacKey); Assert.AreEqual(2, proxy2.pyroAttrs.Count); Assert.AreEqual(proxy.pyroAttrs, proxy2.pyroAttrs); PyroException ex = new PyroException("error"); s = pickler.serializeData(ex); x = pickler.deserializeData(s); PyroException ex2 = (PyroException) x; Assert.AreEqual(ex.Message, ex2.Message); Assert.IsNull(ex._pyroTraceback); }
public void testPickleUnpickleProxy() { PyroProxy proxy=new PyroProxy("hostname",9999,"objectid"); PyroSerializer ser = new PickleSerializer(); byte[] pickled_proxy=ser.serializeData(proxy); PyroProxy result = (PyroProxy) ser.deserializeData(pickled_proxy); Assert.AreEqual(proxy.hostname, result.hostname); Assert.AreEqual(proxy.objectid, result.objectid); Assert.AreEqual(proxy.port, result.port); }
public void testPickleUnpickleURI() { PyroURI uri=new PyroURI("PYRO:test@localhost:9999"); PyroSerializer ser = new PickleSerializer(); byte[] pickled_uri=ser.serializeData(uri); PyroURI uri2=(PyroURI) ser.deserializeData(pickled_uri); Assert.AreEqual(uri,uri2); uri=new PyroURI(); pickled_uri=ser.serializeData(uri); uri2=(PyroURI) ser.deserializeData(pickled_uri); Assert.AreEqual(uri,uri2); }
public void testPickleUnpickleProxy() { PyroProxy proxy=new PyroProxy("hostname",9999,"objectid"); proxy.pyroHmacKey = Encoding.UTF8.GetBytes("secret"); proxy.pyroHandshake = "apples"; PyroSerializer ser = new PickleSerializer(); byte[] pickled_proxy=ser.serializeData(proxy); PyroProxy result = (PyroProxy) ser.deserializeData(pickled_proxy); Assert.AreEqual(proxy.hostname, result.hostname); Assert.AreEqual(proxy.objectid, result.objectid); Assert.AreEqual(proxy.port, result.port); Assert.AreEqual(Encoding.UTF8.GetBytes("secret"), result.pyroHmacKey); Assert.AreEqual("apples", result.pyroHandshake); }
public void testUnpickleRealProxy() { byte[] pickled_proxy=new byte[] {128, 2, 99, 80, 121, 114, 111, 52, 46, 99, 111, 114, 101, 10, 80, 114, 111, 120, 121, 10, 113, 1, 41, 129, 113, 2, 99, 80, 121, 114, 111, 52, 46, 99, 111, 114, 101, 10, 85, 82, 73, 10, 113, 3, 41, 129, 113, 4, 40, 85, 4, 80, 89, 82, 79, 113, 5, 85, 10, 115, 111, 109, 101, 111, 98, 106, 101, 99, 116, 113, 6, 78, 85, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 113, 7, 77, 15, 39, 116, 98, 99, 95, 95, 98, 117, 105, 108, 116, 105, 110, 95, 95, 10, 115, 101, 116, 10, 113, 8, 93, 133, 82, 113, 9, 71, 0, 0, 0, 0, 0, 0, 0, 0, 135, 98, 46}; PyroSerializer ser = new PickleSerializer(); PyroProxy proxy=(PyroProxy)ser.deserializeData(pickled_proxy); Assert.AreEqual("someobject",proxy.objectid); Assert.AreEqual("localhost",proxy.hostname); Assert.AreEqual(9999,proxy.port); }
private void unpickleRealProxy(byte[] pickled_proxy) { PyroSerializer ser = new PickleSerializer(); PyroProxy proxy=(PyroProxy)ser.deserializeData(pickled_proxy); Assert.AreEqual("Pyro.NameServer",proxy.objectid); Assert.AreEqual("localhost",proxy.hostname); Assert.AreEqual(9090,proxy.port); Assert.AreEqual("hello", proxy.pyroHandshake); CollectionAssert.AreEqual(Encoding.UTF8.GetBytes("secret"), proxy.pyroHmacKey); ISet<string> expectedSet = new HashSet<string>(); CollectionAssert.AreEquivalent(expectedSet, proxy.pyroAttrs); expectedSet.Clear(); expectedSet.Add("lookup"); expectedSet.Add("ping"); expectedSet.Add("register"); expectedSet.Add("remove"); expectedSet.Add("list"); expectedSet.Add("count"); CollectionAssert.AreEquivalent(expectedSet, proxy.pyroMethods); expectedSet = new HashSet<string>(); CollectionAssert.AreEquivalent(expectedSet, proxy.pyroOneway); }