private FailingTestSuite(bool failOnSetup, bool failOnTeardown, BooleanByRef tearDownCalled
				, IClosure4 tests) : base(tests)
			{
				_failOnSetUp = failOnSetup;
				_failOnTeardown = failOnTeardown;
				_tearDownCalled = tearDownCalled;
			}
		/// <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();
		}
Esempio n. 3
0
 public virtual void AssertSingleEntry(LocalObjectContainer container, long id)
 {
     var called = new BooleanByRef();
     Index(container).TraverseKeys(container.SystemTransaction(), new _IVisitor4_24(id
         , called));
     Assert.IsTrue(called.value);
 }
Esempio n. 4
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 TestExceptionInUpdateCallback()
		{
			BooleanByRef doThrow = new BooleanByRef();
			EventRegistryFactory.ForObjectContainer(Db()).Updated += new System.EventHandler<Db4objects.Db4o.Events.ObjectInfoEventArgs>
				(new _IEventListener4_42(doThrow).OnEvent);
			ExceptionsInCallbackTestCase.Holder holder = new ExceptionsInCallbackTestCase.Holder
				();
			ExceptionsInCallbackTestCase.Item item = new ExceptionsInCallbackTestCase.Item();
			Store(holder);
			Store(item);
			Commit();
			doThrow.value = true;
			holder.list = new ArrayList();
			holder.list.Add(item);
			try
			{
				Db().Store(holder, int.MaxValue);
			}
			catch (Exception)
			{
			}
			// rex.printStackTrace();
			Checkdb();
			Commit();
			Checkdb();
			Reopen();
			Checkdb();
		}
 /// <exception cref="System.Exception"></exception>
 public virtual void TestExceptionInUpdateCallback()
 {
     var doThrow = new BooleanByRef();
     EventRegistryFactory.ForObjectContainer(Db()).Updated += new _IEventListener4_42(doThrow).OnEvent;
     var holder = new Holder
         ();
     var item = new Item();
     Store(holder);
     Store(item);
     Commit();
     doThrow.value = true;
     holder.list = new ArrayList();
     holder.list.Add(item);
     try
     {
         Db().Store(holder, int.MaxValue);
     }
     catch (Exception)
     {
     }
     // rex.printStackTrace();
     Checkdb();
     Commit();
     Checkdb();
     Reopen();
     Checkdb();
 }
Esempio n. 7
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));
 }
		public virtual void TestSplits()
		{
			BooleanByRef splitNotified = new BooleanByRef();
			IBTreeStructureListener listener = new _IBTreeStructureListener_18(splitNotified);
			_btree.StructureListener(listener);
			for (int i = 0; i < BtreeNodeSize + 1; i++)
			{
				Add(i);
			}
			Assert.IsTrue(splitNotified.value);
		}
		public virtual void TestFailOnTearDown()
		{
			BooleanByRef tearDownCalled = new BooleanByRef();
			TestResult result = new TestResult();
			new TestRunner(Iterators.Iterable(new OpaqueTestSuiteFailureTestCase.FailingTestSuite
				[] { new OpaqueTestSuiteFailureTestCase.FailingTestSuite(false, true, tearDownCalled
				) })).Run(result);
			Assert.AreEqual(1, result.TestCount);
			Assert.AreEqual(2, result.Failures.Count);
			Assert.IsTrue(tearDownCalled.value);
		}
Esempio n. 10
0
		internal override QConClass ShareParentForClass(IReflectClass a_class, BooleanByRef
			 removeExisting)
		{
			if (i_parent == null)
			{
				return null;
			}
			QConClass newConstraint = new QConClass(i_trans, i_parent, GetField(), a_class);
			Morph(removeExisting, newConstraint, a_class);
			return newConstraint;
		}
 public virtual void TestTransactionInEventArgs()
 {
     var factory = EventRegistryFactory.ForObjectContainer(Db());
     var called = new BooleanByRef();
     var foundTrans = new ObjectByRef();
     factory.Creating += new _IEventListener4_20(called, foundTrans).OnEvent;
     Db().Store(new Item());
     Db().Commit();
     Assert.IsTrue(called.value);
     Assert.AreSame(Trans(), foundTrans.value);
 }
Esempio n. 12
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));
		}
		public virtual void TestTransactionInEventArgs()
		{
			IEventRegistry factory = EventRegistryFactory.ForObjectContainer(Db());
			BooleanByRef called = new BooleanByRef();
			ObjectByRef foundTrans = new ObjectByRef();
			factory.Creating += new System.EventHandler<Db4objects.Db4o.Events.CancellableObjectEventArgs>
				(new _IEventListener4_20(called, foundTrans).OnEvent);
			Db().Store(new EventArgsTransactionTestCase.Item());
			Db().Commit();
			Assert.IsTrue(called.value);
			Assert.AreSame(Trans(), foundTrans.value);
		}
 public virtual void TestFailOnSetup()
 {
     var tearDownCalled = new BooleanByRef();
     var result = new TestResult();
     new TestRunner(Iterators.Iterable(new[]
     {
         new FailingTestSuite(true, false, tearDownCalled
             )
     })).Run(result);
     Assert.AreEqual(0, result.TestCount);
     Assert.AreEqual(1, result.Failures.Count);
     Assert.IsFalse(tearDownCalled.value);
 }
		//COR-1839
		#if !SILVERLIGHT
		/// <exception cref="System.Exception"></exception>
		public virtual void Test()
		{
			if (!Platform4.HasWeakReferences())
			{
				return;
			}
			WeakReferenceCollectionTestCase.Item item = new WeakReferenceCollectionTestCase.Item
				();
			Store(item);
			Commit();
			ByRef reference = new ByRef();
			ReferenceSystem().TraverseReferences(new _IVisitor4_30(reference));
			Assert.IsNotNull(((ObjectReference)reference.value));
			item = null;
			long timeout = 10000;
			long startTime = Runtime.CurrentTimeMillis();
			while (true)
			{
				long currentTime = Runtime.CurrentTimeMillis();
				if (currentTime - startTime >= timeout)
				{
					Assert.Fail("Timeout waiting for WeakReference collection.");
				}
				Runtime.Gc();
				Runtime.RunFinalization();
				Thread.Sleep(1);
				if (((ObjectReference)reference.value).GetObject() == null)
				{
					break;
				}
			}
			startTime = Runtime.CurrentTimeMillis();
			while (true)
			{
				long currentTime = Runtime.CurrentTimeMillis();
				if (currentTime - startTime >= timeout)
				{
					Assert.Fail("Timeout waiting for removal of ObjectReference from ReferenceSystem."
						);
				}
				BooleanByRef found = new BooleanByRef();
				ReferenceSystem().TraverseReferences(new _IVisitor4_63(reference, found));
				if (!found.value)
				{
					return;
				}
				Thread.Sleep(10);
			}
		}
Esempio n. 16
0
		internal override QCon ShareParent(object a_object, BooleanByRef removeExisting)
		{
			if (i_parent == null)
			{
				return null;
			}
			object obj = GetField().Coerce(a_object);
			if (obj == No4.Instance)
			{
				QCon falseConstraint = new QConUnconditional(i_trans, false);
				Morph(removeExisting, falseConstraint, ReflectClassForObject(obj));
				return falseConstraint;
			}
			QConObject newConstraint = new QConObject(i_trans, i_parent, GetField(), obj);
			Morph(removeExisting, newConstraint, ReflectClassForObject(obj));
			return newConstraint;
		}
		public void ActivateAspects(UnmarshallingContext context)
		{
			BooleanByRef schemaUpdateDetected = new BooleanByRef();
			ContextState savedState = context.SaveState();
			ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_63(context
				, schemaUpdateDetected, EnsureFieldList(context));
			// TODO: cant the aspect handle it itself?
			// Probably no because old aspect versions might not be able
			// to handle null...
			TraverseAllAspects(context, command);
			if (schemaUpdateDetected.value)
			{
				context.RestoreState(savedState);
				command = new _MarshallingInfoTraverseAspectCommand_94(context, EnsureFieldList(context
					));
				TraverseAllAspects(context, command);
			}
		}
 /// <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 _MarshallingInfoTraverseAspectCommand_456(ClassAspect aspect, BooleanByRef
     found, ObjectHeaderContext context, IMarshallingInfo baseArg1) : base(baseArg1)
 {
     this.aspect = aspect;
     this.found = found;
     this.context = context;
 }
Esempio n. 20
0
			public _IVisitor4_39(TransactionLogHandler _enclosing, BooleanByRef ret)
			{
				this._enclosing = _enclosing;
				this.ret = ret;
			}
Esempio n. 21
0
		protected virtual bool WriteSlots(IVisitable slotChangeTree)
		{
			BooleanByRef ret = new BooleanByRef();
			slotChangeTree.Accept(new _IVisitor4_39(this, ret));
			return ret.value;
		}
			public _IVisitor4_63(ByRef reference, BooleanByRef found)
			{
				this.reference = reference;
				this.found = found;
			}
Esempio n. 23
0
		/// <param name="claxx"></param>
		/// <param name="removeExisting"></param>
		internal virtual QConClass ShareParentForClass(IReflectClass claxx, BooleanByRef 
			removeExisting)
		{
			// virtual
			return null;
		}
Esempio n. 24
0
		/// <param name="obj"></param>
		/// <param name="removeExisting"></param>
		internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon ShareParent(object
			 obj, BooleanByRef removeExisting)
		{
			// virtual
			return null;
		}
Esempio n. 25
0
			public _IClosure4_58(ClientObjectContainer client, BooleanByRef eventRaised, Lock4
				 Lock)
			{
				this.client = client;
				this.eventRaised = eventRaised;
				this.Lock = Lock;
			}
 public _MarshallingInfoTraverseAspectCommand_349(StandardReferenceTypeHandler _enclosing
     , BooleanByRef aspectFound, CollectIdContext subContext, IMarshallingInfo baseArg1
     ) : base(baseArg1)
 {
     this._enclosing = _enclosing;
     this.aspectFound = aspectFound;
     this.subContext = subContext;
 }
Esempio n. 27
0
		// Our QConPath objects are just placeholders to fields,
		// so the parents are reachable.
		// If we find a "real" constraint, we throw the QPath
		// out and replace it with the other constraint. 
		private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass
			 claxx)
		{
			bool mayMorph = true;
			if (claxx != null)
			{
				ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx);
				if (yc != null)
				{
					IEnumerator i = IterateChildren();
					while (i.MoveNext())
					{
						QField qf = ((QCon)i.Current).GetField();
						if (!yc.HasField(i_trans.Container(), qf.Name()))
						{
							mayMorph = false;
							break;
						}
					}
				}
			}
			// }
			if (mayMorph)
			{
				IEnumerator j = IterateChildren();
				while (j.MoveNext())
				{
					newConstraint.AddConstraint((QCon)j.Current);
				}
				if (HasJoins())
				{
					IEnumerator k = IterateJoins();
					while (k.MoveNext())
					{
						QConJoin qcj = (QConJoin)k.Current;
						qcj.ExchangeConstraint(this, newConstraint);
						newConstraint.AddJoin(qcj);
					}
				}
				i_parent.ExchangeConstraint(this, newConstraint);
				removeExisting.value = true;
			}
			else
			{
				i_parent.AddConstraint(newConstraint);
			}
		}
Esempio n. 28
0
		public virtual void TestServerClosedEvent()
		{
			BooleanByRef receivedEvent = new BooleanByRef(false);
			IObjectServerEvents events = (IObjectServerEvents)server;
			events.Closed += new System.EventHandler<ServerClosedEventArgs>(new _IEventListener4_101
				(receivedEvent).OnEvent);
			server.Close();
			Assert.IsTrue(receivedEvent.value);
		}
Esempio n. 29
0
 public _IVisitor4_24(long id, BooleanByRef called)
 {
     this.id = id;
     this.called = called;
 }
Esempio n. 30
0
			public _IEventListener4_101(BooleanByRef receivedEvent)
			{
				this.receivedEvent = receivedEvent;
			}