Пример #1
0
        public void HasMember()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Assert.Equal(true, testIntf.HasMember("ping", "s", "s"));
            Assert.Equal(true, testIntf.HasMember("chirp", "", "s"));

            /*
             * expected to be false even though the members exist the signatures do not
             * match what is expected.
             */
            Assert.Equal(false, testIntf.HasMember("ping", "i", "s"));
            Assert.Equal(false, testIntf.HasMember("chirp", "b", null));
            Assert.Equal(false, testIntf.HasMember("invalid", "s", null));

            bus.Dispose();
        }
Пример #2
0
        public void GetSignal()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("foo", "", "", ""));
            status = testIntf.AddSignal("chirp", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Verify the signal
            AllJoyn.InterfaceDescription.Member signalMember = null;
            signalMember = testIntf.GetSignal("chirp");
            Assert.NotNull(signalMember);

            Assert.Equal(testIntf, signalMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
            Assert.Equal("chirp", signalMember.Name);
            Assert.Equal("s", signalMember.Signature);
            Assert.Equal("", signalMember.ReturnSignature);
            Assert.Equal("data", signalMember.ArgNames);

            AllJoyn.InterfaceDescription.Member methodMember = null;
            methodMember = testIntf.GetSignal("foo");
            //since "foo" is a method GetSignal should return null
            Assert.Null(methodMember);

            methodMember = testIntf.GetSignal("bar");
            // "bar" is not a member of the interface it should return null
            Assert.Null(methodMember);
        }
Пример #3
0
        public void Activate()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            /* once the interface has been activated we should not be able to add new members */
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "pong", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.BUS_INTERFACE_ACTIVATED, status);

            bus.Dispose();
        }
Пример #4
0
        public void GetProperty()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            AllJoyn.InterfaceDescription.Property prop1 = testIntf.GetProperty("prop1");
            Assert.Equal("prop1", prop1.Name);
            Assert.Equal("s", prop1.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Read, prop1.Access);

            AllJoyn.InterfaceDescription.Property prop2 = testIntf.GetProperty("prop2");
            Assert.Equal("prop2", prop2.Name);
            Assert.Equal("i", prop2.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Write, prop2.Access);

            AllJoyn.InterfaceDescription.Property prop3 = testIntf.GetProperty("prop3");
            Assert.Equal("prop3", prop3.Name);
            Assert.Equal("u", prop3.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.ReadWrite, prop3.Access);
        }
Пример #5
0
        public void AddMethod()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface(INTERFACE_NAME, out testIntf));
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));

            // Test adding a Signal
            status = testIntf.AddMethod("pong", "", "s", "pong-in", AllJoyn.InterfaceDescription.AnnotationFlags.Deprecated | AllJoyn.InterfaceDescription.AnnotationFlags.NoReply);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            string expectedIntrospect = "<interface name=\"org.alljoyn.test.InterfaceDescriptionTest\">\n" +
                                        "  <method name=\"ping\">\n" +
                                        "    <arg name=\"in\" type=\"s\" direction=\"in\"/>\n" +
                                        "    <arg name=\"out\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </method>\n" +
                                        "  <method name=\"pong\">\n" +
                                        "    <arg name=\"pong-in\" type=\"s\" direction=\"out\"/>\n" +
                                        "    <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n" +
                                        "    <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n" +
                                        "  </method>\n" +
                                        "</interface>\n";

            Assert.Equal(expectedIntrospect, testIntf.Introspect());
        }
Пример #6
0
        public void GetMethod()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("foo", "", ""));

            // Verify the ping member
            AllJoyn.InterfaceDescription.Member pingMember = null;
            pingMember = testIntf.GetMethod("ping");
            Assert.NotNull(pingMember);

            Assert.Equal(testIntf, pingMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.MethodCall, pingMember.MemberType);
            Assert.Equal("ping", pingMember.Name);
            Assert.Equal("s", pingMember.Signature);
            Assert.Equal("s", pingMember.ReturnSignature);
            Assert.Equal("in,out", pingMember.ArgNames);

            AllJoyn.InterfaceDescription.Member fooMember = null;
            fooMember = testIntf.GetMethod("foo");
            // since "foo" is a signal is should return null when using GetMethod
            Assert.Null(fooMember);

            fooMember = testIntf.GetMethod("bar");
            // since "bar" is not a member of the interface it should be null
            Assert.Null(fooMember);
        }
Пример #7
0
        public void HasProperty()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // check for the properties
            Assert.Equal(true, testIntf.HasProperty("prop1"));
            Assert.Equal(true, testIntf.HasProperty("prop2"));
            Assert.Equal(true, testIntf.HasProperty("prop3"));
            Assert.Equal(false, testIntf.HasProperty("invalid_prop"));

            bus.Dispose();
        }
Пример #8
0
        public void IsSecure_DepricatedCreateInterface()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create an insecure interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(false, testIntf.IsSecure);

            bus.DeleteInterface(testIntf);

            // create a secure interface
            status = bus.CreateInterface(INTERFACE_NAME, true, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(true, testIntf.IsSecure);

            bus.Dispose();
        }
Пример #9
0
        public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(path, false)
        {
            AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME);
            AllJoyn.QStatus status = AddInterface(exampleIntf);
            if (!status)
            {
                serverText += "Server Failed to add interface " + status.ToString() + "\n";
                Debug.Log("Server Failed to add interface " + status.ToString());
            }

            AllJoyn.InterfaceDescription.Member catMember = exampleIntf.GetMember("acc");
            status = AddMethodHandler(catMember, this.Acc);
            if (!status)
            {
                serverText += "Server Failed to add method handler " + status.ToString() + "\n";
                Debug.Log("Server Failed to add method handler " + status.ToString());
            }

            catMember = exampleIntf.GetMember("data");
            status    = AddMethodHandler(catMember, this.Data);
            if (!status)
            {
                serverText += "Server Failed to add method handler " + status.ToString() + "\n";
                Debug.Log("Server Failed to add method handler " + status.ToString());
            }
        }
Пример #10
0
        public void AddSignal()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddSignal("signal1", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Verify the signal
            AllJoyn.InterfaceDescription.Member signalMember = null;
            signalMember = testIntf.GetMember("signal1");
            Assert.NotNull(signalMember);

            Assert.Equal(testIntf, signalMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
            Assert.Equal("signal1", signalMember.Name);
            Assert.Equal("s", signalMember.Signature);
            Assert.Equal("", signalMember.ReturnSignature);
            Assert.Equal("data", signalMember.ArgNames);
            //TODO add in code to use new annotation methods

            bus.Dispose();
        }
Пример #11
0
        public string CallRemoteMethod()
        {
            using (AllJoyn.ProxyBusObject remoteObj = new AllJoyn.ProxyBusObject(sMsgBus, SERVICE_NAME, SERVICE_PATH, sSessionId))
            {
                AllJoyn.InterfaceDescription alljoynTestIntf = sMsgBus.GetInterface(INTERFACE_NAME);
                if (alljoynTestIntf == null)
                {
                    throw new Exception("Client Failed to get test interface.");
                }
                remoteObj.AddInterface(alljoynTestIntf);

                AllJoyn.Message reply  = new AllJoyn.Message(sMsgBus);
                AllJoyn.MsgArgs inputs = new AllJoyn.MsgArgs(2);
                inputs[0] = "Hello ";
                inputs[1] = "World!";

                AllJoyn.QStatus status = remoteObj.MethodCallSynch(SERVICE_NAME, "cat", inputs, reply, 5000, 0);

                if (status)
                {
                    Console.WriteLine("{0}.{1} (path={2}) returned \"{3}\"", SERVICE_NAME, "cat", SERVICE_PATH,
                                      (string)reply[0]);
                    return((string)reply[0]);
                }
                else
                {
                    Console.WriteLine("MethodCall on {0}.{1} failed", SERVICE_NAME, "cat");
                    return("");
                }
            }
        }
Пример #12
0
        public string CallRemoteMethod()
        {
            using (AllJoyn.ProxyBusObject remoteObj = new AllJoyn.ProxyBusObject(sMsgBus, SERVICE_NAME, SERVICE_PATH, sSessionId))
            {
                AllJoyn.InterfaceDescription alljoynTestIntf = sMsgBus.GetInterface(INTERFACE_NAME);
                if (alljoynTestIntf == null)
                {
                    //throw new Exception("Client Failed to get test interface.");
                    return("");
                }
                else
                {
                    remoteObj.AddInterface(alljoynTestIntf);

                    AllJoyn.Message reply  = new AllJoyn.Message(sMsgBus);
                    AllJoyn.MsgArgs inputs = new AllJoyn.MsgArgs(2);
                    inputs[0] = "Hello ";
                    inputs[1] = "World!";

                    AllJoyn.QStatus status = remoteObj.MethodCallSynch(SERVICE_NAME, "cat", inputs, reply, 5000, 0);

                    if (status)
                    {
                        //Debug.Log(SERVICE_NAME + ".cat(path=" + SERVICE_PATH + ") returned \"" + (string)reply[0] + "\"");
                        return((string)reply[0]);
                    }
                    else
                    {
                        Debug.Log("MethodCall on " + SERVICE_NAME + ".cat failed");
                        return("");
                    }
                }
            }
        }
Пример #13
0
        public void PropertyAnnotations()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            AllJoyn.InterfaceDescription.Property property = testIntf.GetProperty("prop");
            Assert.Equal("prop", property.Name);
            Assert.Equal("s", property.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Read, property.Access);

            string value = "";

            Assert.True(testIntf.GetPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", ref value));
            Assert.Equal("here", value);

            Assert.True(property.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = property.GetAnnotations();

            Assert.Equal(5, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);
            bus.Dispose();
        }
Пример #14
0
        public void IntrospectRemoteObject()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
            Assert.NotNull(proxyBusObject);

            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.IntrospectRemoteObject());

            AllJoyn.InterfaceDescription interfaceDescription = proxyBusObject.GetInterface("org.freedesktop.DBus.Introspectable");

            string expectedIntrospect = "<interface name=\"org.freedesktop.DBus.Introspectable\">\n" +
                                        "  <method name=\"Introspect\">\n" +
                                        "    <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </method>\n" +
                                        "</interface>\n";

            Assert.Equal(expectedIntrospect, interfaceDescription.Introspect());


            proxyBusObject.Dispose();
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
            busAttachment.Dispose();
        }
Пример #15
0
        public void pin_keyx()
        {
            ResetAuthFlags();
            clientBus.ClearKeyStore();

            PinKeyX_service_authlistener serviceAuthlistener = new PinKeyX_service_authlistener(this);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.EnablePeerSecurity("ALLJOYN_PIN_KEYX", serviceAuthlistener, null, false));

            serviceBus.ClearKeyStore();

            Assert.Equal(AllJoyn.QStatus.OK, SetUpAuthService());

            PinKeyX_client_authlistener clientAuthlistener = new PinKeyX_client_authlistener(this);

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.EnablePeerSecurity("ALLJOYN_PIN_KEYX", clientAuthlistener, null, false));
            clientBus.ClearKeyStore();

            // create+activate the interface
            AllJoyn.QStatus status;
            AllJoyn.InterfaceDescription iFace = null;
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out iFace));
            Assert.NotNull(iFace);

            Assert.Equal(AllJoyn.QStatus.OK, iFace.AddMethod("ping", "s", "s", "in,out"));
            iFace.Activate();

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0);
            Assert.NotNull(proxyBusObject);
            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.AddInterface(iFace));

            AllJoyn.MsgArg  input    = new AllJoyn.MsgArg("s", "AllJoyn");
            AllJoyn.Message replyMsg = new AllJoyn.Message(clientBus);
            status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.Equal("AllJoyn", (string)replyMsg[0]);

            Assert.True(authflags.requestCreds_service);
            Assert.True(authflags.authComplete_serivce);

            Assert.True(authflags.requestCreds_client);
            Assert.True(authflags.authComplete_client);

            clientAuthlistener.Dispose();
            serviceAuthlistener.Dispose();

            busObject.Dispose();

            proxyBusObject.Dispose();


            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Join());

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Join());

            serviceBus.Dispose();
            clientBus.Dispose();
        }
Пример #16
0
        public void MethodAnnotations()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "one", "black_cat");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            string value = "";

            testIntf.GetMemberAnnotation("ping", "one", ref value);
            Assert.Equal("black_cat", value);

            AllJoyn.InterfaceDescription.Member member = testIntf.GetMember("ping");

            Assert.True(member.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = member.GetAnnotations();

            Assert.Equal(6, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);
            Assert.True(annotations.TryGetValue("one", out value));
            Assert.Equal("black_cat", value);
        }
Пример #17
0
        public void SignalAnnotations()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);
            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            string value = "";

            testIntf.GetMemberAnnotation("chirp", "org.alljoyn.test.annotation.one", ref value);
            Assert.Equal("here", value);

            AllJoyn.InterfaceDescription.Member signal = testIntf.GetMember("chirp");

            Assert.True(signal.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = signal.GetAnnotations();

            Assert.Equal(5, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);

            bus.Dispose();
        }
Пример #18
0
            public TestBusObject(AllJoyn.BusAttachment bus, string path)
                : base(path, false)
            {
                AllJoyn.InterfaceDescription testIntf = bus.GetInterface("org.alljoyn.test.BusAttachment");
                AllJoyn.QStatus status = AddInterface(testIntf);
                Assert.Equal(AllJoyn.QStatus.OK, status);

                testSignalMember = testIntf.GetMember("testSignal");
            }
Пример #19
0
        public void CreateInterface()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.InterfaceDescription testIntf = null;
            status = busAttachment.CreateInterface("org.alljoyn.test.BusAttachment", out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);
        }
Пример #20
0
        public void GetName()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(INTERFACE_NAME, testIntf.Name);
        }
Пример #21
0
            public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(bus, path, false)
            {
                AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME);
                AllJoyn.QStatus status = AddInterface(exampleIntf);
                if (!status)
                {
                    chatText = "Chat Failed to add interface " + status.ToString() + "\n" + chatText;
                    Debug.Log("Chat Failed to add interface " + status.ToString());
                }

                chatMember = exampleIntf.GetMember("chat");
            }
Пример #22
0
        public void srp_keyx2()
        {
            ResetAuthFlags();
            clientBus.ClearKeyStore();

            SrpKeyx2_service_authlistener serviceAuthlistener = new SrpKeyx2_service_authlistener(this);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.EnablePeerSecurity("ALLJOYN_SRP_KEYX", serviceAuthlistener, null, false));

            serviceBus.ClearKeyStore();

            Assert.Equal(AllJoyn.QStatus.OK, SetUpAuthService());

            SrpKeyx2_client_authlistener clientAuthlistener = new SrpKeyx2_client_authlistener(this);

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.EnablePeerSecurity("ALLJOYN_SRP_KEYX", clientAuthlistener, null, false));
            clientBus.ClearKeyStore();

            // create+activate the interface
            AllJoyn.QStatus status;
            AllJoyn.InterfaceDescription iFace = null;
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out iFace));
            Assert.NotNull(iFace);

            Assert.Equal(AllJoyn.QStatus.OK, iFace.AddMethod("ping", "s", "s", "in,out"));
            iFace.Activate();

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0);
            Assert.NotNull(proxyBusObject);
            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.AddInterface(iFace));

            AllJoyn.MsgArg  input    = new AllJoyn.MsgArg("s", "AllJoyn");
            AllJoyn.Message replyMsg = new AllJoyn.Message(clientBus);
            status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0);
            Assert.Equal(AllJoyn.QStatus.BUS_REPLY_IS_ERROR_MESSAGE, status);

            Assert.True(authflags.requestCreds_service);
            Assert.True(authflags.authComplete_serivce);

            Assert.True(authflags.authComplete_client);
            // Authentication complete can occure before the SecurityViolation callback
            // with authentication complete the MethodCall will return the BUS_REPLY_IS_ERROR_MESSAGE
            // and the code could check for the sercurityViolation_client before it is actually set
            // for this reason we need to wait for the flag to be set.
            Wait(TimeSpan.FromSeconds(5));
            Assert.True(authflags.securityViolation_client);
            clientAuthlistener.Dispose();
            serviceAuthlistener.Dispose();

            busObject.Dispose();

            proxyBusObject.Dispose();
        }
Пример #23
0
        public void GetMember()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Verify the ping member
            AllJoyn.InterfaceDescription.Member pingMember = null;
            pingMember = testIntf.GetMember("ping");
            Assert.NotNull(pingMember);

            Assert.Equal(testIntf, pingMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.MethodCall, pingMember.MemberType);
            Assert.Equal("ping", pingMember.Name);
            Assert.Equal("s", pingMember.Signature);
            Assert.Equal("s", pingMember.ReturnSignature);
            Assert.Equal("in,out", pingMember.ArgNames);
            //TODO add in code to use new annotation methods
            //Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, pingMember.Annotation);

            // Verify the chirp member
            AllJoyn.InterfaceDescription.Member chirpMember = null;
            chirpMember = testIntf.GetMember("chirp");
            Assert.NotNull(chirpMember);

            Assert.Equal(testIntf, chirpMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, chirpMember.MemberType);
            Assert.Equal("chirp", chirpMember.Name);
            Assert.Equal("", chirpMember.Signature);
            Assert.Equal("s", chirpMember.ReturnSignature);
            Assert.Equal("chirp", chirpMember.ArgNames);
            //TODO add in code to use new annotation methods
            //Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, chirpMember.Annotation);

            bus.Dispose();
        }
Пример #24
0
            public MethodTestBusObject(AllJoyn.BusAttachment bus, string path)
                : base(path, false)
            {
                // add the interface to the bus object
                AllJoyn.InterfaceDescription testIntf = bus.GetInterface(INTERFACE_NAME);
                AllJoyn.QStatus status = AddInterface(testIntf);
                Assert.Equal(AllJoyn.QStatus.OK, status);

                // register a method handler for the ping method
                AllJoyn.InterfaceDescription.Member pingMember = testIntf.GetMember("ping");
                status = AddMethodHandler(pingMember, this.Ping);
                Assert.Equal(AllJoyn.QStatus.OK, status);
            }
Пример #25
0
            public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(path, false)
            {
                AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME);
                AllJoyn.QStatus status = AddInterface(exampleIntf);
                if (!status)
                {
                    //Debug.LogError("Failed to add interface " + status.ToString());
                }

                playerMember    = exampleIntf.GetMember("player");
                enemyInitMember = exampleIntf.GetMember("enemyInit");
                enemyAgroMember = exampleIntf.GetMember("enemyAgro");
                enemyHPMember   = exampleIntf.GetMember("enemyHP");
            }
Пример #26
0
        public void AddProperty()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
Пример #27
0
        public void CreateInterface()
        {
            AllJoyn.QStatus       status = AllJoyn.QStatus.FAIL;
            AllJoyn.BusAttachment bus    = null;
            bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(bus);

            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface("org.alljoyn.test.BusAttachment", out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // TODO: move these into a teardown method?
            bus.Dispose();
        }
Пример #28
0
        public void AddInterface()
        {
            AllJoyn.InterfaceDescription testIntf = null;
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.CreateInterface(INTERFACE_NAME, out testIntf));
            Assert.NotNull(testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out"));
            testIntf.Activate();

            proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
            Assert.NotNull(proxyBusObject);

            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.AddInterface(testIntf));

            Assert.True(proxyBusObject.ImplementsInterface(INTERFACE_NAME));
        }
Пример #29
0
        public void HasProperties()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            /*
             * At this point this is an empty interface the call to hasproperties should
             * return false.
             */
            Assert.False(testIntf.HasProperties);
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            /*
             * At this point the interface only contains a method call the call to
             * hasproperties should return false.
             */
            Assert.False(testIntf.HasProperties);
            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            /*
             * At this point the interface only contains a property the call to
             * hasproperties should return true.
             */
            Assert.True(testIntf.HasProperties);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            /*
             * At this point the interface only contains multiple properties the call to
             * hasproperties should return true.
             */
            Assert.True(testIntf.HasProperties);

            bus.Dispose();
        }
Пример #30
0
            public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(bus, path, false)
            {
                AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME);
                AllJoyn.QStatus status = AddInterface(exampleIntf);
                if (!status)
                {
                    Console.WriteLine("Server Failed to add interface {0}", status);
                }

                AllJoyn.InterfaceDescription.Member catMember = exampleIntf.GetMember("cat");
                status = AddMethodHandler(catMember, this.Cat);
                if (!status)
                {
                    Console.WriteLine("Server Failed to add method handler {0}", status);
                }
            }