Beispiel #1
0
			public _IEventListener4_51(string clientName, BooleanByRef eventRaised, Lock4 Lock
				)
			{
				this.clientName = clientName;
				this.eventRaised = eventRaised;
				this.Lock = Lock;
			}
		/// <exception cref="System.Exception"></exception>
		public virtual void Test()
		{
			BooleanByRef disconnected = new BooleanByRef();
			Lock4 Lock = new Lock4();
			if (IsNetworking())
			{
				IDb4oClientServerFixture clientServerFixture = (IDb4oClientServerFixture)Fixture(
					);
				IObjectServerEvents objectServerEvents = (IObjectServerEvents)clientServerFixture
					.Server();
				objectServerEvents.ClientDisconnected += new System.EventHandler<Db4objects.Db4o.Events.StringEventArgs>
					(new _IEventListener4_46(Lock, disconnected).OnEvent);
			}
			DeleteOnDeletingCallbackTestCase.RootItem root = ((DeleteOnDeletingCallbackTestCase.RootItem
				)RetrieveOnlyInstance(typeof(DeleteOnDeletingCallbackTestCase.RootItem)));
			root.child = new DeleteOnDeletingCallbackTestCase.Item();
			Db().Store(root);
			Db().Delete(root);
			Reopen();
			if (IsNetworking())
			{
				Lock.Run(new _IClosure4_63(disconnected, Lock));
			}
			AssertClassIndexIsEmpty();
		}
Beispiel #3
0
 // closing is asynchronous, relying on completion is hard
 // That's why there is no test here. 
 // ClientProcessesTestCase tests closing.
 public virtual void TestClientDisconnectedEvent()
 {
     var client = (ClientObjectContainer) OpenClient();
     var clientName = client.UserName;
     var eventRaised = new BooleanByRef();
     var events = (IObjectServerEvents) server;
     var Lock = new Lock4();
     events.ClientDisconnected += new _IEventListener4_51(clientName, eventRaised, Lock).OnEvent;
     Lock.Run(new _IClosure4_58(client, eventRaised, Lock));
 }
Beispiel #4
0
		// closing is asynchronous, relying on completion is hard
		// That's why there is no test here. 
		// ClientProcessesTestCase tests closing.
		public virtual void TestClientDisconnectedEvent()
		{
			ClientObjectContainer client = (ClientObjectContainer)OpenClient();
			string clientName = client.UserName;
			BooleanByRef eventRaised = new BooleanByRef();
			IObjectServerEvents events = (IObjectServerEvents)server;
			Lock4 Lock = new Lock4();
			events.ClientDisconnected += new System.EventHandler<Db4objects.Db4o.Events.StringEventArgs>
				(new _IEventListener4_51(clientName, eventRaised, Lock).OnEvent);
			Lock.Run(new _IClosure4_58(client, eventRaised, Lock));
		}
		/// <exception cref="System.Exception"></exception>
		private void AssertQueryOnCallBack(Type classConstraint)
		{
			Lock4 Lock = new Lock4();
			Db().Store(new CallbackTrackingTestCase.Item(42));
			IEventRegistry eventRegistry = EventRegistry();
			eventRegistry.Committed += new System.EventHandler<Db4objects.Db4o.Events.CommitEventArgs>
				(new _IEventListener4_30(classConstraint, Lock).OnEvent);
			lock (Lock)
			{
				Db().Commit();
				Lock.Snooze(5000);
			}
		}
 /// <exception cref="System.Exception"></exception>
 public virtual void Test()
 {
     var server = (ObjectServerImpl) Db4oClientServer.OpenServer(TempFile(
         ), Db4oClientServer.ArbitraryPort);
     var Lock = new Lock4();
     server.ClientDisconnected += new _IEventListener4_39(Lock).OnEvent;
     server.GrantAccess(User, Password);
     var client = OpenClient(server.Port());
     var msgDispatcher = FirstMessageDispatcherFor(server);
     var transaction = msgDispatcher.Transaction();
     var idSystem = transaction.IdSystem();
     var prefetchedID = idSystem.PrefetchID();
     Assert.IsGreater(0, prefetchedID);
     Lock.Run(new _IClosure4_58(client, Lock, idSystem, prefetchedID));
     // This wont work with the PointerBasedIdSystem
     server.Close();
 }
		/// <exception cref="System.Exception"></exception>
		public virtual void Test()
		{
			ObjectServerImpl server = (ObjectServerImpl)Db4oClientServer.OpenServer(TempFile(
				), Db4oClientServer.ArbitraryPort);
			Lock4 Lock = new Lock4();
			server.ClientDisconnected += new System.EventHandler<Db4objects.Db4o.Events.StringEventArgs>
				(new _IEventListener4_39(Lock).OnEvent);
			server.GrantAccess(User, Password);
			IObjectContainer client = OpenClient(server.Port());
			ServerMessageDispatcherImpl msgDispatcher = FirstMessageDispatcherFor(server);
			Transaction transaction = msgDispatcher.Transaction();
			ITransactionalIdSystem idSystem = transaction.IdSystem();
			int prefetchedID = idSystem.PrefetchID();
			Assert.IsGreater(0, prefetchedID);
			Lock.Run(new _IClosure4_58(client, Lock, idSystem, prefetchedID));
			// This wont work with the PointerBasedIdSystem
			server.Close();
		}
 /// <exception cref="System.Exception"></exception>
 public virtual void Test()
 {
     var disconnected = new BooleanByRef();
     var Lock = new Lock4();
     if (IsNetworking())
     {
         var clientServerFixture = (IDb4oClientServerFixture) Fixture(
             );
         var objectServerEvents = (IObjectServerEvents) clientServerFixture
             .Server();
         objectServerEvents.ClientDisconnected += new _IEventListener4_46(Lock, disconnected).OnEvent;
     }
     var root = ((RootItem
         ) RetrieveOnlyInstance(typeof (RootItem)));
     root.child = new Item();
     Db().Store(root);
     Db().Delete(root);
     Reopen();
     if (IsNetworking())
     {
         Lock.Run(new _IClosure4_63(disconnected, Lock));
     }
     AssertClassIndexIsEmpty();
 }
			public _IEventListener4_39(Lock4 Lock)
			{
				this.Lock = Lock;
			}
				public _IClosure4_47(BooleanByRef disconnected, Lock4 Lock)
				{
					this.disconnected = disconnected;
					this.Lock = Lock;
				}
			public _IEventListener4_46(Lock4 Lock, BooleanByRef disconnected)
			{
				this.Lock = Lock;
				this.disconnected = disconnected;
			}
				public _IClosure4_170(BooleanByRef shallListen, OwnCommittedCallbacksFixture.CommitAction
					 action, IObjectContainer clientA, IObjectContainer clientB, Lock4 lockObject)
				{
					this.shallListen = shallListen;
					this.action = action;
					this.clientA = clientA;
					this.clientB = clientB;
					this.lockObject = lockObject;
				}
Beispiel #13
0
 public _IClosure4_96(IExtObjectContainer client, Lock4 clientDisconnectedLock)
 {
     this.client = client;
     this.clientDisconnectedLock = clientDisconnectedLock;
 }
				public _IEventListener4_153(BooleanByRef shallListen, BooleanByRef gotEvent, BooleanByRef
					 ownEvent, Lock4 lockObject)
				{
					this.shallListen = shallListen;
					this.gotEvent = gotEvent;
					this.ownEvent = ownEvent;
					this.lockObject = lockObject;
				}
Beispiel #15
0
 public SimpleTimer(IRunnable runnable, long interval)
 {
     _runnable = runnable;
     _interval = interval;
     _lock     = new Lock4();
 }
Beispiel #16
0
		private void CloseConnectionInNetworkingCS(IExtObjectContainer client)
		{
			BooleanByRef eventWasRaised = new BooleanByRef();
			Lock4 clientDisconnectedLock = new Lock4();
			IObjectServerEvents serverEvents = (IObjectServerEvents)ClientServerFixture().Server
				();
			serverEvents.ClientDisconnected += new System.EventHandler<Db4objects.Db4o.Events.StringEventArgs>
				(new _IEventListener4_85(clientDisconnectedLock, eventWasRaised).OnEvent);
			clientDisconnectedLock.Run(new _IClosure4_96(client, clientDisconnectedLock));
			Assert.IsTrue(eventWasRaised.value, "ClientDisconnected event was not raised.");
		}
Beispiel #17
0
		public SimpleTimer(IRunnable runnable, long interval)
		{
			_runnable = runnable;
			_interval = interval;
			_lock = new Lock4();
		}
			public _IEventListener4_30(Type classConstraint, Lock4 Lock)
			{
				this.classConstraint = classConstraint;
				this.Lock = Lock;
			}
				public _IClosure4_172(Lock4 lockObject)
				{
					this.lockObject = lockObject;
				}
				public _IClosure4_40(Lock4 Lock)
				{
					this.Lock = Lock;
				}
Beispiel #21
0
 public _IClosure4_87(BooleanByRef eventWasRaised, Lock4 clientDisconnectedLock)
 {
     this.eventWasRaised = eventWasRaised;
     this.clientDisconnectedLock = clientDisconnectedLock;
 }
			public _IClosure4_58(IObjectContainer client, Lock4 Lock, ITransactionalIdSystem 
				idSystem, int prefetchedID)
			{
				this.client = client;
				this.Lock = Lock;
				this.idSystem = idSystem;
				this.prefetchedID = prefetchedID;
			}
			/// <exception cref="System.Exception"></exception>
			public virtual void TestCommittedCallbacks()
			{
				Lock4 lockObject = new Lock4();
				BooleanByRef ownEvent = new BooleanByRef(false);
				BooleanByRef gotEvent = new BooleanByRef(false);
				BooleanByRef shallListen = new BooleanByRef(false);
				OwnCommittedCallbacksFixture.IContainerFactory factory = ((OwnCommittedCallbacksFixture.IContainerFactory
					)Factory.Value);
				OwnCommittedCallbacksFixture.CommitAction action = ((OwnCommittedCallbacksFixture.CommitAction
					)Action.Value);
				factory.Open();
				IObjectContainer clientA = factory.OpenClient();
				IObjectContainer clientB = factory.OpenClient();
				IEventRegistry registry = EventRegistryFactory.ForObjectContainer(clientA);
				registry.Committed += new System.EventHandler<Db4objects.Db4o.Events.CommitEventArgs>
					(new _IEventListener4_153(shallListen, gotEvent, ownEvent, lockObject).OnEvent);
				shallListen.value = true;
				action.CommitItem(new OwnCommitCallbackFlaggedNetworkingTestSuite.Item(42), clientA
					, clientB);
				lockObject.Run(new _IClosure4_172(lockObject));
				shallListen.value = false;
				clientB.Close();
				clientA.Close();
				factory.Close();
				Assert.IsTrue(gotEvent.value);
				Assert.AreEqual(action.SelectsFirstClient(), ownEvent.value);
			}
Beispiel #24
0
 private void CloseConnectionInNetworkingCS(IExtObjectContainer client)
 {
     var eventWasRaised = new BooleanByRef();
     var clientDisconnectedLock = new Lock4();
     var serverEvents = (IObjectServerEvents) ClientServerFixture().Server
         ();
     serverEvents.ClientDisconnected += new _IEventListener4_85(clientDisconnectedLock, eventWasRaised).OnEvent;
     clientDisconnectedLock.Run(new _IClosure4_96(client, clientDisconnectedLock));
     Assert.IsTrue(eventWasRaised.value, "ClientDisconnected event was not raised.");
 }
Beispiel #25
0
 public _IEventListener4_85(Lock4 clientDisconnectedLock, BooleanByRef eventWasRaised
     )
 {
     this.clientDisconnectedLock = clientDisconnectedLock;
     this.eventWasRaised = eventWasRaised;
 }
Beispiel #26
0
			public _IClosure4_58(ClientObjectContainer client, BooleanByRef eventRaised, Lock4
				 Lock)
			{
				this.client = client;
				this.eventRaised = eventRaised;
				this.Lock = Lock;
			}
 /// <exception cref="System.Exception"></exception>
 public virtual void TestCommittedCallbacks()
 {
     var lockObject = new Lock4();
     var ownEvent = new BooleanByRef(false);
     var gotEvent = new BooleanByRef(false);
     var shallListen = new BooleanByRef(false);
     var factory = ((IContainerFactory
         ) Factory.Value);
     var action = ((CommitAction
         ) Action.Value);
     factory.Open();
     var clientA = factory.OpenClient();
     var clientB = factory.OpenClient();
     var registry = EventRegistryFactory.ForObjectContainer(clientA);
     registry.Committed += new _IEventListener4_153(shallListen, gotEvent, ownEvent, lockObject).OnEvent;
     lockObject.Run(new _IClosure4_170(shallListen, action, clientA, clientB, lockObject
         ));
     shallListen.value = false;
     clientB.Close();
     clientA.Close();
     factory.Close();
     Assert.IsTrue(gotEvent.value);
     Assert.AreEqual(action.SelectsFirstClient(), ownEvent.value);
 }