/// <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); }
/// <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(); }
public _MarshallingInfoTraverseAspectCommand_456(ClassAspect aspect, BooleanByRef found, ObjectHeaderContext context, IMarshallingInfo baseArg1) : base(baseArg1) { this.aspect = aspect; this.found = found; this.context = context; }
/// <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 virtual bool MoveNext() { BooleanByRef result = new BooleanByRef(); Run(new _IRunnable_26(this, result)); return(result.value); }
private bool Descend1(QQuery query, string fieldName, IntByRef run) { if (run.value == 2 || i_constraints.Size() == 0) { // On the second run we are really creating a second independant // query network that is not joined to other higher level // constraints. // Let's see how this works out. We may need to join networks. run.value = 0; // prevent a double run of this code Stream().ClassCollection().AttachQueryNode(fieldName, new _IVisitor4_275(this)); } CheckConstraintsEvaluationMode(); BooleanByRef foundClass = new BooleanByRef(false); IEnumerator i = IterateConstraints(); while (i.MoveNext()) { if (((QCon)i.Current).Attach(query, fieldName)) { foundClass.value = true; } } return(foundClass.value); }
protected virtual bool WriteSlots(IVisitable slotChangeTree) { var ret = new BooleanByRef(); slotChangeTree.Accept(new _IVisitor4_39(this, ret)); return(ret.value); }
/// <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(); }
internal CreateDescendChildTraversingVisitor(ByRef pending, BooleanByRef innerRes , bool isNot) { _pending = pending; _innerRes = innerRes; _isNot = isNot; }
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 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(); }
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 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); 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); }
private FailingTestSuite(bool failOnSetup, bool failOnTeardown, BooleanByRef tearDownCalled , IClosure4 tests) : base(tests) { _failOnSetUp = failOnSetup; _failOnTeardown = failOnTeardown; _tearDownCalled = tearDownCalled; }
public bool IsLeafTest() { BooleanByRef isLeaf = new BooleanByRef(); RunDecorated(new _IRunnable_58(this, isLeaf)); return(isLeaf.value); }
private bool AttachToExistingConstraints(Collection4 newConstraintsCollector, object obj, bool onlyForPaths) { bool found = false; IEnumerator j = IterateConstraints(); while (j.MoveNext()) { QCon existingConstraint = (QCon)j.Current; BooleanByRef removeExisting = new BooleanByRef(false); if (!onlyForPaths || (existingConstraint is QConPath)) { QCon newConstraint = existingConstraint.ShareParent(obj, removeExisting); if (newConstraint != null) { newConstraintsCollector.Add(newConstraint); AddConstraint(newConstraint); if (removeExisting.value) { RemoveConstraint(existingConstraint); } found = true; if (!onlyForPaths) { break; } } } } return(found); }
public virtual void AssertSingleEntry(LocalObjectContainer container, long id) { BooleanByRef called = new BooleanByRef(); Index(container).TraverseKeys(container.SystemTransaction(), new _IVisitor4_24(id , called)); Assert.IsTrue(called.value); }
public _IEventListener4_153(BooleanByRef shallListen, BooleanByRef gotEvent, BooleanByRef ownEvent, Lock4 lockObject) { this.shallListen = shallListen; this.gotEvent = gotEvent; this.ownEvent = ownEvent; this.lockObject = lockObject; }
public _MarshallingInfoTraverseAspectCommand_349(StandardReferenceTypeHandler _enclosing , BooleanByRef aspectFound, CollectIdContext subContext, IMarshallingInfo baseArg1 ) : base(baseArg1) { this._enclosing = _enclosing; this.aspectFound = aspectFound; this.subContext = subContext; }
private bool CreateChildForDescendable(QCandidates parentCandidates, ITypeHandler4 handler, QueryingReadContext queryingReadContext, ITypeHandler4 arrayElementHandler ) { int offset = queryingReadContext.Offset(); bool outerRes = true; // The following construct is worse than not ideal. For each constraint it completely reads the // underlying structure again. The structure could be kept fairly easy. TODO: Optimize! IEnumerator i = parentCandidates.IterateConstraints(); while (i.MoveNext()) { QCon qcon = (QCon)i.Current; QField qf = qcon.GetField(); if (qf != null && !qf.Name().Equals(_fieldMetadata.GetName())) { continue; } QCon tempParent = qcon.Parent(); qcon.SetParent(null); QCandidates candidates = new QCandidates(parentCandidates.i_trans, null, qf, false ); candidates.AddConstraint(qcon); qcon.SetCandidates(candidates); ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates ); queryingReadContext.Seek(offset); bool isNot = qcon.IsNot(); if (isNot) { qcon.RemoveNot(); } candidates.Evaluate(); ByRef pending = ByRef.NewInstance(); BooleanByRef innerRes = new BooleanByRef(isNot); candidates.Traverse(new QCandidate.CreateDescendChildTraversingVisitor(pending, innerRes , isNot)); if (isNot) { qcon.Not(); } // In case we had pending subresults, we need to communicate them up to our root. if (((Tree)pending.value) != null) { ((Tree)pending.value).Traverse(new _IVisitor4_168(this)); } if (!innerRes.value) { // Again this could be double triggering. // // We want to clean up the "No route" at some stage. qcon.Visit(GetRoot(), qcon.Evaluator().Not(false)); outerRes = false; } qcon.SetParent(tempParent); } return(outerRes); }
public virtual bool SeekToField(ObjectHeaderContext context, ClassAspect aspect) { BooleanByRef found = new BooleanByRef(false); ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_456(aspect , found, context, EnsureFieldList(context)); TraverseAllAspects(context, command); return(found.value); }
public _IClosure4_625(LocalObjectContainer _enclosing, Transaction trans, string name, BooleanByRef acquired, int timeout) { this._enclosing = _enclosing; this.trans = trans; this.name = name; this.acquired = acquired; this.timeout = timeout; }
public override string ToString() { BooleanByRef found = new BooleanByRef(); StringBuilder str = new StringBuilder("HashcodeReferenceSystem {"); TraverseReferences(new _IVisitor4_117(found, str)); str.Append("}"); return(str.ToString()); }
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; }
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); }
public virtual void TestServerClosedEvent() { var receivedEvent = new BooleanByRef(false); var events = (IObjectServerEvents)server; events.Closed += new _IEventListener4_101 (receivedEvent).OnEvent; server.Close(); Assert.IsTrue(receivedEvent.value); }
// 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)); }
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."); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private bool CollectIDsByTypehandlerAspect(QueryingReadContext context) { BooleanByRef aspectFound = new BooleanByRef(false); CollectIdContext subContext = CollectIdContext.ForID(context.Transaction(), context .Collector(), context.CollectionID()); ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_349(this , aspectFound, subContext, EnsureFieldList(subContext)); TraverseAllAspects(subContext, command); return(aspectFound.value); }
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); }