Exemplo n.º 1
0
 public virtual void TestDeleteReaddFromOtherClient()
 {
     if (!PrepareTest())
     {
         return;
     }
     DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent parent1
         = ((DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
             )RetrieveOnlyInstance(client1, typeof(DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
                                                   )));
     DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent parent2
         = ((DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
             )RetrieveOnlyInstance(client2, typeof(DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
                                                   )));
     client1.Delete(parent1.child);
     AssertQueries(0, 1);
     client1.Commit();
     AssertQueries(0, 0);
     client2.Store(parent2.child);
     AssertQueries(0, 1);
     client2.Commit();
     AssertQueries(1, 1);
     client2.Close();
     AssertRestoredState();
 }
        private void WithDatabase(string file, IFunction4 function)
        {
            Configure();
            IExtObjectContainer objectContainer = Db4oFactory.OpenFile(file).Ext();

            try
            {
                function.Apply(objectContainer);
            }
            finally
            {
                objectContainer.Close();
            }
            IObjectServer server = Db4oFactory.OpenServer(ClientServerFileName(file), -1);

            server.GrantAccess(Username, Password);
            objectContainer = Db4oFactory.OpenClient("localhost", server.Ext().Port(), Username
                                                     , Password).Ext();
            try
            {
                function.Apply(objectContainer);
            }
            finally
            {
                objectContainer.Close();
                server.Close();
            }
        }
Exemplo n.º 3
0
        public virtual void TestSetSemaphore()
        {
            string semaphoreName = "sem";

            Assert.IsTrue(_client1.SetSemaphore(semaphoreName, 0));
            Assert.IsFalse(_client2.SetSemaphore(semaphoreName, 0));
            _client1.ReleaseSemaphore(semaphoreName);
            Assert.IsTrue(_client2.SetSemaphore(semaphoreName, 0));
            _client2.Close();
            Assert.IsTrue(_client1.SetSemaphore(semaphoreName, 0));
        }
Exemplo n.º 4
0
 public virtual void TestCommitOnClose()
 {
     EmbeddedClientObjectContainerTestCase.Item storedItem = StoreItemToClient1AndCommit
                                                                 ();
     storedItem._name = ChangedName;
     _client1.Store(storedItem);
     _client1.Close();
     EmbeddedClientObjectContainerTestCase.Item retrievedItem = RetrieveItemFromClient2
                                                                    ();
     Assert.AreEqual(ChangedName, retrievedItem._name);
 }
Exemplo n.º 5
0
        public virtual void Test()
        {
            int[]      ids            = new int[2];
            IObjectSet originalResult = NewQuery(typeof(DeepPrefetchingCacheConcurrencyTestCase.Item
                                                        )).Execute();

            DeepPrefetchingCacheConcurrencyTestCase.Item firstOriginalItem = ((DeepPrefetchingCacheConcurrencyTestCase.Item
                                                                               )originalResult.Next());
            Db().Purge(firstOriginalItem);
            IExtObjectContainer otherClient  = OpenNewSession();
            IObjectSet          updateResult = otherClient.Query(typeof(DeepPrefetchingCacheConcurrencyTestCase.Item
                                                                        ));
            int idx = 0;

            for (IEnumerator updateItemIter = updateResult.GetEnumerator(); updateItemIter.MoveNext
                     ();)
            {
                DeepPrefetchingCacheConcurrencyTestCase.Item updateItem = ((DeepPrefetchingCacheConcurrencyTestCase.Item
                                                                            )updateItemIter.Current);
                ids[idx]         = (int)otherClient.GetID(updateItem);
                updateItem._name = "updated";
                otherClient.Store(updateItem);
                idx++;
            }
            otherClient.Commit();
            otherClient.Close();
            for (int i = 0; i < ids.Length; i++)
            {
                DeepPrefetchingCacheConcurrencyTestCase.Item checkItem = ((DeepPrefetchingCacheConcurrencyTestCase.Item
                                                                           )Db().GetByID(ids[i]));
                Db().Activate(checkItem);
                Assert.AreEqual("updated", checkItem._name);
            }
        }
Exemplo n.º 6
0
        public virtual void TestSeparateSessions()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();

            try
            {
                IObjectSet os1 = oc1.Query(typeof(DualDeleteTestCase.Item));
                IObjectSet os2 = oc2.Query(typeof(DualDeleteTestCase.Item));
                DeleteObjectSet(oc1, os1);
                AssertOccurrences(oc1, typeof(Atom), 0);
                AssertOccurrences(oc2, typeof(Atom), 1);
                DeleteObjectSet(oc2, os2);
                AssertOccurrences(oc1, typeof(Atom), 0);
                AssertOccurrences(oc2, typeof(Atom), 0);
                oc1.Rollback();
                AssertOccurrences(oc1, typeof(Atom), 1);
                AssertOccurrences(oc2, typeof(Atom), 0);
                oc1.Commit();
                AssertOccurrences(oc1, typeof(Atom), 1);
                AssertOccurrences(oc2, typeof(Atom), 0);
                DeleteAll(oc2, typeof(DualDeleteTestCase.Item));
                oc2.Commit();
                AssertOccurrences(oc1, typeof(Atom), 0);
                AssertOccurrences(oc2, typeof(Atom), 0);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
            }
        }
        public virtual void TestSD()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject
                                                                                                )));
                oc1.Delete(o1);
                SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("hello", o2.GetS());
                o2.SetS("o2");
                oc2.Store(o2);
                oc2.Commit();
                oc1.Commit();
                AssertOccurrences(oc1, typeof(SimpleObject), 0);
                AssertOccurrences(oc2, typeof(SimpleObject), 0);
                AssertOccurrences(oc3, typeof(SimpleObject), 0);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
Exemplo n.º 8
0
        public virtual void Test()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();

            try
            {
                RefreshTestCase.Item r1 = GetRoot(oc1);
                r1.name = "cc";
                oc1.Refresh(r1, 0);
                Assert.AreEqual("cc", r1.name);
                oc1.Refresh(r1, 1);
                Assert.AreEqual("o1", r1.name);
                r1.child.name = "cc";
                oc1.Refresh(r1, 1);
                Assert.AreEqual("cc", r1.child.name);
                oc1.Refresh(r1, 2);
                Assert.AreEqual("o2", r1.child.name);
                RefreshTestCase.Item r2 = GetRoot(oc2);
                r2.name             = "o21";
                r2.child.name       = "o22";
                r2.child.child.name = "o23";
                oc2.Store(r2);
                oc2.Commit();
                oc1.Refresh(r1, 3);
                Assert.AreEqual("o21", r1.name);
                Assert.AreEqual("o22", r1.child.name);
                Assert.AreEqual("o23", r1.child.child.name);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
            }
        }
Exemplo n.º 9
0
            internal virtual void RunMethod()
            {
                IExtObjectContainer oc = null;

                try
                {
                    oc = this._enclosing.Fixture().OpenNewSession(this.toTest);
                    object[] args;
                    if (this.showSeq)
                    {
                        args    = new object[2];
                        args[0] = oc;
                        args[1] = this.seq;
                    }
                    else
                    {
                        args    = new object[1];
                        args[0] = oc;
                    }
                    this.method.Invoke(this.toTest, args);
                }
                catch (Exception e)
                {
                    this._enclosing.failures[this.seq] = e;
                }
                finally
                {
                    if (oc != null)
                    {
                        oc.Close();
                    }
                }
            }
        /// <exception cref="System.Exception"></exception>
        public virtual void TestConcurrentClientModification()
        {
            if (!IsMultiSession())
            {
                return;
            }
            IExtObjectContainer client1 = Db();
            IExtObjectContainer client2 = OpenNewSession();

            try
            {
                Item foo1 = ItemByName(client1, "Foo");
                Item foo2 = ItemByName(client2, "Foo");
                foo1.SetName("Foo*");
                foo2.SetName("Foo**");
                AssertUpdatedObjects(client1, foo1);
                AssertUpdatedObjects(client2, foo2);
                client1.Refresh(foo1, 1);
                Assert.AreEqual(foo2.GetName(), foo1.GetName());
            }
            finally
            {
                client2.Close();
            }
        }
Exemplo n.º 11
0
        public virtual void TestSetRollback()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();

            try
            {
                for (int i = 0; i < 1000; i++)
                {
                    SimpleObject obj1 = new SimpleObject("oc " + i, i);
                    SimpleObject obj2 = new SimpleObject("oc2 " + i, i);
                    oc1.Store(obj1);
                    oc2.Store(obj2);
                    oc2.Rollback();
                    obj2 = new SimpleObject("oc2.2 " + i, i);
                    oc2.Store(obj2);
                }
                oc1.Commit();
                oc2.Rollback();
                Assert.AreEqual(1000, oc1.Query(typeof(SimpleObject)).Count);
                Assert.AreEqual(1000, oc2.Query(typeof(SimpleObject)).Count);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
            }
        }
Exemplo n.º 12
0
 protected override void PreClose()
 {
     if (null != _session)
     {
         _session.Close();
     }
 }
Exemplo n.º 13
0
        private MockActivatable RetrieveMockFromNewClientAndClose()
        {
            IExtObjectContainer client = OpenNewSession();

            try
            {
                return(RetrieveMock(client));
            }
            finally
            {
                client.Close();
            }
        }
Exemplo n.º 14
0
 /// <exception cref="System.Exception"></exception>
 public override void Close()
 {
     if (null != _objectContainer)
     {
         IThreadPool4 clientThreadPool = ClientThreadPool();
         _objectContainer.Close();
         _objectContainer = null;
         if (null != clientThreadPool)
         {
             clientThreadPool.Join(ThreadpoolTimeout);
         }
     }
     CloseServer();
 }
Exemplo n.º 15
0
        private void DeleteAllItemsFromSecondClient()
        {
            IExtObjectContainer client = OpenNewSession();

            try
            {
                DeleteAll(client, typeof(PrefetchConfigurationTestCase.Item));
                client.Commit();
            }
            finally
            {
                client.Close();
            }
        }
Exemplo n.º 16
0
        public virtual void TestSingleChild()
        {
            IExtObjectContainer client1 = OpenNewSession();
            IQuery query = client1.Query();

            query.Constrain(typeof(TAUnavailableClassAtServer.ParentWithSingleChild));
            IObjectSet result = query.Execute();

            Assert.IsTrue(result.HasNext());
            TAUnavailableClassAtServer.ParentWithSingleChild parent = (TAUnavailableClassAtServer.ParentWithSingleChild
                                                                       )result.Next();
            Assert.AreEqual(43, parent.Child().Value());
            client1.Close();
        }
Exemplo n.º 17
0
        public virtual void TestChildArray()
        {
            IExtObjectContainer client1 = OpenNewSession();
            IQuery query = client1.Query();

            query.Constrain(typeof(TAUnavailableClassAtServer.ParentWithMultipleChilds));
            IObjectSet result = query.Execute();

            Assert.IsTrue(result.HasNext());
            TAUnavailableClassAtServer.ParentWithMultipleChilds parent = (TAUnavailableClassAtServer.ParentWithMultipleChilds
                                                                          )result.Next();
            Assert.IsNotNull(parent.Children());
            client1.Close();
        }
        public virtual void TestOwnedSemaphoreCannotBeTaken()
        {
            IExtObjectContainer client1 = OpenNewSession();

            try
            {
                Assert.IsTrue(Db().SetSemaphore(SemaphoreName, 0));
                Assert.IsFalse(client1.SetSemaphore(SemaphoreName, 0));
            }
            finally
            {
                client1.Close();
            }
        }
Exemplo n.º 19
0
        /// <exception cref="System.Exception"></exception>
        public virtual void _testDeleteDeleted()
        {
            int total          = 10;
            int CddMemberCount = 12;

            IExtObjectContainer[] containers = new IExtObjectContainer[total];
            IExtObjectContainer   oc         = null;

            try
            {
                for (int i = 0; i < total; i++)
                {
                    containers[i] = OpenNewSession();
                    AssertOccurrences(containers[i], typeof(CascadeDeleteDeletedTestCase.CddMember),
                                      CddMemberCount);
                }
                for (int i = 0; i < total; i++)
                {
                    DeleteAll(containers[i], typeof(CascadeDeleteDeletedTestCase.CddMember));
                }
                oc = OpenNewSession();
                AssertOccurrences(oc, typeof(CascadeDeleteDeletedTestCase.CddMember), CddMemberCount
                                  );
                // ocs[0] deleted all CddMember objects, and committed the change
                containers[0].Commit();
                containers[0].Close();
                // FIXME: following assertion fails
                AssertOccurrences(oc, typeof(CascadeDeleteDeletedTestCase.CddMember), 0);
                for (int i = 1; i < total; i++)
                {
                    containers[i].Close();
                }
                AssertOccurrences(oc, typeof(CascadeDeleteDeletedTestCase.CddMember), 0);
            }
            finally
            {
                if (oc != null)
                {
                    oc.Close();
                }
                for (int i = 0; i < total; i++)
                {
                    if (containers[i] != null)
                    {
                        containers[i].Close();
                    }
                }
            }
        }
        public virtual void Test()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                IQuery query1 = oc1.Query();
                query1.Descend("name").Constrain("root");
                IObjectSet os1 = query1.Execute();
                Assert.AreEqual(1, os1.Count);
                Atom o1 = (Atom)os1.Next();
                o1.child.child.name = "o1";
                oc1.Store(o1);
                IQuery query2 = oc2.Query();
                query2.Descend("name").Constrain("root");
                IObjectSet os2 = query2.Execute();
                Assert.AreEqual(1, os2.Count);
                Atom o2 = (Atom)os2.Next();
                Assert.AreEqual("child.child", o2.child.child.name);
                oc1.Rollback();
                oc2.Purge(o2);
                os2 = query2.Execute();
                Assert.AreEqual(1, os2.Count);
                o2 = (Atom)os2.Next();
                Assert.AreEqual("child.child", o2.child.child.name);
                oc1.Store(o1);
                oc1.Commit();
                os2 = query2.Execute();
                Assert.AreEqual(1, os2.Count);
                o2 = (Atom)os2.Next();
                oc2.Refresh(o2, int.MaxValue);
                Assert.AreEqual("o1", o2.child.child.name);
                IQuery query3 = oc3.Query();
                query3.Descend("name").Constrain("root");
                IObjectSet os3 = query1.Execute();
                Assert.AreEqual(1, os3.Count);
                Atom o3 = (Atom)os3.Next();
                Assert.AreEqual("o1", o3.child.child.name);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
        public virtual void TestClosingClientReleasesSemaphores()
        {
            IExtObjectContainer client1 = OpenNewSession();

            Assert.IsTrue(client1.SetSemaphore(SemaphoreName, 0));
            Assert.IsFalse(Db().SetSemaphore(SemaphoreName, 0));
            if (IsNetworking())
            {
                CloseConnectionInNetworkingCS(client1);
            }
            else
            {
                client1.Close();
            }
            Assert.IsTrue(Db().SetSemaphore(SemaphoreName, 0));
        }
Exemplo n.º 22
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            DeepSetClientServerTestCase.Item example = new DeepSetClientServerTestCase.Item();
            example.name = "1";
            try
            {
                DeepSetClientServerTestCase.Item item1 = (DeepSetClientServerTestCase.Item)oc1.QueryByExample
                                                             (example).Next();
                Assert.AreEqual("1", item1.name);
                Assert.AreEqual("2", item1.child.name);
                Assert.AreEqual("3", item1.child.child.name);
                DeepSetClientServerTestCase.Item item2 = (DeepSetClientServerTestCase.Item)oc2.QueryByExample
                                                             (example).Next();
                Assert.AreEqual("1", item2.name);
                Assert.AreEqual("2", item2.child.name);
                Assert.AreEqual("3", item2.child.child.name);
                item1.child.name       = "12";
                item1.child.child.name = "13";
                oc1.Store(item1, 2);
                oc1.Commit();
                // check result
                DeepSetClientServerTestCase.Item item = (DeepSetClientServerTestCase.Item)oc1.QueryByExample
                                                            (example).Next();
                Assert.AreEqual("1", item.name);
                Assert.AreEqual("12", item.child.name);
                Assert.AreEqual("13", item.child.child.name);
                item = (DeepSetClientServerTestCase.Item)oc2.QueryByExample(example).Next();
                oc2.Refresh(item, 3);
                Assert.AreEqual("1", item.name);
                Assert.AreEqual("12", item.child.name);
                Assert.AreEqual("3", item.child.child.name);
                item = (DeepSetClientServerTestCase.Item)oc3.QueryByExample(example).Next();
                Assert.AreEqual("1", item.name);
                Assert.AreEqual("12", item.child.name);
                Assert.AreEqual("3", item.child.child.name);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
        public virtual void TestPreviouslyOwnedSemaphoreCannotBeTaken()
        {
            IExtObjectContainer client1 = OpenNewSession();

            try
            {
                Assert.IsTrue(Db().SetSemaphore(SemaphoreName, 0));
                Assert.IsFalse(client1.SetSemaphore(SemaphoreName, 0));
                Db().ReleaseSemaphore(SemaphoreName);
                EnsureMessageProcessed(Db());
                Assert.IsTrue(client1.SetSemaphore(SemaphoreName, 0));
                Assert.IsFalse(Db().SetSemaphore(SemaphoreName, 0));
            }
            finally
            {
                client1.Close();
            }
        }
        public virtual void TestRepeatedStore()
        {
            IExtObjectContainer client1 = Db();
            IExtObjectContainer client2 = OpenNewSession();

            CsCascadedDeleteReaddChildReferenceTestCase.ItemParent parent1 = ((CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                               )RetrieveOnlyInstance(client1, typeof(CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                                                                     )));
            CsCascadedDeleteReaddChildReferenceTestCase.ItemParent parent2 = ((CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                               )RetrieveOnlyInstance(client2, typeof(CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                                                                     )));
            client1.Ext().Store(parent1, int.MaxValue);
            client1.Commit();
            client2.Ext().Store(parent2, int.MaxValue);
            client2.Commit();
            client2.Close();
            AssertInstanceCountAndFieldIndexes(client1);
        }
Exemplo n.º 25
0
        public virtual void TestRefresh()
        {
            IExtObjectContainer client1 = OpenNewSession();
            IExtObjectContainer client2 = OpenNewSession();

            NonTARefreshTestCase.TAItem item1 = (NonTARefreshTestCase.TAItem)RetrieveInstance
                                                    (client1);
            NonTARefreshTestCase.TAItem item2 = (NonTARefreshTestCase.TAItem)RetrieveInstance
                                                    (client2);
            AssertDescendingRange(10, item1);
            AssertDescendingRange(10, item2);
            item1.Value(100);
            item1.Next().Value(200);
            client1.Store(item1, 2);
            client1.Commit();
            Assert.AreEqual(100, item1.Value());
            Assert.AreEqual(200, item1.Next().Value());
            Assert.AreEqual(10, item2.Value());
            Assert.AreEqual(9, item2.Next().Value());
            //refresh 0
            client2.Refresh(item2, 0);
            Assert.AreEqual(10, item2.Value());
            Assert.AreEqual(9, item2.Next().Value());
            //refresh 1
            client2.Refresh(item2, 1);
            Assert.AreEqual(100, item2.Value());
            Assert.AreEqual(9, item2.Next().Value());
            //refresh 2
            client2.Refresh(item2, 2);
            Assert.AreEqual(100, item2.Value());
            Assert.AreEqual(200, item2.Next().Value());
            UpdateAscendingWithRange(item1, 1000);
            client1.Store(item1, 5);
            client1.Commit();
            client2.Refresh(item2, 5);
            NonTARefreshTestCase.TAItem next2 = item2;
            for (int i = 1000; i < 1005; i++)
            {
                Assert.AreEqual(i, next2.Value());
                next2 = next2.Next();
            }
            client1.Close();
            client2.Close();
        }
Exemplo n.º 26
0
        public virtual void Test()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject
                                                                                                )));
                o1.SetS("o1");
                oc1.Store(o1);
                SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("hello", o2.GetS());
                oc1.Rollback();
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                oc2.Refresh(o2, int.MaxValue);
                Assert.AreEqual("hello", o2.GetS());
                oc1.Commit();
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                Assert.AreEqual("hello", o2.GetS());
                oc1.Store(o1);
                oc1.Commit();
                oc2.Refresh(o2, int.MaxValue);
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                Assert.AreEqual("o1", o2.GetS());
                SimpleObject o3 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc3, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("o1", o3.GetS());
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
Exemplo n.º 27
0
        /// <exception cref="System.Exception"></exception>
        private void CheckConcurrencyMethod(AbstractDb4oTestCase toTest, string testMethodName
                                            )
        {
            MethodInfo checkMethod = CheckMethodFor(toTest.GetType(), testMethodName);

            if (null == checkMethod)
            {
                return;
            }
            // pass ExtObjectContainer as a param to check method
            IExtObjectContainer oc = Fixture().Db();

            try
            {
                checkMethod.Invoke(toTest, new object[] { oc });
            }
            finally
            {
                oc.Close();
            }
        }
 /// <exception cref="System.Exception"></exception>
 public override void Close()
 {
     try
     {
         PreClose();
     }
     finally
     {
         if (null != _db)
         {
             Assert.IsTrue(_db.Close());
             try
             {
                 ThreadPool().Join(3000);
             }
             finally
             {
                 _db = null;
             }
         }
     }
 }
Exemplo n.º 29
0
        public virtual void TestRefreshIsUnaffectedByPrefetchingBehavior()
        {
            IExtObjectContainer oc1 = Db();
            IExtObjectContainer oc2 = OpenNewSession();

            oc1.Configure().ClientServer().PrefetchDepth(1);
            oc2.Configure().ClientServer().PrefetchDepth(1);
            try
            {
                PrefetchConfigurationTestCase.Item itemFromClient1 = new PrefetchConfigurationTestCase.RootItem
                                                                         (new PrefetchConfigurationTestCase.Item());
                oc1.Store(itemFromClient1);
                oc1.Commit();
                itemFromClient1.child = null;
                oc1.Store(itemFromClient1);
                PrefetchConfigurationTestCase.Item itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem
                                                                       )RetrieveOnlyInstance(oc2, typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Rollback();
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                oc2.Refresh(itemFromClient2, int.MaxValue);
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Commit();
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Store(itemFromClient1);
                oc1.Commit();
                oc2.Refresh(itemFromClient2, int.MaxValue);
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNull(itemFromClient2.child);
            }
            finally
            {
                oc2.Close();
            }
        }
Exemplo n.º 30
0
		/// <exception cref="System.Exception"></exception>
		public virtual void _concDelete(IExtObjectContainer oc, int seq)
		{
			ClientObjectContainer client = (ClientObjectContainer)oc;
			try
			{
				if (seq % 2 == 0)
				{
					// ok to get something
					client.QueryByExample(null);
				}
				else
				{
					client.Socket().Close();
					Assert.IsFalse(oc.IsClosed());
					Assert.Expect(typeof(Db4oException), new _ICodeBlock_27(client));
				}
			}
			finally
			{
				oc.Close();
				Assert.IsTrue(oc.IsClosed());
			}
		}
Exemplo n.º 31
0
        public virtual void TestDisconnect()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();

            try
            {
                ClientObjectContainer client1 = (ClientObjectContainer)oc1;
                ClientObjectContainer client2 = (ClientObjectContainer)oc2;
                client1.Socket().Close();
                Assert.IsFalse(oc1.IsClosed());
                Assert.Expect(typeof(Db4oException), new _ICodeBlock_27(client1));
                // It's ok for client2 to get something.
                client2.QueryByExample(null);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                Assert.IsTrue(oc1.IsClosed());
                Assert.IsTrue(oc2.IsClosed());
            }
        }