public void TestListenerRegisteredUnregistered()
        {
            AllJoyn.BusAttachment bus         = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.BusListener   busListener = new TestBusListener(this);
            listenerRegistered   = false;
            listenerUnregistered = false;
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // start the bus attachment
            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // connect to the bus
            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            bus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerRegistered);

            bus.UnregisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerUnregistered);

            // TODO: move these into a teardown method?
            busListener.Dispose();
            bus.Dispose();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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();
        }
        public void TestNameOwnerChanged()
        {
            // create bus attachment
            AllJoyn.BusAttachment bus    = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.QStatus       status = AllJoyn.QStatus.FAIL;

            // start the bus attachment
            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // connect to the bus
            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            listenerRegistered = false;
            nameOwnerChanged   = false;

            // register the bus listener
            AllJoyn.BusListener busListener = new TestBusListener(this);
            bus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerRegistered);

            // test name owner changed
            status = bus.RequestName(ObjectName, 0);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, nameOwnerChanged);

            busListener.Dispose();
            bus.Dispose();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public void EnableConcurrentCallbacks_Used()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;
            callbackStatus         = AllJoyn.QStatus.FAIL;
            listenerRegisteredFlag = false;
            nameOwnerChangedFlag   = false;

            mbus = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.BusListener busListener = new BusListenerEnableConcurrentCallbacks(this);

            // start the bus attachment
            status = mbus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // connect to the bus
            status = mbus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            mbus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.True(listenerRegisteredFlag);

            mbus.RequestName(ObjectName, 0);
            Wait(MaxWaitTime);
            Assert.True(nameOwnerChangedFlag);
            Assert.Equal(AllJoyn.QStatus.OK, callbackStatus);

            mbus.UnregisterBusListener(busListener);
            mbus.Stop();
            mbus.Join();
            mbus.Dispose();
        }
Beispiel #8
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();
        }
Beispiel #9
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();
        }
Beispiel #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();
        }
        public void TestObjectRegisteredUnregistered()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // create+start+connect bus attachment
            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("BusObjectTest", true);
            Assert.NotNull(bus);

            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // create the bus object
            TestBusObject testBusObject = new TestBusObject(bus, OBJECT_PATH, this);

            objectRegistered   = false;
            objectUnregistered = false;

            // test registering the bus object
            status = bus.RegisterBusObject(testBusObject);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, objectRegistered);

            // test unregistering the bus object
            bus.UnregisterBusObject(testBusObject);
            Wait(MaxWaitTime);
            Assert.Equal(true, objectUnregistered);

            bus.Dispose();
        }
Beispiel #12
0
        public void CreateDispose()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("MessageTest", false);
            AllJoyn.Message       message       = new AllJoyn.Message(busAttachment);

            message.Dispose();
            busAttachment.Dispose();
        }
Beispiel #13
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();
        }
        public void TestFoundNameByTransport()
        {
            // create bus attachment
            AllJoyn.BusAttachment bus    = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.QStatus       status = AllJoyn.QStatus.FAIL;

            // start the bus attachment
            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // connect to the bus
            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            listenerRegistered  = false;
            foundAdvertisedName = false;
            nameOwnerChanged    = false;
            transportFound      = AllJoyn.TransportMask.None;

            // register the bus listener
            AllJoyn.BusListener busListener = new TestBusListener(this);
            bus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerRegistered);

            AllJoyn.SessionOpts sessionOpts = new AllJoyn.SessionOpts(
                AllJoyn.SessionOpts.TrafficType.Messages, false,
                AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);

            // advertise the name, & see if we find it
            status = bus.FindAdvertisedNameByTransport(ObjectName, AllJoyn.TransportMask.Local);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Wait(MaxWaitTime);
            Assert.Equal(true, foundAdvertisedName);
            Assert.Equal(AllJoyn.TransportMask.Local, transportFound);

            status = bus.CancelAdvertisedName(ObjectName, sessionOpts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = bus.CancelFindAdvertisedNameByTransport(ObjectName, AllJoyn.TransportMask.Local);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            foundAdvertisedName = false;
            status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Wait(TimeSpan.FromSeconds(1));
            Assert.Equal(false, foundAdvertisedName);

            busListener.Dispose();
            bus.Dispose();
        }
Beispiel #15
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             bus.Dispose();
         }
         disposed = true;
     }
 }
Beispiel #16
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             serviceBus.Dispose();
             clientBus.Dispose();
         }
         disposed = true;
     }
 }
Beispiel #17
0
        public void Concurrency()
        {
            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            // The default value for concurrency is 4
            Assert.Equal <uint>(4, bus.Concurrency);
            bus.Dispose();

            bus = new AllJoyn.BusAttachment("BusAttachmentTest", true, 8);
            Assert.Equal <uint>(8, bus.Concurrency);
            bus.Dispose();
        }
Beispiel #18
0
        public void srp_keyx()
        {
            ResetAuthFlags();
            clientBus.ClearKeyStore();

            SrpKeyx_service_authlistener serviceAuthlistener = new SrpKeyx_service_authlistener(this);

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

            serviceBus.ClearKeyStore();

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

            SrpKeyx_client_authlistener clientAuthlistener = new SrpKeyx_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.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();
        }
Beispiel #19
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();
        }
Beispiel #20
0
        public void CreateDispose()
        {
            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);
            proxyBusObject.Dispose();
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
            busAttachment.Dispose();
        }
        public void TestFoundLostAdvertisedName()
        {
            // create bus attachment
            AllJoyn.BusAttachment bus    = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.QStatus       status = AllJoyn.QStatus.FAIL;

            // start the bus attachment
            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // connect to the bus
            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            listenerRegistered  = false;
            foundAdvertisedName = false;
            lostAdvertisedName  = false;

            // register the bus listener
            AllJoyn.BusListener busListener = new TestBusListener(this);
            bus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerRegistered);

            // advertise the name, & see if we find it
            status = bus.FindAdvertisedName(ObjectName);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            AllJoyn.SessionOpts sessionOpts = new AllJoyn.SessionOpts(
                AllJoyn.SessionOpts.TrafficType.Messages, false,
                AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);

            status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Wait(MaxWaitTime);
            Assert.Equal(true, foundAdvertisedName);

            // stop advertising the name, & see if we lose it
            status = bus.CancelAdvertisedName(ObjectName, sessionOpts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Wait(MaxWaitTime);
            Assert.Equal(true, lostAdvertisedName);

            // TODO: move these into a teardown method?
            busListener.Dispose();
            bus.Dispose();
        }
Beispiel #22
0
        public void StartAndStop()
        {
            AllJoyn.QStatus       status = AllJoyn.QStatus.FAIL;
            AllJoyn.BusAttachment bus    = null;
            bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(bus);

            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = bus.Stop();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // TODO: move these into a teardown method?
            bus.Dispose();
        }
Beispiel #23
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();
        }
Beispiel #24
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();
        }
Beispiel #25
0
        public void IsSecure()
        {
            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, 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, AllJoyn.InterfaceDescription.SecurityPolicy.Inherit, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(false, testIntf.IsSecure);
            Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Inherit, testIntf.GetSecurityPolicy);
            bus.DeleteInterface(testIntf);

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

            Assert.Equal(false, testIntf.IsSecure);
            Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Off, testIntf.GetSecurityPolicy);

            bus.DeleteInterface(testIntf);

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

            Assert.Equal(true, testIntf.IsSecure);
            Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Required, testIntf.GetSecurityPolicy);

            bus.Dispose();
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                mbus.ReleaseName(ObjectName);

                mbus.UnregisterBusListener(busListener);
                mbus.Stop();
                mbus.Join();

                if (disposing)
                {
                    mbus.Dispose();
                }
                disposed = true;
            }
        }
Beispiel #27
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (proxyBusObject != null)
             {
                 proxyBusObject.Dispose();
             }
             Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
             Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
             busAttachment.Dispose();
         }
         disposed = true;
     }
 }
Beispiel #28
0
        public void Connect_no_params()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(busAttachment);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect());

            Assert.True(busAttachment.IsConnected);

            Assert.True(busAttachment.ConnectSpec.Equals(AllJoynTestCommon.GetConnectSpec()) || busAttachment.ConnectSpec.Equals("null:"));

            busAttachment.Stop();
            busAttachment.Join();

            busAttachment.Dispose();
        }
Beispiel #29
0
        public void GetName()
        {
            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);

            Assert.Equal(INTERFACE_NAME, testIntf.Name);

            bus.Dispose();
        }
Beispiel #30
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                // additional clean up before disposing
                serviceBus.Stop();
                serviceBus.Join();

                clientBus.Stop();
                clientBus.Join();

                if (disposing)
                {
                    serviceBus.Dispose();
                    clientBus.Dispose();
                }
                disposed = true;
            }
        }