public void TestPickleUnpickleUri() { PyroURI uri = new PyroURI("PYRO:test@localhost:9999"); PyroSerializer ser = new PickleSerializer(); var pickledUri = ser.serializeData(uri); PyroURI uri2 = (PyroURI)ser.deserializeData(pickledUri); Assert.Equal(uri, uri2); uri = new PyroURI(); pickledUri = ser.serializeData(uri); uri2 = (PyroURI)ser.deserializeData(pickledUri); Assert.Equal(uri, uri2); }
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); }
private static void UnpickleRealProxy(byte[] pickledProxy) { PyroSerializer ser = new PickleSerializer(); PyroProxy proxy = (PyroProxy)ser.deserializeData(pickledProxy); Assert.Equal("Pyro.NameServer", proxy.objectid); Assert.Equal("localhost", proxy.hostname); Assert.Equal(9090, proxy.port); Assert.Equal("hello", proxy.pyroHandshake); Assert.Equal(Encoding.UTF8.GetBytes("secret"), proxy.pyroHmacKey); ISet <string> expectedSet = new HashSet <string>(); Assert.Equal(expectedSet, proxy.pyroAttrs); expectedSet.Clear(); expectedSet.Add("lookup"); expectedSet.Add("ping"); expectedSet.Add("register"); expectedSet.Add("remove"); expectedSet.Add("list"); expectedSet.Add("count"); expectedSet.Add("set_metadata"); proxy.pyroMethods.ExceptWith(expectedSet); Assert.Equal(0, proxy.pyroMethods.Count); // "something is wrong with the expected exposed methods" expectedSet = new HashSet <string>(); Assert.Equal(expectedSet, proxy.pyroOneway); }
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.Equal(uri, x); var proxy = new PyroProxy(uri) { correlation_id = Guid.NewGuid(), pyroHandshake = "apples", pyroHmacKey = Encoding.UTF8.GetBytes("secret"), pyroAttrs = new HashSet <string> { "attr1", "attr2" } }; s = pickler.serializeData(proxy); x = pickler.deserializeData(s); PyroProxy proxy2 = (PyroProxy)x; Assert.Equal(uri.host, proxy2.hostname); Assert.Equal(uri.objectid, proxy2.objectid); Assert.Equal(uri.port, proxy2.port); Assert.Null(proxy2.correlation_id); // "correlation_id is not serialized on the proxy object" Assert.Equal(proxy.pyroHandshake, proxy2.pyroHandshake); Assert.Equal(proxy.pyroHmacKey, proxy2.pyroHmacKey); Assert.Equal(2, proxy2.pyroAttrs.Count); Assert.Equal(proxy.pyroAttrs, proxy2.pyroAttrs); PyroException ex = new PyroException("error"); s = pickler.serializeData(ex); x = pickler.deserializeData(s); PyroException ex2 = (PyroException)x; Assert.Equal("[Pyro4.errors.PyroError] error", ex2.Message); Assert.Null(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 TestUnpickleProto0Bytes() { var pickle = File.ReadAllBytes("pickled_bytes_level0.dat"); PickleSerializer ser = new PickleSerializer(); string x = (string)ser.deserializeData(pickle); Assert.Equal(2496, x.Length); // validate that the bytes in the string are what we expect (based on md5 hash) var m = SHA1.Create(); var hashb = m.ComputeHash(Encoding.UTF8.GetBytes(x)); string digest = BitConverter.ToString(hashb); Assert.Equal("22-f4-5b-87-63-83-c9-1b-1c-b2-0a-fe-51-ee-3b-30-f5-a8-5d-4c", digest.ToLowerInvariant()); }
public void TestPickleUnpickleProxy() { PyroProxy proxy = new PyroProxy("hostname", 9999, "objectid") { pyroHmacKey = Encoding.UTF8.GetBytes("secret"), pyroHandshake = "apples" }; PyroSerializer ser = new PickleSerializer(); var pickledProxy = ser.serializeData(proxy); PyroProxy result = (PyroProxy)ser.deserializeData(pickledProxy); Assert.Equal(proxy.hostname, result.hostname); Assert.Equal(proxy.objectid, result.objectid); Assert.Equal(proxy.port, result.port); Assert.Equal(Encoding.UTF8.GetBytes("secret"), result.pyroHmacKey); Assert.Equal("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); }