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();
        }
        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();
        }
        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();
        }
Exemple #4
0
        public ProxyBusObjectTest()
        {
            busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
Exemple #5
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();
        }
Exemple #6
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();
        }
        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();
        }
Exemple #8
0
        public void ServiceName()
        {
            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("org.alljoyn.Bus", proxyBusObject.ServiceName);
        }
Exemple #9
0
        public SignalsTest()
        {
            // create+start+connect bus attachment
            bus = new AllJoyn.BusAttachment("SignalsTest", true);
            Assert.NotNull(bus);

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

            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
Exemple #10
0
        public ObjectSecurityTest()
        {
            serviceBus = new AllJoyn.BusAttachment("AuthListenerTestService", false);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

            clientBus = new AllJoyn.BusAttachment("AuthListenerTestClient", false);

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
        public ConcurrentCallbackTest()
        {
            mbus = new AllJoyn.BusAttachment("BusListenerTest", true);

            // 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);
        }
Exemple #12
0
        public void Connect_no_params()
        {
            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();
        }
Exemple #13
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();
        }
        private void SetupMemberTwo()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            memberTwoBus = null;
            memberTwoBus = new AllJoyn.BusAttachment("SessionTestMemberTwo", true);
            Assert.NotNull(memberTwoBus);

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

            status = memberTwoBus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
Exemple #15
0
        public MessageTest()
        {
            serviceBus = new AllJoyn.BusAttachment("MessageTest", false);
            Assert.NotNull(serviceBus);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

            //SetUp Client
            //start client BusAttachment
            clientBus = new AllJoyn.BusAttachment("MessageTestClient", true);
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
        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();
        }
        private void SetupHost()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

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

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

            status = hostBus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
Exemple #18
0
        public void ImplementsInterface()
        {
            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());

            Assert.True(proxyBusObject.ImplementsInterface("org.alljoyn.Bus"));
            Assert.True(proxyBusObject.ImplementsInterface("org.alljoyn.Daemon"));
            Assert.False(proxyBusObject.ImplementsInterface("org.alljoyn.Invalid"));
        }
Exemple #19
0
        public BusListenerTest()
        {
            notifyEvent = new AutoResetEvent(false);

            bus = new AllJoyn.BusAttachment("BusListenerTest", true);

            // 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);

            busListener = new TestBusListener(this);
        }
Exemple #20
0
        public void SessionId()
        {
            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(0u, proxyBusObject.SessionId);

            /*
             * TODO set up a session with a real session and make sure that proxyObj
             * has and will return the proper sessionid.
             */
        }
Exemple #21
0
        public void ParseXml()
        {
            string busObjectXML = "<node name=\"/org/alljoyn/test/ProxyObjectTest\">" +
                                  "  <interface name=\"org.alljoyn.test.ProxyBusObjectTest\">\n" +
                                  "    <signal name=\"chirp\">\n" +
                                  "      <arg name=\"chirp\" type=\"s\"/>\n" +
                                  "    </signal>\n" +
                                  "    <signal name=\"chirp2\">\n" +
                                  "      <arg name=\"chirp\" type=\"s\" direction=\"out\"/>\n" +
                                  "    </signal>\n" +
                                  "    <method name=\"ping\">\n" +
                                  "      <arg name=\"in\" type=\"s\" direction=\"in\"/>\n" +
                                  "      <arg name=\"out\" type=\"s\" direction=\"out\"/>\n" +
                                  "    </method>\n" +
                                  "  </interface>\n" +
                                  "</node>\n";

            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, null, null, 0);
            Assert.NotNull(proxyBusObject);

            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.ParseXml(busObjectXML));

            Assert.True(proxyBusObject.ImplementsInterface("org.alljoyn.test.ProxyBusObjectTest"));

            AllJoyn.InterfaceDescription iface = proxyBusObject.GetInterface("org.alljoyn.test.ProxyBusObjectTest");
            Assert.NotNull(iface);

            string expectedIntrospect = "<interface name=\"org.alljoyn.test.ProxyBusObjectTest\">\n" +
                                        "  <signal name=\"chirp\">\n" +
                                        "    <arg name=\"chirp\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </signal>\n" +
                                        "  <signal name=\"chirp2\">\n" +
                                        "    <arg name=\"chirp\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </signal>\n" +
                                        "  <method name=\"ping\">\n" +
                                        "    <arg name=\"in\" type=\"s\" direction=\"in\"/>\n" +
                                        "    <arg name=\"out\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </method>\n" +
                                        "</interface>\n";

            Assert.Equal(expectedIntrospect, iface.Introspect());
        }
Exemple #22
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();
        }
Exemple #23
0
        public AuthListenerTest()
        {
            serviceBus = new AllJoyn.BusAttachment("AuthListenerTestService", false);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

            AllJoyn.InterfaceDescription service_intf = null;
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out service_intf));
            Assert.Equal(AllJoyn.QStatus.OK, service_intf.AddMethod("ping", "s", "s", "in,out"));
            service_intf.Activate();

            clientBus = new AllJoyn.BusAttachment("AuthListenerTestClient", false);

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
Exemple #24
0
        public void Disconnect()
        {
            Assert.Equal(AllJoyn.QStatus.BUS_BUS_NOT_STARTED, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

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

            Assert.Equal(AllJoyn.QStatus.BUS_NOT_CONNECTED, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

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

            Assert.True(busAttachment.IsConnected);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

            Assert.False(busAttachment.IsConnected);

            busAttachment.Stop();
            busAttachment.Join();
        }
Exemple #25
0
        public void AddInterface()
        {
            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.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();

            AllJoyn.ProxyBusObject 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));
        }
Exemple #26
0
        public void EnableConcurrentCallbacks_Not_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 BusListenerWithBlockingCall(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);

            /*
             * Because of the way that callback functions are defered we can still make
             * what would be a blocking call in alljoyn_core and it is not a blocking
             * call in Unity.  This is a by product of the alljoyn_c deffered callback class
             * and its usage.  I am still investigating ways to work around issues caused
             * by the deffered callback class at some point in the future may start to work
             * as alljoyn_core.
             * Assert.Equal(AllJoyn.QStatus.BUS_BLOCKING_CALL_NOT_ALLOWED, callbackStatus);
             */
            Assert.Equal(AllJoyn.QStatus.OK, callbackStatus);
            mbus.UnregisterBusListener(busListener);
            mbus.Stop();
            mbus.Join();
            mbus.Dispose();
        }
Exemple #27
0
        public void RegisterUnregisterSessionlessSignals()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

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

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

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

            AllJoyn.InterfaceDescription testIntf;
            Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface("org.alljoyn.test.signalstest", out testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("testSignal", "s", "newName"));
            testIntf.Activate();

            TestBusObject testObj = new TestBusObject("/org/alljoyn/test/signal");

            Assert.Equal(AllJoyn.QStatus.OK, testObj.AddInterface(testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, bus.RegisterBusObject(testObj));

            AllJoyn.InterfaceDescription.Member mySignalMember = testIntf.GetMember("testSignal");

            Assert.Equal(AllJoyn.QStatus.OK, bus.AddMatch("type='signal',sessionless='t',interface='org.alljoyn.test.signalstest,member='testSignal'"));

            AllJoyn.Message msg = new AllJoyn.Message(bus);
            AllJoyn.MsgArg  arg = new AllJoyn.MsgArg();

            Assert.Equal(AllJoyn.QStatus.OK, arg.Set("s", "AllJoyn"));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg.CallSerial));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg));
        }
        public void TestStopDisconnected()
        {
            // 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;
            busDisconnected    = false;
            busStopping        = false;

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

            // test disconnecting from the bus
            status = bus.Disconnect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, busDisconnected);

            // test stopping the bus
            status = bus.Stop();
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, busStopping);

            busListener.Dispose();
            bus.Dispose();
        }
Exemple #29
0
        public BusObjectTest()
        {
            notifyEvent = new AutoResetEvent(false);

            // create+start+connect bus attachment
            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+start+connect bus attachment
            servicebus = new AllJoyn.BusAttachment("BusObjectTestService", true);
            Assert.NotNull(servicebus);

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

            status = servicebus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
Exemple #30
0
        public void Disconnect()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(busAttachment);

            Assert.Equal(AllJoyn.QStatus.BUS_BUS_NOT_STARTED, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

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

            Assert.Equal(AllJoyn.QStatus.BUS_NOT_CONNECTED, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

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

            Assert.True(busAttachment.IsConnected);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Disconnect(AllJoynTestCommon.GetConnectSpec()));

            Assert.False(busAttachment.IsConnected);

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

            busAttachment.Dispose();
        }