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();
		}
		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 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();
		}
		public void InterfaceDescriptionEquals()
		{
			AllJoyn.BusAttachment servicebus = null;
			servicebus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
			Assert.NotNull(servicebus);

			// create the interface one
			AllJoyn.InterfaceDescription testIntf = null;
			Assert.Equal(AllJoyn.QStatus.OK, servicebus.CreateInterface(INTERFACE_NAME, out testIntf));
			Assert.NotNull(testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("chirp", "s", "chirp"));
			testIntf.Activate();

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

			AllJoyn.BusObject busObject = new AllJoyn.BusObject(OBJECT_PATH, false);
			Assert.Equal(AllJoyn.QStatus.OK, busObject.AddInterface(testIntf));

			Assert.Equal(AllJoyn.QStatus.OK, servicebus.RegisterBusObject(busObject));

			Assert.Equal(AllJoyn.QStatus.OK, servicebus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.AllowReplacement |
				AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.ReplaceExisting));

			AllJoyn.BusAttachment clientbus = null;
			clientbus = new AllJoyn.BusAttachment("InterfaceDescriptionTestclient", true);
			Assert.NotNull(clientbus);

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

			AllJoyn.ProxyBusObject proxy = new AllJoyn.ProxyBusObject(clientbus, WELLKNOWN_NAME, OBJECT_PATH, 0);
			Assert.Equal(AllJoyn.QStatus.OK, proxy.IntrospectRemoteObject());

			AllJoyn.InterfaceDescription testIntf2 = proxy.GetInterface(INTERFACE_NAME);
			Assert.NotNull(testIntf);

			// create the interface three
			AllJoyn.InterfaceDescription testIntf3 = null;
			Assert.Equal(AllJoyn.QStatus.OK, servicebus.CreateInterface(INTERFACE_NAME + ".three", out testIntf3));
			Assert.NotNull(testIntf3);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddMethod("ping", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddMethod("pong", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddSignal("chirp", "s", "chirp"));

			Assert.True(testIntf == testIntf2);
			Assert.True(testIntf.Equals(testIntf2));
			Assert.True(testIntf.GetHashCode() == testIntf2.GetHashCode());

			Assert.False(testIntf == testIntf3);
			Assert.False(testIntf.Equals(testIntf3));
			Assert.False(testIntf.GetHashCode() == testIntf3.GetHashCode());

			proxy.Dispose();
			busObject.Dispose();

			servicebus.Stop();
			servicebus.Join();

			clientbus.Stop();
			clientbus.Join();

			servicebus.Dispose();
			clientbus.Dispose();
		}
Esempio n. 5
0
		public void PingOtherOnSameBus()
		{
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect());

			AllJoyn.BusAttachment otherBusAttachment = null;
			otherBusAttachment = new AllJoyn.BusAttachment("OtherBusAttachmentTest", false);

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

			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Ping(otherBusAttachment.UniqueName, 1000));

			otherBusAttachment.Stop();
			otherBusAttachment.Join();

			busAttachment.Stop();
			busAttachment.Join();
		}
		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();
		}
		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();
		}
		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();
		}