Skip to content

Commit

Permalink
some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Jun 15, 2015
1 parent 1ba9d46 commit f194b68
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 67 deletions.
3 changes: 2 additions & 1 deletion README.txt
Expand Up @@ -98,7 +98,8 @@ features which may eventually be utilized, but for now, only version 2 is used.
The source archive contains the full source, and also unit test code and a
couple of example programs in the java/test/ directory.

Pyrolite speaks Pyro4 protocol version 47 only (Pyro 4.26 and later).
Pyrolite speaks Pyro4 protocol version 48 only (Pyro 4.38 and later).
(get an older version of Pyrolite if you need to connect to earlier Pyro versions)
The java library requires java 1.6 or newer.
The .net library requires .net framework 4.0 or newer.
The Java code was developed using Eclipse.
Expand Down
24 changes: 24 additions & 0 deletions dotnet/Pyrolite.Tests/Pyro/MessageTests.cs
Expand Up @@ -159,6 +159,30 @@ public void testRecvAnnotations()
Assert.AreEqual(new byte[]{10,20,30,40,50}, msg.annotations["TEST"]);
Assert.IsTrue(msg.annotations.ContainsKey("HMAC"));
}

class CustomAnnProxy : PyroProxy
{
public CustomAnnProxy(PyroURI uri) : base(uri) {}

public override IDictionary<string, byte[]> annotations()
{
var ann = base.annotations();
ann["XYZZ"] = Encoding.UTF8.GetBytes("some value");
return ann;
}
}

[Test]
public void testProxyAnnotations()
{
var p = new CustomAnnProxy(new PyroURI("PYRO:dummy@localhost:50000"));
p.pyroHmacKey = Encoding.UTF8.GetBytes("secret");
p.correlation_id = Guid.NewGuid();
var annotations = p.annotations();
Assert.AreEqual(2, annotations.Count);
Assert.IsTrue(annotations.ContainsKey("CORR"));
Assert.IsTrue(annotations.ContainsKey("XYZZ"));
}

[Test]
[ExpectedException(typeof(PyroException), ExpectedMessage="invalid protocol version: 25455")]
Expand Down
6 changes: 6 additions & 0 deletions dotnet/Pyrolite.Tests/Pyro/SerializePyroTests.cs
Expand Up @@ -50,6 +50,7 @@ public void PyroClassesSerpent()
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");
Expand Down Expand Up @@ -81,6 +82,9 @@ public void PyroClassesPickle()
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;
Expand All @@ -90,6 +94,8 @@ public void PyroClassesPickle()
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);
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Pyrolite/Pyro/PyroProxy.cs
Expand Up @@ -105,7 +105,6 @@ public class PyroProxy : DynamicObject, IDisposable {
}

// invoke the get_metadata method on the daemon
Console.WriteLine("INVOKE get_metadata"); // TODO
Hashtable result = this.internal_call("get_metadata", Config.DAEMON_NAME, 0, false, new [] {objectId}) as Hashtable;
if(result==null)
return;
Expand Down Expand Up @@ -201,6 +200,7 @@ public override bool TrySetMember(SetMemberBinder binder, object value)
/// <summary>
/// Returns a dict with annotations to be sent with each message.
/// Default behavior is to include the current correlation id (if it is set).
/// (note that the Message may include an additional hmac annotation at the moment the message is sent)
/// </summary>
public virtual IDictionary<string, byte[]> annotations()
{
Expand Down

This file was deleted.

0 comments on commit f194b68

Please sign in to comment.