Ejemplo n.º 1
0
        /// <summary>Test : delete the unique object</summary>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test10()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            long size = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count;

            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1bis = (NeoDatis.Odb.Test.VO.Login.Function)
                                                        odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst();
            odb.Delete(f1bis);
            odb.Close();
            odb = Open(baseName);
            AssertEquals(size, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("last function"));
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                           ));
            odb.Close();
            AssertEquals(size + 1, l.Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Test : delete the last object and insert a new one in another transaction
        /// - detected by Alessandra
        /// </summary>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test9()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function2");
            NeoDatis.Odb.Test.VO.Login.Function f3 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function3");
            odb.Store(f1);
            odb.Store(f2);
            odb.Store(f3);
            NeoDatis.Odb.OID id = odb.GetObjectId(f3);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f3bis = (NeoDatis.Odb.Test.VO.Login.Function)
                                                        odb.GetObjectFromId(id);
            odb.Delete(f3bis);
            odb.Close();
            odb = Open(baseName);
            odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("last function"));
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                           ));
            odb.Close();
            AssertEquals(3, l.Count);
        }
Ejemplo n.º 3
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			DeleteBase("t1u.neodatis");
			NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			odb.Store(login);
			Println("--------");
			odb.Store(login);
			odb.Store(logout);
			// odb.commit();
			odb.Close();
			odb = Open("t1u.neodatis");
			NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst
				();
			f2.SetName("login function");
			odb.Store(f2);
			odb.Close();
			NeoDatis.Odb.ODB odb2 = Open("t1u.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb2
				.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst();
			AssertEquals("login function", f.GetName());
			odb2.Close();
			DeleteBase("t1u.neodatis");
		}
Ejemplo n.º 4
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestObjectVersionWithoutClose2()
        {
            DeleteBase("ext2");
            NeoDatis.Odb.ODB odb = Open("ext2");
            int  size            = 1000;
            long updateDate      = 0;
            long creationDate    = 0;

            // LogUtil.allOn(true);
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f"));
            odb.Close();
            odb = Open("ext2");
            Java.Lang.Thread.Sleep(100);
            // LogUtil.allOn(true);
            for (int i = 0; i < size; i++)
            {
                // odb = open("ext");
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oid);
                f.SetName("f" + i);
                odb.Store(f);
                odb.Commit();
            }
            odb.Close();
        }
Ejemplo n.º 5
0
        public virtual void Test1()
        {
            string baseName = GetBaseName();

            Println(baseName);
            string currentEncoding = NeoDatis.Odb.OdbConfiguration.GetDatabaseCharacterEncoding
                                         ();

            NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding("ISO8859-5");
            NeoDatis.Odb.ODB odb = null;
            try
            {
                odb = Open(baseName);
                string nameWithCyrillicCharacters     = "\u0410 \u0430 \u0431 \u0448 \u0429";
                NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function(nameWithCyrillicCharacters
                                                                                                );
                NeoDatis.Odb.OID oid = odb.Store(f);
                odb.Close();
                Println(f);
                odb = Open(baseName);
                NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
                                                         .GetObjectFromId(oid);
                odb.Close();
                AssertEquals(nameWithCyrillicCharacters, f2.GetName());
                AssertEquals('\u0410', f2.GetName()[0]);
                AssertEquals('\u0430', f2.GetName()[2]);
                AssertEquals('\u0431', f2.GetName()[4]);
                AssertEquals('\u0448', f2.GetName()[6]);
                AssertEquals('\u0429', f2.GetName()[8]);
            }
            finally
            {
                NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding(currentEncoding);
            }
        }
Ejemplo n.º 6
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test6()
 {
     DeleteBase("t1u.neodatis");
     NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                     ("login");
     NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
                                                      ("logout");
     odb.Store(login);
     odb.Store(logout);
     odb.Close();
     odb = Open("t1u.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function login2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                      ("login2");
     NeoDatis.Odb.Test.VO.Login.Function logout2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                       ("logout2");
     odb.Store(login2);
     odb.Store(logout2);
     // select without committing
     NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                    ), true);
     AssertEquals(4, l.Count);
     // println(l);
     odb.Close();
     odb = Open("t1u.neodatis");
     l   = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true);
     AssertEquals(4, l.Count);
     // println(l);
     odb.Close();
 }
Ejemplo n.º 7
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test3()
		{
			// LogUtil.objectReaderOn(true);
			DeleteBase("map-with-collections");
			NeoDatis.Odb.ODB odb = null;
			odb = Open("map-with-collections");
			NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject o = new NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject
				("test");
			System.Collections.ICollection c = new System.Collections.ArrayList();
			c.Add(o);
			NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function1");
			o.GetMap().Add("a", c);
			int size = 1;
			for (int i = 0; i < size; i++)
			{
				o.GetMap().Add("A" + i, f1);
			}
			o.GetMap().Add("c", f1);
			Println("RealMap" + o.GetMap());
			odb.Store(o);
			odb.Close();
			odb = Open("map-with-collections");
			NeoDatis.Odb.Objects os = odb.GetObjects(typeof(NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject
				));
			NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject mmo = (NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject
				)os.GetFirst();
			odb.Close();
			DeleteBase("map-with-collections");
			AssertEquals(o.GetName(), mmo.GetName());
			AssertEquals(size + 2, mmo.GetMap().Count);
			AssertEquals(mmo, ((System.Collections.ICollection)mmo.GetMap()["a"]).GetEnumerator
				().Current);
			AssertEquals("function1", mmo.GetMap()["c"].ToString());
		}
Ejemplo n.º 8
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test6()
 {
     // LogUtil.objectWriterOn(true);
     DeleteBase("t6.neodatis");
     NeoDatis.Odb.ODB odb = Open("t6.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                     ("login");
     NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
                                                      ("logout");
     System.Collections.IList list = new System.Collections.ArrayList();
     list.Add(login);
     list.Add(logout);
     NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
                                                      ("operator", list);
     NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
                                                                                   , "*****@*****.**", profile);
     odb.Store(olivier);
     odb.Close();
     Println("----------");
     odb = Open("t6.neodatis");
     NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                        ), true);
     NeoDatis.Odb.Test.VO.Login.User u1 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
                                              ();
     u1.GetProfile().SetName("operator 234567891011121314");
     odb.Store(u1);
     odb.Close();
     odb = Open("t6.neodatis");
     NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                           ), true);
     AssertEquals(1, profiles.Count);
     NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)profiles
                                             .GetFirst();
     AssertEquals(u1.GetProfile().GetName(), p1.GetName());
 }
Ejemplo n.º 9
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Login.Function)));
			NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
				("function1");
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("function2");
			NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function
				("function3");
			odb.Store(function1);
			odb.Store(function2);
			odb.Store(function3);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", "function2")));
			NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
				)l.GetFirst();
			odb.Delete(function);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			AssertEquals(n + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function))));
			odb.Close();
			DeleteBase(baseName);
		}
Ejemplo n.º 10
0
		/// <exception cref="Java.IO.UnsupportedEncodingException"></exception>
		public virtual void Test1()
		{
			string baseName = GetBaseName();
			Println(baseName);
			string currentEncoding = NeoDatis.Odb.OdbConfiguration.GetDatabaseCharacterEncoding
				();
			NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding("ISO8859-5");
			NeoDatis.Odb.ODB odb = null;
			try
			{
				odb = Open(baseName);
				string nameWithCyrillicCharacters = "\u0410 \u0430 \u0431 \u0448 \u0429";
				NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function(nameWithCyrillicCharacters
					);
				NeoDatis.Odb.OID oid = odb.Store(f);
				odb.Close();
				Println(f);
				odb = Open(baseName);
				NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
					.GetObjectFromId(oid);
				odb.Close();
				AssertEquals(nameWithCyrillicCharacters, f2.GetName());
				AssertEquals('\u0410', f2.GetName()[0]);
				AssertEquals('\u0430', f2.GetName()[2]);
				AssertEquals('\u0431', f2.GetName()[4]);
				AssertEquals('\u0448', f2.GetName()[6]);
				AssertEquals('\u0429', f2.GetName()[8]);
			}
			finally
			{
				NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding(currentEncoding);
			}
		}
Ejemplo n.º 11
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("t1.neodatis");
     // LogUtil.allOn(true);
     NeoDatis.Odb.ODB odb = Open("t1.neodatis");
     // LogUtil.objectWriterOn(true);
     NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                     ("login");
     System.Collections.IList list = new System.Collections.ArrayList();
     list.Add(login);
     NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
                                                       ("operator 1", list);
     NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
                                                                                , "*****@*****.**", profile1);
     odb.Store(user);
     odb.Close();
     odb = Open("t1.neodatis");
     NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                        ), true);
     // assertEquals(nbUsers+2,users.size());
     NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
                                                 ();
     odb.Close();
     AssertEquals(user.ToString(), user2.ToString());
     DeleteBase("t1.neodatis");
 }
Ejemplo n.º 12
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test4Sort()
        {
            int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree();

            try
            {
                NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40);
                NeoDatis.Odb.ODB odb = Open("criteria.neodatis");
                NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                             (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                             .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Or().Add(NeoDatis.Odb.Core.Query.Criteria.Where
                                                                                                                                  .Equal("name", "function 2")).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name"
                                                                                                                                                                                                                 , "function 3"))));
                aq.OrderByDesc("name");
                // aq.orderByAsc("name");
                NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1);
                AssertEquals(48, l.Count);
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst
                                                            ();
                AssertEquals("function 9", f.GetName());
                odb.Close();
            }
            finally
            {
                NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d);
            }
        }
Ejemplo n.º 13
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestObjectVersionWithoutClose()
        {
            DeleteBase("extd");
            NeoDatis.Odb.ODB odb = Open("extd");
            int  size            = 1000;
            long updateDate      = 0;
            long creationDate    = 0;

            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f"));
            odb.Close();
            odb = Open("extd");
            Java.Lang.Thread.Sleep(100);
            for (int i = 0; i < size; i++)
            {
                // odb = open("ext");
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oid);
                int version = odb.Ext().GetObjectVersion(oid);
                // System.out.println("i="+i + " - v="+ version+ " - oid="+oid);
                AssertEquals(i + 1, version);
                f.SetName("f" + i);
                // update the object, should increase the version number
                odb.Store(f);
                odb.Commit();
            }
            odb.Close();
        }
Ejemplo n.º 14
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            NeoDatis.Odb.ODB          odb    = Open("big-data.neodatis");
            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
            for (int i = 0; i < 30000; i++)
            {
                buffer.Append('a');
            }
            NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
                                                               (buffer.ToString());
            odb.Store(function);
            odb.Close();
            odb = Open("big-data.neodatis");
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
                                                     .GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst();
            AssertEquals(30000, f2.GetName().Length);
            odb.Close();
            odb = Open("big-data.neodatis");
            f2  = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                             )).GetFirst();
            f2.SetName(f2.GetName() + "ola chico");
            int newSize = f2.GetName().Length;

            odb.Store(f2);
            odb.Close();
            odb = Open("big-data.neodatis");
            f2  = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                             )).GetFirst();
            AssertEquals(newSize, f2.GetName().Length);
            AssertEquals(buffer.ToString() + "ola chico", f2.GetName());
            odb.Close();
        }
Ejemplo n.º 15
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     if (!isLocal)
     {
         return;
     }
     DeleteBase("unconnected");
     NeoDatis.Odb.ODB odb = Open("unconnected");
     NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
     odb.Close();
     Println("Oid=" + oid);
     odb = Open("unconnected");
     NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
                                              .GetObjectFromId(oid);
     f2.SetName("New Function");
     odb.Store(f2);
     NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
     // retrieve the class info to check connected and unconnected zone
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = storageEngine.GetSession(true
                                                                                  ).GetMetaModel().GetClassInfo(typeof(NeoDatis.Odb.Test.VO.Login.Function).FullName
                                                                                                                , true);
     odb.Close();
     AssertEquals(1, ci.GetCommitedZoneInfo().GetNbObjects());
     AssertNotNull(ci.GetCommitedZoneInfo().first);
     AssertNotNull(ci.GetCommitedZoneInfo().last);
     AssertEquals(0, ci.GetUncommittedZoneInfo().GetNbObjects());
     AssertNull(ci.GetUncommittedZoneInfo().first);
     AssertNull(ci.GetUncommittedZoneInfo().last);
     odb = Open("unconnected");
     AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                  );
     odb.Close();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Bug when deleting the first object of unconnected zone when commited zone
        /// already have at least one object.
        /// </summary>
        /// <remarks>
        /// Bug when deleting the first object of unconnected zone when commited zone
        /// already have at least one object.
        /// Detected running the polePosiiton Bahrain circuit.
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test21()
        {
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function0");
            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function2");
            odb.Store(f2);
            odb.Delete(f1);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function)));
            AssertEquals(2, objects.Count);
            odb.Close();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Stores on object and close database then Stores another object, commits
        /// without closing.
        /// </summary>
        /// <remarks>
        /// Stores on object and close database then Stores another object, commits
        /// without closing. Loads the object, gets its oid and delete by oid. In the
        /// case the commit has no write actions. And there was a bug : when there is
        /// no write actions, the commit process is much more simple! but in this the
        /// cache was not calling the transaction.clear and this was a reason for
        /// some connected/unconnected zone problem! (step14 of the turotial.)
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test20()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
                "1function0");
            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            odb.Commit();
            NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                              .Like("name", "func%")));
            AssertEquals(1, objects.Count);
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
                                                     .GetFirst();
            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
            AssertEquals(1, objects.Count);
        }
Ejemplo n.º 18
0
        /// <summary>Stores an object, closes the base.</summary>
        /// <remarks>
        /// Stores an object, closes the base. Loads the object, gets its oid and
        /// delete by oid.
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test19()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                 ));
            AssertEquals(1, objects.Count);
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
                                                     .GetFirst();
            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(0, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
            AssertEquals(0, objects.Count);
        }
Ejemplo n.º 19
0
        // deleteBase("t5.neodatis");
        /// <exception cref="System.Exception"></exception>
        public virtual void TestSimple()
        {
            DeleteBase("t2.neodatis");
            NeoDatis.Odb.ODB odb = Open("t2.neodatis");
            int nbFunctions      = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true
                                                  ).Count;

            NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                            ("login");
            NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
                                                             ("logout");
            odb.Store(login);
            odb.Store(logout);
            odb.Close();
            odb = Open("t2.neodatis");
            NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                   ), true);
            NeoDatis.Odb.Test.VO.Login.Function f1 = (NeoDatis.Odb.Test.VO.Login.Function)functions
                                                     .GetFirst();
            f1.SetName("login1");
            odb.Store(f1);
            odb.Close();
            odb       = Open("t2.neodatis");
            functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true);
            odb.Close();
            AssertEquals(2, functions.Count);
            AssertEquals("login1", ((NeoDatis.Odb.Test.VO.Login.Function)functions.GetFirst()
                                    ).GetName());
            DeleteBase("t2.neodatis");
        }
Ejemplo n.º 20
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("t1u.neodatis");
     NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                     ("login");
     NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
                                                      ("logout");
     odb.Store(login);
     Println("--------");
     odb.Store(login);
     odb.Store(logout);
     // odb.commit();
     odb.Close();
     odb = Open("t1u.neodatis");
     NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                    ), true);
     NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst
                                                  ();
     f2.SetName("login function");
     odb.Store(f2);
     odb.Close();
     NeoDatis.Odb.ODB odb2 = Open("t1u.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb2
                                             .GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst();
     AssertEquals("login function", f.GetName());
     odb2.Close();
     DeleteBase("t1u.neodatis");
 }
Ejemplo n.º 21
0
		/// <summary>Getting object by id after re opening database</summary>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test1()
		{
			DeleteBase("getid.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
				("f1");
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("f2");
			NeoDatis.Odb.ODB odb = Open("getid.neodatis");
			odb.Store(function1);
			odb.Store(function2);
			NeoDatis.Odb.OID id1 = odb.GetObjectId(function1);
			NeoDatis.Odb.OID id2 = odb.GetObjectId(function2);
			odb.Close();
			odb = Open("getid.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function function1bis = (NeoDatis.Odb.Test.VO.Login.Function
				)odb.GetObjectFromId(id1);
			AssertEquals(function1.GetName(), function1bis.GetName());
			NeoDatis.Odb.Test.VO.Login.Function function2bis = (NeoDatis.Odb.Test.VO.Login.Function
				)odb.GetObjectFromId(id2);
			function2bis.SetName("function 2");
			odb.Store(function2bis);
			NeoDatis.Odb.OID id2bis = odb.GetObjectId(function2bis);
			odb.Close();
			odb = Open("getid.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function function2ter = (NeoDatis.Odb.Test.VO.Login.Function
				)odb.GetObjectFromId(id2);
			AssertEquals("function 2", function2ter.GetName());
			odb.Close();
			DeleteBase("getid.neodatis");
		}
Ejemplo n.º 22
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5_deleteNullObject()
        {
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function1"
                                                                                            );
            odb.Store(f);
            NeoDatis.Odb.OID oid = odb.GetObjectId(f);
            try
            {
                odb.Delete(null);
                Fail("Should have thrown an exception: trying to delete a null object");
            }
            catch (NeoDatis.Odb.ODBRuntimeException)
            {
                odb.Close();
                DeleteBase(baseName);
            }
            catch (System.Exception)
            {
                Fail("Should have thrown an OdbRuntimeException: trying to delete a null object");
            }
        }
Ejemplo n.º 23
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            long             n   = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
                                                                                                         NeoDatis.Odb.Test.VO.Login.Function)));

            NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function1");
            NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function2");
            NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function3");
            odb.Store(function1);
            odb.Store(function2);
            odb.Store(function3);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                        (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                        .Equal("name", "function2")));
            NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
                                                            )l.GetFirst();
            odb.Delete(function);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                            ), true);
            AssertEquals(n + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 24
0
 /// <summary>test in place update with rollback.</summary>
 /// <remarks>
 /// test in place update with rollback. Bug detected by Olivier 22/02/2008.
 /// In place updates for connected object were done out of transaction,
 /// avoiding rollback (ObejctWriter.manageInPlaceUpdate()
 /// </remarks>
 public virtual void Test10()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         odb = Open("inplcae-transaction");
         NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function1"
                                                                                  ));
         odb.Close();
         odb = Open("inplcae-transaction");
         NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                 GetObjectFromId(oid);
         f.SetName("function2");
         odb.Store(f);
         odb.Rollback();
         odb.Close();
         odb = Open("inplcae-transaction");
         f   = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjectFromId(oid);
         odb.Close();
         AssertEquals("function1", f.GetName());
     }
     catch (System.Exception)
     {
     }
 }
Ejemplo n.º 25
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestObjectVersion()
        {
            DeleteBase("extc");
            NeoDatis.Odb.ODB odb = Open("extc");
            int  size            = 1000;
            long updateDate      = 0;
            long creationDate    = 0;

            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f"));
            odb.Close();
            Java.Lang.Thread.Sleep(100);
            // LogUtil.allOn(true);
            for (int i = 0; i < size; i++)
            {
                odb = Open("extc");
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oid);
                int version = odb.Ext().GetObjectVersion(oid);
                // System.out.println("i="+i + " - v="+ version+ " - oid="+oid);
                updateDate   = odb.Ext().GetObjectUpdateDate(oid);
                creationDate = odb.Ext().GetObjectCreationDate(oid);
                f.SetName(f.GetName() + "-" + i);
                // update the object, should increase the version number
                odb.Store(f);
                odb.Close();
                AssertEquals(i + 1, version);
                // System.out.println(creationDate + " - "+ updateDate+ "- "+
                // OdbTime.getCurrentTimeInMs());
                // in first iteration, creation & update date may be equal
                if (i > 0)
                {
                    AssertTrue(creationDate < updateDate);
                }
            }
        }
Ejemplo n.º 26
0
 public virtual void Test1()
 {
     if (!isLocal)
     {
         return;
     }
     DeleteBase(FileName);
     NeoDatis.Odb.Core.Layers.Layer3.IBaseIdentification parameter = new NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter
                                                                         (NeoDatis.Odb.Test.ODBTest.Directory + FileName, true, null, null);
     NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.OdbConfiguration
                                                             .GetCoreProvider().GetClientStorageEngine(parameter);
     NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
                                                         ("login");
     engine.Store(function1);
     NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                         ("login2");
     engine.Store(function2);
     engine.Commit();
     engine.Close();
     engine = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClientStorageEngine(parameter
                                                                                     );
     System.Collections.Generic.IList <long> l = engine.GetAllObjectIds();
     AssertEquals(2, l.Count);
     engine.Close();
     DeleteBase(FileName);
 }
Ejemplo n.º 27
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = Open("big-data.neodatis");
			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
			for (int i = 0; i < 30000; i++)
			{
				buffer.Append('a');
			}
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				(buffer.ToString());
			odb.Store(function);
			odb.Close();
			odb = Open("big-data.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
				.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst();
			AssertEquals(30000, f2.GetName().Length);
			odb.Close();
			odb = Open("big-data.neodatis");
			f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				)).GetFirst();
			f2.SetName(f2.GetName() + "ola chico");
			int newSize = f2.GetName().Length;
			odb.Store(f2);
			odb.Close();
			odb = Open("big-data.neodatis");
			f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				)).GetFirst();
			AssertEquals(newSize, f2.GetName().Length);
			AssertEquals(buffer.ToString() + "ola chico", f2.GetName());
			odb.Close();
		}
Ejemplo n.º 28
0
 /// <summary>Getting object by id after re opening database</summary>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual void Test1()
 {
     DeleteBase("getid.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
                                                         ("f1");
     NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                         ("f2");
     NeoDatis.Odb.ODB odb = Open("getid.neodatis");
     odb.Store(function1);
     odb.Store(function2);
     NeoDatis.Odb.OID id1 = odb.GetObjectId(function1);
     NeoDatis.Odb.OID id2 = odb.GetObjectId(function2);
     odb.Close();
     odb = Open("getid.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function function1bis = (NeoDatis.Odb.Test.VO.Login.Function
                                                         )odb.GetObjectFromId(id1);
     AssertEquals(function1.GetName(), function1bis.GetName());
     NeoDatis.Odb.Test.VO.Login.Function function2bis = (NeoDatis.Odb.Test.VO.Login.Function
                                                         )odb.GetObjectFromId(id2);
     function2bis.SetName("function 2");
     odb.Store(function2bis);
     NeoDatis.Odb.OID id2bis = odb.GetObjectId(function2bis);
     odb.Close();
     odb = Open("getid.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function function2ter = (NeoDatis.Odb.Test.VO.Login.Function
                                                         )odb.GetObjectFromId(id2);
     AssertEquals("function 2", function2ter.GetName());
     odb.Close();
     DeleteBase("getid.neodatis");
 }
Ejemplo n.º 29
0
        /// <summary>creates 3 objects.</summary>
        /// <remarks>creates 3 objects. Delete the 2th. And create 3 new objects</remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test17()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            DeleteBase(baseName);
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function2");
            NeoDatis.Odb.Test.VO.Login.Function f3 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function2");
            odb.Store(f1);
            odb.Store(f2);
            odb.Store(f3);
            AssertEquals(3, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.Delete(f2);
            AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            // odb.store(f1);
            odb.Store(f2);
            // odb.store(f3);
            AssertEquals(3, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(3, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 30
0
        public virtual void Test1()
		{
			if (!isLocal)
			{
				return;
			}
			DeleteBase(FileName);
			NeoDatis.Odb.Core.Layers.Layer3.IBaseIdentification parameter = new NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter
				(NeoDatis.Odb.Test.ODBTest.Directory + FileName, true, null, null);
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.OdbConfiguration
				.GetCoreProvider().GetClientStorageEngine(parameter);
			NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			engine.Store(function1);
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("login2");
			engine.Store(function2);
			engine.Commit();
			engine.Close();
			engine = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClientStorageEngine(parameter
				);
			System.Collections.Generic.IList<long> l = engine.GetAllObjectIds();
			AssertEquals(2, l.Count);
			engine.Close();
			DeleteBase(FileName);
		}
Ejemplo n.º 31
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestConcurrentObjectVersion()
        {
            // LogUtil.allOn(true);
            int port = Port + 8;

            NeoDatis.Tool.IOUtil.DeleteFile(Directory + "exta1");
            NeoDatis.Odb.ODBServer server = NeoDatis.Odb.ODBFactory.OpenServer(port);
            server.StartServer(true);
            NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                      + "exta1");
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
            int version          = odb.Ext().GetObjectVersion(oid);

            Println(version);
            odb.Close();
            NeoDatis.Odb.ODB odb1 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                       + "exta1");
            NeoDatis.Odb.ODB odb2 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                       + "exta1");
            int v1 = odb1.Ext().GetObjectVersion(oid);
            int v2 = odb2.Ext().GetObjectVersion(oid);

            AssertEquals(1, v1);
            AssertEquals(1, v2);
            Println("v1=" + v1 + "- v2=" + v2);
            NeoDatis.Odb.Test.VO.Login.Function f1 = (NeoDatis.Odb.Test.VO.Login.Function)odb1
                                                     .GetObjectFromId(oid);
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb2
                                                     .GetObjectFromId(oid);
            f1.SetName("function 1");
            odb1.Store(f1);
            v1 = odb1.Ext().GetObjectVersion(oid);
            Println("after update odb1 , v1=" + v1);
            odb1.Close();
            NeoDatis.Odb.ODB odb3 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                       + "exta1");
            // Check committed object value
            NeoDatis.Odb.Test.VO.Login.Function f3 = (NeoDatis.Odb.Test.VO.Login.Function)odb3
                                                     .GetObjectFromId(oid);
            AssertEquals(f1.GetName(), f3.GetName());
            AssertEquals(2, odb3.Ext().GetObjectVersion(oid));
            odb3.Close();
            AssertEquals(2, v1);
            f2.SetName("function 2");
            odb2.Store(f2);
            v2 = odb2.Ext().GetObjectVersion(oid);
            Println("after update odb2 , v2=" + v2);
            odb2.Close();
            AssertEquals(3, v2);
            NeoDatis.Odb.ODB odb4 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                       + "exta1");
            // Check committed object value
            NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
                                                     .GetObjectFromId(oid);
            AssertEquals(f2.GetName(), f4.GetName());
            AssertEquals(3, odb4.Ext().GetObjectVersion(oid));
            odb4.Close();
            server.Close();
        }
Ejemplo n.º 32
0
 public Profile(string name, NeoDatis.Odb.Test.VO.Login.Function function) : base(
         )
 {
     this.functions = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Function
                                                           >();
     this.functions.Add(function);
     this.name = name;
 }
Ejemplo n.º 33
0
 public virtual void AddFunction(NeoDatis.Odb.Test.VO.Login.Function function)
 {
     if (functions == null)
     {
         functions = new System.Collections.Generic.List <Function>();
     }
     functions.Add(function);
 }
Ejemplo n.º 34
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestConcurrentObjectVersion2()
        {
            // LogUtil.allOn(true);
            int port = Port + 8;

            NeoDatis.Tool.IOUtil.DeleteFile(Directory + "exta1");
            NeoDatis.Odb.ODBServer server = NeoDatis.Odb.ODBFactory.OpenServer(port);
            server.StartServer(true);
            NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                      + "exta1");
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
            int version          = odb.Ext().GetObjectVersion(oid);

            Println(version);
            odb.Close();
            int nbThreads = 100;

            NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
            int[] versions          = new int[nbThreads];
            NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
                                                              [nbThreads];
            // Open all Odbs and get the object
            for (int i = 0; i < nbThreads; i++)
            {
                odbs[i] = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1"
                                                             );
                versions[i]  = odbs[i].Ext().GetObjectVersion(oid);
                functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
                AssertEquals(1, versions[i]);
                AssertEquals("f1", functions[i].GetName());
            }
            // Open all Odbs and get the object
            for (int i = 0; i < nbThreads; i++)
            {
                functions[i].SetName("function " + i);
                odbs[i].Store(functions[i]);
                versions[i] = odbs[i].Ext().GetObjectVersion(oid);
                Println("Function with name " + functions[i].GetName() + " has version " + versions
                        [i]);
                odbs[i].Close();
                AssertEquals(i + 2, versions[i]);
                // Just to check the version number after commit
                odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1");
                int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
                Println("After commit = " + committedVersionNumber);
                AssertEquals(i + 2, committedVersionNumber);
                odb.Close();
            }
            NeoDatis.Odb.ODB odb4 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
                                                                       + "exta1");
            // Check committed object value
            NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
                                                     .GetObjectFromId(oid);
            AssertEquals("function " + (nbThreads - 1), f4.GetName());
            AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
            odb4.Close();
            server.Close();
        }
Ejemplo n.º 35
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test2()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb         = Open(baseName);
            long             nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.VO.Login.Function)));
            long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                            (typeof(NeoDatis.Odb.Test.VO.Login.Profile)));

            NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function1");
            NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function2");
            NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("function3");
            System.Collections.IList functions = new System.Collections.ArrayList();
            functions.Add(function1);
            functions.Add(function2);
            functions.Add(function3);
            NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
                                                              ("profile1", functions);
            NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile
                                                              ("profile2", function1);
            odb.Store(profile1);
            odb.Store(profile2);
            odb.Close();
            odb = Open(baseName);
            // checks functions
            NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                    ), true);
            AssertEquals(nbFunctions + 3, lfunctions.Count);
            NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                        (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                        .Equal("name", "function2")));
            NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
                                                            )l.GetFirst();
            odb.Delete(function);
            odb.Close();
            odb = Open(baseName);
            AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                        (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                            ), true);
            // check Profile 1
            NeoDatis.Odb.Objects lprofile = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                               (typeof(NeoDatis.Odb.Test.VO.Login.Profile), NeoDatis.Odb.Core.Query.Criteria.Where
                                                               .Equal("name", "profile1")));
            NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile
                                                    .GetFirst();
            AssertEquals(2, p1.GetFunctions().Count);
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 36
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestConcurrentObjectVersion3()
        {
            if (isLocal || (useSameVmOptimization && !testNewFeature))
            {
                return;
            }
            // LogUtil.allOn(true);
            DeleteBase("exta1");
            NeoDatis.Odb.ODB odb = Open("exta1");
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
            int version          = odb.Ext().GetObjectVersion(oid);

            Println(version);
            odb.Close();
            int nbThreads = 100;

            NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
            int[] versions          = new int[nbThreads];
            NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
                                                              [nbThreads];
            // Open all Odbs and get the object
            for (int i = 0; i < nbThreads; i++)
            {
                odbs[i]      = Open("exta1");
                versions[i]  = odbs[i].Ext().GetObjectVersion(oid);
                functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
                AssertEquals(1, versions[i]);
                AssertEquals("f1", functions[i].GetName());
            }
            // Open all Odbs and get the object
            for (int i = 0; i < nbThreads; i++)
            {
                functions[i].SetName("function " + i);
                odbs[i].Store(functions[i]);
                versions[i] = odbs[i].Ext().GetObjectVersion(oid);
                Println("Function with name " + functions[i].GetName() + " has version " + versions
                        [i]);
                odbs[i].Close();
                AssertEquals(i + 2, versions[i]);
                // Just to check the version number after commit
                odb = Open("exta1");
                int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
                Println("After commit = " + committedVersionNumber);
                AssertEquals(i + 2, committedVersionNumber);
                odb.Close();
            }
            NeoDatis.Odb.ODB odb4 = Open("exta1");
            // Check committed object value
            NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
                                                     .GetObjectFromId(oid);
            AssertEquals("function " + (nbThreads - 1), f4.GetName());
            AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
            odb4.Close();
        }
Ejemplo n.º 37
0
        public virtual void TestGetObects()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("Test"));
            NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.Function> functions = odb.GetObjects
                                                                                       (typeof(NeoDatis.Odb.Test.VO.Login.Function));
            NeoDatis.Odb.Test.VO.Login.Function f = functions.GetFirst();
            odb.Close();
            AssertEquals(1, functions.Count);
        }
Ejemplo n.º 38
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			long nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function)));
			long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile)));
			NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
				("function1");
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("function2");
			NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function
				("function3");
			System.Collections.IList functions = new System.Collections.ArrayList();
			functions.Add(function1);
			functions.Add(function2);
			functions.Add(function3);
			NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
				("profile1", functions);
			NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile
				("profile2", function1);
			odb.Store(profile1);
			odb.Store(profile2);
			odb.Close();
			odb = Open(baseName);
			// checks functions
			NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			AssertEquals(nbFunctions + 3, lfunctions.Count);
			NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", "function2")));
			NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
				)l.GetFirst();
			odb.Delete(function);
			odb.Close();
			odb = Open(baseName);
			AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function))));
			NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			// check Profile 1
			NeoDatis.Odb.Objects lprofile = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", "profile1")));
			NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile
				.GetFirst();
			AssertEquals(2, p1.GetFunctions().Count);
			odb.Close();
			DeleteBase(baseName);
		}
Ejemplo n.º 39
0
		private object GetUserInstance(int i)
		{
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login" + i);
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout" + i);
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator" + i, list);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				 + i, "*****@*****.**", profile);
			return user;
		}
Ejemplo n.º 40
0
		private object GetUserInstance()
		{
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			System.Collections.Generic.IList<NeoDatis.Odb.Test.VO.Login.Function> list = new 
				System.Collections.Generic.List<NeoDatis.Odb.Test.VO.Login.Function>();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", list);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			return user;
		}
Ejemplo n.º 41
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCompositeCollection2DifferentObjects()
		{
			DeleteBase("ti1.neodatis");
			NeoDatis.Odb.ODB odb = Open("ti1.neodatis");
			int nbUsers = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), true).Count;
			int nbProfiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile), true)
				.Count;
			int nbFunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true
				).Count;
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			NeoDatis.Odb.Test.VO.Login.Function disconnect = new NeoDatis.Odb.Test.VO.Login.Function
				("disconnect");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			System.Collections.IList list2 = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator 1", list);
			NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator 2", list2);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile1);
			NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("A√°sa Galv√£o Smadja"
				, "*****@*****.**", profile2);
			odb.Store(user);
			odb.Store(userB);
			odb.Commit();
			NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
				), true);
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			odb.Close();
			// assertEquals(nbUsers+2,users.size());
			NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			AssertEquals(nbProfiles + 2, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			DeleteBase("ti1.neodatis");
		}
Ejemplo n.º 42
0
		/// <summary>Loading x objects, x/2 are modified, using strategy 2</summary>
		public virtual void Test2()
		{
			NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch();
			stopWatch.Start();
			System.Collections.IDictionary objects = new NeoDatis.Tool.Wrappers.Map.OdbHashMap
				();
			NeoDatis.Odb.Test.VO.Login.Function f = null;
			NeoDatis.Odb.OID oid = null;
			NeoDatis.Odb.Test.Performance.ObjectWrapper ow = null;
			int i = 0;
			for (i = 0; i < size; i++)
			{
				f = new NeoDatis.Odb.Test.VO.Login.Function("function " + i);
				oid = NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(i);
				objects.Add(oid, new NeoDatis.Odb.Test.Performance.ObjectWrapper(f, false));
				if (i < size / 2)
				{
					ow = (NeoDatis.Odb.Test.Performance.ObjectWrapper)objects[oid];
					ow.SetModified(true);
				}
				if (i % 10000 == 0)
				{
					NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("put i", false);
				}
			}
			i = 0;
			int nbModified = 0;
			// Now get all modified objects
			System.Collections.IEnumerator iterator = objects.Keys.GetEnumerator();
			while (iterator.MoveNext())
			{
				oid = (NeoDatis.Odb.OID)iterator.Current;
				ow = (NeoDatis.Odb.Test.Performance.ObjectWrapper)objects[oid];
				if (ow.IsModified())
				{
					nbModified++;
				}
				if (i % 10000 == 0)
				{
					NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("get i", false);
				}
				i++;
			}
			stopWatch.End();
			Println("time for 1 map =" + stopWatch.GetDurationInMiliseconds());
			AssertEquals(size / 2, nbModified);
		}
Ejemplo n.º 43
0
        public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = Open("withoid");
			NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
			odb.Close();
			odb = Open("withoid");
			NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
				"f2");
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(odb);
			engine.Store(oid, f2);
			odb.Close();
			odb = Open("withoid");
			NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
				GetObjectFromId(oid);
			odb.Close();
			AssertEquals("f2", f.GetName());
		}
Ejemplo n.º 44
0
		/// <exception cref="Java.IO.UnsupportedEncodingException"></exception>
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2_ClientServer()
		{
			string baseName = GetBaseName();
			Println(baseName);
			string currentEncoding = NeoDatis.Odb.OdbConfiguration.GetDatabaseCharacterEncoding
				();
			NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding("ISO8859-5");
			NeoDatis.Odb.ODBServer server = null;
			try
			{
				server = NeoDatis.Odb.ODBFactory.OpenServer(NeoDatis.Odb.Test.ODBTest.Port + 1);
				server.AddBase(baseName, baseName);
				server.StartServer(true);
				Java.Lang.Thread.Sleep(200);
				NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", NeoDatis.Odb.Test.ODBTest
					.Port + 1, baseName);
				string nameWithCyrillicCharacters = "\u0410 \u0430 \u0431 \u0448 \u0429";
				NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function(nameWithCyrillicCharacters
					);
				NeoDatis.Odb.OID oid = odb.Store(f);
				odb.Close();
				Println(f);
				odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", NeoDatis.Odb.Test.ODBTest.Port
					 + 1, baseName);
				NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
					.GetObjectFromId(oid);
				odb.Close();
				AssertEquals(nameWithCyrillicCharacters, f2.GetName());
				AssertEquals('\u0410', f2.GetName()[0]);
				AssertEquals('\u0430', f2.GetName()[2]);
				AssertEquals('\u0431', f2.GetName()[4]);
				AssertEquals('\u0448', f2.GetName()[6]);
				AssertEquals('\u0429', f2.GetName()[8]);
			}
			finally
			{
				NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding(currentEncoding);
				if (server != null)
				{
					server.Close();
				}
			}
		}
Ejemplo n.º 45
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestGetObjectId()
		{
			DeleteBase("extb");
			NeoDatis.Odb.ODB odb = null;
			odb = Open("extb");
			NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("Test Function"
				);
			NeoDatis.Odb.OID oid = odb.Store(f);
			NeoDatis.Odb.ExternalOID extOid = odb.Ext().GetObjectExternalOID(f);
			AssertEquals(oid.GetObjectId(), extOid.GetObjectId());
			AssertEquals(odb.Ext().GetDatabaseId(), extOid.GetDatabaseId());
			odb.Close();
			odb = Open("extb");
			// Getting object via external oid
			NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
				.GetObjectFromId(extOid);
			NeoDatis.Odb.OID lastOid = odb.GetObjectId(f2);
			AssertEquals(oid, lastOid);
			AssertEquals(f.GetName(), f2.GetName());
			odb.Close();
		}
Ejemplo n.º 46
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCompositeCollection1()
		{
			DeleteBase("t31.neodatis");
			NeoDatis.Odb.ODB odb = Open("t31.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator 1", list);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile1);
			odb.Store(user);
			odb.Close();
			odb = Open("t31.neodatis");
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			odb.Close();
			// assertEquals(nbUsers+2,users.size());
			NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			DeleteBase("t31.neodatis");
		}
Ejemplo n.º 47
0
		/// <summary>Stores an object, closes the base.</summary>
		/// <remarks>
		/// Stores an object, closes the base. Loads the object, gets its oid and
		/// delete by oid.
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test19()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = null;
			odb = Open(baseName);
			NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function1");
			odb.Store(f1);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				));
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
				.GetFirst();
			NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
			odb.DeleteObjectWithId(oid);
			AssertEquals(0, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
				);
			odb.Close();
			odb = Open(baseName);
			objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
			AssertEquals(0, objects.Count);
		}
Ejemplo n.º 48
0
		/// <summary>
		/// Stores on object and close database then Stores another object, commits
		/// without closing.
		/// </summary>
		/// <remarks>
		/// Stores on object and close database then Stores another object, commits
		/// without closing. Loads the object, gets its oid and delete by oid. In the
		/// case the commit has no write actions. And there was a bug : when there is
		/// no write actions, the commit process is much more simple! but in this the
		/// cache was not calling the transaction.clear and this was a reason for
		/// some connected/unconnected zone problem! (step14 of the turotial.)
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test20()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = null;
			odb = Open(baseName);
			NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
				"1function0");
			odb.Store(f0);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function1");
			odb.Store(f1);
			odb.Commit();
			NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
				.Like("name", "func%")));
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
				.GetFirst();
			NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
			odb.DeleteObjectWithId(oid);
			AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
				);
			odb.Close();
			odb = Open(baseName);
			objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
			AssertEquals(1, objects.Count);
		}
Ejemplo n.º 49
0
		/// <summary>
		/// Bug when deleting the first object of unconnected zone when commited zone
		/// already have at least one object.
		/// </summary>
		/// <remarks>
		/// Bug when deleting the first object of unconnected zone when commited zone
		/// already have at least one object.
		/// Detected running the polePosiiton Bahrain circuit.
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test21()
		{
			NeoDatis.Odb.ODB odb = null;
			string baseName = GetBaseName();
			odb = Open(baseName);
			NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function0");
			odb.Store(f0);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function1");
			odb.Store(f1);
			NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
				"function2");
			odb.Store(f2);
			odb.Delete(f1);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function)));
			AssertEquals(2, objects.Count);
			odb.Close();
		}
Ejemplo n.º 50
0
        public virtual void Test8()
		{
			int size1 = 1000;
			int size2 = 1000;
			if (!runAll)
			{
				return;
			}
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = null;
			NeoDatis.Odb.Objects os = null;
			for (int i = 0; i < size1; i++)
			{
				odb = Open(baseName);
				for (int j = 0; j < size2; j++)
				{
					NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function "
						 + j);
					odb.Store(f);
				}
				odb.Close();
				odb = Open(baseName);
				os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
				while (os.HasNext())
				{
					NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)os.Next
						();
					odb.Delete(f);
				}
				odb.Close();
				if (i % 100 == 0)
				{
					Println(i + "/" + size1);
				}
			}
			odb = Open(baseName);
			os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
			AssertEquals(0, os.Count);
			odb.Close();
			Println("step2");
			for (int i = 0; i < size1; i++)
			{
				odb = Open(baseName);
				os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
				while (os.HasNext())
				{
					NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)os.Next
						();
					odb.Delete(f);
				}
				odb.Close();
				odb = Open(baseName);
				for (int j = 0; j < size2; j++)
				{
					NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function "
						 + j);
					odb.Store(f);
				}
				odb.Close();
				if (i % 100 == 0)
				{
					Println(i + "/" + size1);
				}
			}
			odb = Open(baseName);
			os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
			AssertEquals(size2, os.Count);
			odb.Close();
			DeleteBase(baseName);
		}
Ejemplo n.º 51
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test3()
		{
			DeleteBase("t1u2.neodatis");
			NeoDatis.Odb.ODB odb = Open("t1u2.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				(null);
			odb.Store(login);
			odb.Close();
			odb = Open("t1u2.neodatis");
			login = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
				.IsNull("name"))).GetFirst();
			AssertTrue(login.GetName() == null);
			login.SetName("login");
			odb.Store(login);
			odb.Close();
			odb = Open("t1u2.neodatis");
			login = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				)).GetFirst();
			AssertTrue(login.GetName().Equals("login"));
			odb.Close();
			DeleteBase("t1u2.neodatis");
		}
Ejemplo n.º 52
0
        public virtual void TestCompareCollection9()
		{
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", function);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new 
				NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			// Sets attributes offsets - this is normally done by reading then from
			// disk, but in this junit,
			// we must set them manually
			long[] offsets = new long[] { 1L, 2L, 3L };
			int[] ids = new int[] { 1, 2, 3 };
			instanceInfo.GetHeader().SetAttributesIdentification(offsets);
			instanceInfo.GetHeader().SetAttributesIds(ids);
			instanceInfo.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1
				));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			user.SetName("Kiko");
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			instanceInfo3.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(
				1));
			nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)instanceInfo3
				.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
			AssertEquals(1, comparator.GetNbChanges());
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = 
				(NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator
				.GetChangedAttributeActions()[0];
			AssertEquals(1, comparator.GetChangedAttributeActions().Count);
			AssertEquals(user.GetName(), cnaa.GetNoiWithNewValue().GetObject());
		}
Ejemplo n.º 53
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test6()
		{
			// LogUtil.objectWriterOn(true);
			DeleteBase("t6.neodatis");
			NeoDatis.Odb.ODB odb = Open("t6.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", list);
			NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			odb.Store(olivier);
			odb.Close();
			Println("----------");
			odb = Open("t6.neodatis");
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			NeoDatis.Odb.Test.VO.Login.User u1 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			u1.GetProfile().SetName("operator 234567891011121314");
			odb.Store(u1);
			odb.Close();
			odb = Open("t6.neodatis");
			NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
				), true);
			AssertEquals(1, profiles.Count);
			NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)profiles
				.GetFirst();
			AssertEquals(u1.GetProfile().GetName(), p1.GetName());
		}
Ejemplo n.º 54
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2()
		{
			DeleteBase("t2.neodatis");
			NeoDatis.Odb.ODB odb = Open("t2.neodatis");
			int nbUsers = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User)).Count;
			int nbProfiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile), true)
				.Count;
			int nbFunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true
				).Count;
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", list);
			NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
				, "*****@*****.**", profile);
			odb.Store(olivier);
			odb.Store(aisa);
			odb.Commit();
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
				), true);
			NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			odb.Close();
			// println("Users:"+users);
			Println("Profiles:" + profiles);
			Println("Functions:" + functions);
			odb = Open("t2.neodatis");
			NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), 
				true);
			odb.Close();
			AssertEquals(nbUsers + 2, users.Count);
			NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			AssertEquals(olivier.ToString(), user2.ToString());
			AssertEquals(nbProfiles + 1, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			NeoDatis.Odb.ODB odb2 = Open("t2.neodatis");
			l = odb2.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true);
			NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
				)l.GetFirst();
			function.SetName("login function");
			odb2.Store(function);
			odb2.Close();
			NeoDatis.Odb.ODB odb3 = Open("t2.neodatis");
			NeoDatis.Odb.Objects l2 = odb3.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User)
				, true);
			int i = 0;
			while (l2.HasNext() && i < System.Math.Min(2, l2.Count))
			{
				NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l2.Next();
				AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0]
					);
				i++;
			}
			odb3.Close();
			DeleteBase("t2.neodatis");
		}
Ejemplo n.º 55
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestConcurrentObjectVersion3()
		{
			if (isLocal || (useSameVmOptimization && !testNewFeature))
			{
				return;
			}
			// LogUtil.allOn(true);
			DeleteBase("exta1");
			NeoDatis.Odb.ODB odb = Open("exta1");
			NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
			int version = odb.Ext().GetObjectVersion(oid);
			Println(version);
			odb.Close();
			int nbThreads = 100;
			NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
			int[] versions = new int[nbThreads];
			NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
				[nbThreads];
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				odbs[i] = Open("exta1");
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
				AssertEquals(1, versions[i]);
				AssertEquals("f1", functions[i].GetName());
			}
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				functions[i].SetName("function " + i);
				odbs[i].Store(functions[i]);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				Println("Function with name " + functions[i].GetName() + " has version " + versions
					[i]);
				odbs[i].Close();
				AssertEquals(i + 2, versions[i]);
				// Just to check the version number after commit
				odb = Open("exta1");
				int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
				Println("After commit = " + committedVersionNumber);
				AssertEquals(i + 2, committedVersionNumber);
				odb.Close();
			}
			NeoDatis.Odb.ODB odb4 = Open("exta1");
			// Check committed object value
			NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
				.GetObjectFromId(oid);
			AssertEquals("function " + (nbThreads - 1), f4.GetName());
			AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
			odb4.Close();
		}
Ejemplo n.º 56
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestConcurrentObjectVersion2()
		{
			// LogUtil.allOn(true);
			int port = Port + 8;
			NeoDatis.Tool.IOUtil.DeleteFile(Directory + "exta1");
			NeoDatis.Odb.ODBServer server = NeoDatis.Odb.ODBFactory.OpenServer(port);
			server.StartServer(true);
			NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
				 + "exta1");
			NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
			int version = odb.Ext().GetObjectVersion(oid);
			Println(version);
			odb.Close();
			int nbThreads = 100;
			NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
			int[] versions = new int[nbThreads];
			NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
				[nbThreads];
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				odbs[i] = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1"
					);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
				AssertEquals(1, versions[i]);
				AssertEquals("f1", functions[i].GetName());
			}
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				functions[i].SetName("function " + i);
				odbs[i].Store(functions[i]);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				Println("Function with name " + functions[i].GetName() + " has version " + versions
					[i]);
				odbs[i].Close();
				AssertEquals(i + 2, versions[i]);
				// Just to check the version number after commit
				odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1");
				int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
				Println("After commit = " + committedVersionNumber);
				AssertEquals(i + 2, committedVersionNumber);
				odb.Close();
			}
			NeoDatis.Odb.ODB odb4 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
				 + "exta1");
			// Check committed object value
			NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
				.GetObjectFromId(oid);
			AssertEquals("function " + (nbThreads - 1), f4.GetName());
			AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
			odb4.Close();
			server.Close();
		}
Ejemplo n.º 57
0
		/// <summary>Test performance of retrieving 2 objects by oid</summary>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test5()
		{
			DeleteBase("getid.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
				("f1");
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("f2");
			NeoDatis.Odb.ODB odb = Open("getid.neodatis");
			odb.Store(function1);
			odb.Store(function2);
			NeoDatis.Odb.OID id1 = odb.GetObjectId(function1);
			NeoDatis.Odb.OID id2 = odb.GetObjectId(function2);
			odb.Close();
			odb = Open("getid.neodatis");
			long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Test.VO.Login.Function function1bis = (NeoDatis.Odb.Test.VO.Login.Function
				)odb.GetObjectFromId(id1);
			NeoDatis.Odb.Test.VO.Login.Function function2bis = (NeoDatis.Odb.Test.VO.Login.Function
				)odb.GetObjectFromId(id2);
			long t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			odb.Close();
			DeleteBase("getid.neodatis");
			AssertEquals(function1.GetName(), function1bis.GetName());
			AssertEquals(function2.GetName(), function2bis.GetName());
			long time = t2 - t1;
			Println(time);
			long acceptableTime = isLocal ? 1 : 17;
			if (time > acceptableTime)
			{
				// ms
				Fail("Getting two objects by oid lasted more than " + acceptableTime + "ms : " + 
					time);
			}
		}
Ejemplo n.º 58
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test5()
		{
			DeleteBase("t5.neodatis");
			NeoDatis.Odb.ODB odb = Open("t5.neodatis");
			long nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Function)));
			long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile)));
			long nbUsers = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
				typeof(NeoDatis.Odb.Test.VO.Login.User)));
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			list.Add(logout);
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", list);
			NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
				, "*****@*****.**", profile);
			odb.Store(olivier);
			odb.Store(profile);
			odb.Commit();
			odb.Close();
			odb = Open("t5.neodatis");
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
				), true);
			NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
				), true);
			odb.Close();
			AssertEquals(nbUsers + 1, users.Count);
			AssertEquals(nbProfiles + 1, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
		}
Ejemplo n.º 59
0
		/// <summary>Trying to get an object with OID that does not exist</summary>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void TestGetOIDThatDoesNotExist()
		{
			DeleteBase("getid.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
				("f2");
			NeoDatis.Odb.ODB odb = Open("getid.neodatis");
			NeoDatis.Odb.OID oid = NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(49);
			try
			{
				object o = odb.GetObjectFromId(oid);
			}
			catch (System.Exception e)
			{
				odb.Close();
				AssertFalse(e.Message.IndexOf(" does not exist in the database") == -1);
			}
		}
Ejemplo n.º 60
0
        public virtual void TestCopy()
		{
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", function);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo copy = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.CreateCopy(new NeoDatis.Tool.Wrappers.Map.OdbHashMap(), true);
			AssertEquals(3, copy.GetAttributeValues().Length);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] aois = copy.GetAttributeValues
				();
			for (int i = 0; i < aois.Length; i++)
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = aois[i];
				AssertEquals(instanceInfo.GetAttributeValues()[i].GetOdbTypeId(), aoi.GetOdbTypeId
					());
			}
		}