Example #1
0
        public virtual void TestCriteriaQueryQueryWithObject()
		{
			string baseName = GetBaseName();
            SetUp(baseName);
			NeoDatis.Odb.ODB odb = Open(baseName);
			Profile p0 = new Profile("profile0"
				);
			p0.AddFunction(null);
			p0.AddFunction(new Function("f1"));
			p0.AddFunction(new Function("f2"));
			Profile p1 = new Profile("profile1"
				);
			p1.AddFunction(null);
			p1.AddFunction(new Function("f12"));
			p1.AddFunction(new Function("f22"));
			User user = new User("The user"
				, "themail", p0);
			User user2 = new User("The user2"
				, "themail2", p1);
			odb.Store(user);
			odb.Store(user2);
			odb.Close();
			odb = Open(baseName);
			Profile pp = (Profile)odb.GetObjects<Profile>
				(new CriteriaQuery(Where.Equal("name", "profile0"))).GetFirst();
			CriteriaQuery query = new CriteriaQuery(Where.Equal("profile", pp));
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query);
			AssertEquals(1, l.Count);
			user = (User)l.GetFirst();
			AssertEquals("The user", user.GetName());
			odb.Close();
		}
Example #2
0
        public virtual void Test1()
		{
			DeleteBase("null.neodatis");
			NeoDatis.Odb.ODB odb = Open("null.neodatis");
			NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli"
				, "oli@sdsadf", null);
			NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine"
				, "karine@sdsadf", null);
			NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null, 
				null, null);
			odb.Store(user1);
			odb.Store(user2);
			odb.Store(user3);
			odb.Close();
			odb = Open("null.neodatis");
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(true);
			AssertEquals(3, l.Count);
			user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals("oli", user1.GetName());
			AssertEquals("oli@sdsadf", user1.GetEmail());
			AssertEquals(null, user1.GetProfile());
			user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals("karine", user2.GetName());
			AssertEquals("karine@sdsadf", user2.GetEmail());
			AssertEquals(null, user2.GetProfile());
			user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals(null, user3.GetName());
			AssertEquals(null, user3.GetEmail());
			AssertEquals(null, user3.GetProfile());
			odb.Close();
			DeleteBase("null.neodatis");
		}
Example #3
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestComplexInstance()
        {
            DeleteBase("t-complex-instance.neodatis");
            NeoDatis.Odb.ODB odb   = Open("t-complex-instance.neodatis");
            Function         login = new Function
                                         ("login");
            Function logout = new Function
                                  ("logout");
            List <Function> functions = new List <Function>();

            functions.Add(login);
            functions.Add(logout);
            Profile profile = new Profile("profile1", functions);

            NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("oliver"
                                                                                       , "*****@*****.**", profile);
            NeoDatis.Odb.Test.VO.Login.User user22 = new NeoDatis.Odb.Test.VO.Login.User("oliver2"
                                                                                         , "*****@*****.**", profile);
            odb.Store(user);
            odb.Store(user22);
            odb.Close();
            odb = Open("t-complex-instance.neodatis");
            NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.User> l = odb.GetObjects <NeoDatis.Odb.Test.VO.Login.User>(true);
            NeoDatis.Odb.Test.VO.Login.User user2 = l.GetFirst();
            // println("#### " + l.size() + " : " + l);
            AssertEquals(user.GetName(), user2.GetName());
            AssertEquals(user.GetEmail(), user2.GetEmail());
            AssertEquals(user.GetProfile().GetName(), user2.GetProfile().GetName());
            AssertEquals(user.GetProfile().GetFunctions()[0].ToString(), user2.GetProfile().GetFunctions
                             ()[0].ToString());
            odb.Close();
            DeleteBase("t-complex-instance.neodatis");
        }
Example #4
0
 public virtual void Test1()
 {
     DeleteBase("null.neodatis");
     NeoDatis.Odb.ODB odb = Open("null.neodatis");
     NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli"
                                                                                 , "oli@sdsadf", null);
     NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine"
                                                                                 , "karine@sdsadf", null);
     NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null,
                                                                                 null, null);
     odb.Store(user1);
     odb.Store(user2);
     odb.Store(user3);
     odb.Close();
     odb = Open("null.neodatis");
     NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(true);
     AssertEquals(3, l.Count);
     user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals("oli", user1.GetName());
     AssertEquals("oli@sdsadf", user1.GetEmail());
     AssertEquals(null, user1.GetProfile());
     user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals("karine", user2.GetName());
     AssertEquals("karine@sdsadf", user2.GetEmail());
     AssertEquals(null, user2.GetProfile());
     user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals(null, user3.GetName());
     AssertEquals(null, user3.GetEmail());
     AssertEquals(null, user3.GetProfile());
     odb.Close();
     DeleteBase("null.neodatis");
 }
Example #5
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCriteriaQueryQueryWithValueInList()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			Profile p0 = new Profile("profile0"
				);
			p0.AddFunction(null);
			p0.AddFunction(new Function("f1"));
			p0.AddFunction(new Function("f2"));
			Profile p1 = new Profile("profile1"
				);
			p1.AddFunction(null);
			p1.AddFunction(new Function("f12"));
			p1.AddFunction(new Function("f22"));
			User user = new User("The user"
				, "themail", p0);
			User user2 = new User("The user2"
				, "themail2", p1);
			odb.Store(user);
			odb.Store(user2);
			odb.Close();
			odb = Open(baseName);
			Function f2bis = (Function)
				odb.GetObjects<Function> (new CriteriaQuery(Where.Equal("name", "f2"))).GetFirst();
			CriteriaQuery query = odb.CriteriaQuery(typeof(
				User), Where.Contain
				("profile.functions", f2bis));
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query);
			AssertEquals(1, l.Count);
			user = (User)l.GetFirst();
			AssertEquals("The user", user.GetName());
			odb.Close();
		}
Example #6
0
        public virtual void Test7()
        {
            DeleteBase("getid.neodatis");
            int size = isLocal ? 10001 : 1000;

            NeoDatis.Odb.ODB   odb  = Open("getid.neodatis");
            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(GetInstance(i));
            }
            odb.Close();
            odb = Open("getid.neodatis");
            long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Login.User u = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjectFromId
                                                        (oids[i]);
                AssertEquals("kiko" + i, u.GetName());
            }
            long t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            odb.Close();
            DeleteBase("getid.neodatis");
            long   time           = t2 - t1;
            double timeForEachGet = (double)time / (double)size;
            double acceptableTime = isLocal ? 0.086 : 1.6;

            // 0.1561843815618438
            Println("time for each get = " + timeForEachGet + " - Total time for " + size + " objects = "
                    + time);
            if (testPerformance && timeForEachGet > acceptableTime)
            {
                // ms
                Println("time for each get = " + timeForEachGet + " - Total time for " + size + " objects = "
                        + time);
                Fail("Getting " + size + " complex objects by oid lasted more than " + acceptableTime
                     + "ms : " + timeForEachGet);
            }
        }
Example #7
0
        public virtual void Test7Ordering()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB odb = Open("get.neodatis");
            NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_183();
            query.OrderByDesc("name");
            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query, true);
            int i = l.Count - 1;

            AssertFalse(l.Count == 0);
            while (l.HasNext())
            {
                NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                AssertEquals("olivier " + i, user.GetName());
                // println(user.getName());
                i--;
            }
            odb.Close();
        }
Example #8
0
        public virtual void Test8Ordering()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB odb = Open("get.neodatis");
            NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_208();
            query.OrderByAsc("name,email");
            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query, true);
            AssertFalse(l.Count == 0);
            int i = 0;

            while (l.HasNext())
            {
                NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                // println(user.getName() + " / " + user.getEmail());
                AssertEquals("olivier " + i / 3, user.GetName());
                AssertEquals("[email protected] " + ((i % 3) + 1), user.GetEmail());
                i++;
            }
            odb.Close();
        }
Example #9
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1WithCommit2()
		{
			if (!runAll)
			{
				return;
			}
			NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch();
			stopWatch.Start();
			int size = 2;
			int size2 = 1;
			int nbFunctions = 1;
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			Function f1 = new Function(
				"function 1");
			Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				User))));
			// Create Objects
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number "
					 + i, f1);
				for (int j = 0; j < nbFunctions; j++)
				{
					p.AddFunction(new Function(" inner function of profile : number "
						 + i + " - " + j));
				}
				User user = new User("user name "
					 + i, "user email " + i, p);
				odb.Store(user);
				if (i % 100 == 0)
				{
					Println("insert " + i);
				}
			}
			odb.Close();
			Println("created");
			// Updates 10 times the objects
			odb = Open(FileName);
			NeoDatis.Odb.Objects<User> objects = odb.GetObjects<User>();
			Println("got the object " + objects.Count);
			for (int k = 0; k < 3; k++)
			{
				objects.Reset();
				long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				for (int i = 0; i < size; i++)
				{
					User user = (User)objects.Next
						();
					user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
					odb.Store(user);
					if (i % 100 == 0)
					{
						Println("update " + i + " - " + k);
					}
				}
				Println("Update " + k + " - " + (NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs
					() - start) + " ms");
			}
			Println("updated");
			Println("deleted");
			odb.Close();
			// Check object count
			odb = Open(FileName);
			objects = odb.GetObjects<User>();
			AssertEquals(objects.Count, size);
			// Check data of the objects
			int a = 0;
			while (objects.HasNext())
			{
				User user = (User)objects.Next
					();
				AssertEquals("user name " + a, user.GetName());
				AssertEquals("user email " + a, user.GetEmail());
				AssertEquals("profile number " + a + "-updated-updated-updated", user.GetProfile(
					).GetName());
				a++;
			}
			Println("checked");
			for (int k = 0; k < 10; k++)
			{
				objects.Reset();
				for (int i = 0; i < size2; i++)
				{
					User user = (User)objects.Next
						();
					user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
					odb.Store(user);
				}
			}
			Println("re-updated");
			odb.Close();
			// delete objects
			odb = Open(FileName);
			objects = odb.GetObjects<User>();
			a = 0;
			while (objects.HasNext())
			{
				odb.Delete(objects.Next());
				a++;
			}
			AssertEquals(size, a);
			odb.Close();
			odb = Open(FileName);
			AssertEquals(0, odb.GetObjects<User>().Count);
			AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(User))));
			Println("deleted");
			odb.Close();
			stopWatch.End();
			Println("Total time 1 = " + stopWatch.GetDurationInMiliseconds());
			if (stopWatch.GetDurationInMiliseconds() > 90700)
			{
				Fail("time is > than " + 90700 + " = " + stopWatch.GetDurationInMiliseconds());
			}
		}
Example #10
0
		/// <summary>
		/// 1) insert 10000 objects 2) update 5000 * 10 times 3) delete other 5000
		/// 4) check count : must be 5000 5) re-update 5000 * 10 times 6) delete the
		/// other 5000 7) check count - must be zero
		/// </summary>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test1WithoutCommit()
		{
			if (!runAll)
			{
				return;
			}
			NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch();
			stopWatch.Start();
			int size = 10000;
			int size2 = 5000;
			int nbFunctions = 10;
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			Function f1 = new Function(
				"function 1");
			// Create Objects
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number "
					 + i, f1);
				for (int j = 0; j < nbFunctions; j++)
				{
					p.AddFunction(new Function(" inner function of profile : number "
						 + i + " - " + j));
				}
				User user = new User("user name "
					 + i, "user email " + i, p);
				odb.Store(user);
			}
			Println("created");
			// Updates 10 times the objects
			NeoDatis.Odb.Objects<User> objects = odb.GetObjects<User>();
			for (int k = 0; k < 10; k++)
			{
				objects.Reset();
				for (int i = 0; i < size2; i++)
				{
					User user = (User)objects.Next
						();
					user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
					odb.Store(user);
				}
			}
			Println("updated");
			// Delete the rest of the objects
			for (int i = size2; i < size; i++)
			{
				odb.Delete(objects.Next());
			}
			Println("deleted");
			// Check object count
			objects = odb.GetObjects<User>();
			AssertEquals(size2, objects.Count);
			// Check data of the objects
			int a = 0;
			while (objects.HasNext())
			{
				User user = (User)objects.Next
					();
				AssertEquals("user name " + a, user.GetName());
				AssertEquals("user email " + a, user.GetEmail());
				AssertEquals("profile number " + a + "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated"
					, user.GetProfile().GetName());
				a++;
			}
			Println("checked");
			for (int k = 0; k < 10; k++)
			{
				objects.Reset();
				for (int i = 0; i < size2; i++)
				{
					User user = (User)objects.Next
						();
					user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
					odb.Store(user);
				}
			}
			Println("re-updated");
			objects = odb.GetObjects<User>();
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(odb);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo uncommited = engine.GetSession(true
				).GetMetaModel().GetClassInfo(typeof(User).FullName, 
				true).GetUncommittedZoneInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo commited = engine.GetSession(true
				).GetMetaModel().GetClassInfo(typeof(User).FullName, 
				true).GetCommitedZoneInfo();
			Println("Before commit : uncommited=" + uncommited);
			Println("Before commit : commited=" + commited);
			a = 0;
			while (objects.HasNext())
			{
				// println("a="+a);
				odb.Delete(objects.Next());
				a++;
			}
			AssertEquals(size2, a);
			AssertEquals(0, odb.GetObjects<User>().Count);
			AssertEquals(0, odb.Count(new CriteriaQuery(typeof(User))));
			Println("deleted");
			odb.Close();
			stopWatch.End();
			Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds());
			if (stopWatch.GetDurationInMiliseconds() > 108438)
			{
				Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds());
			}
		}
Example #11
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestComplexInstance()
		{
			DeleteBase("t-complex-instance.neodatis");
			NeoDatis.Odb.ODB odb = Open("t-complex-instance.neodatis");
			Function login = new Function
				("login");
			Function logout = new Function
				("logout");
			List<Function> functions = new List<Function>();
			functions.Add(login);
			functions.Add(logout);
			Profile profile = new Profile("profile1", functions);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("oliver"
				, "*****@*****.**", profile);
            NeoDatis.Odb.Test.VO.Login.User user22 = new NeoDatis.Odb.Test.VO.Login.User("oliver2"
				, "*****@*****.**", profile);
			odb.Store(user);
			odb.Store(user22);
			odb.Close();
			odb = Open("t-complex-instance.neodatis");
			NeoDatis.Odb.Objects<NeoDatis.Odb.Test.VO.Login.User> l = odb.GetObjects<NeoDatis.Odb.Test.VO.Login.User>(true);
            NeoDatis.Odb.Test.VO.Login.User user2 = l.GetFirst();
			// println("#### " + l.size() + " : " + l);
			AssertEquals(user.GetName(), user2.GetName());
			AssertEquals(user.GetEmail(), user2.GetEmail());
			AssertEquals(user.GetProfile().GetName(), user2.GetProfile().GetName());
			AssertEquals(user.GetProfile().GetFunctions()[0].ToString(), user2.GetProfile().GetFunctions
				()[0].ToString());
			odb.Close();
			DeleteBase("t-complex-instance.neodatis");
		}
Example #12
0
        public virtual void TestInsertSimpleObjectODB()
        {
            bool inMemory = true;

            // Deletes the database file
            NeoDatis.Tool.IOUtil.DeleteFile(OdbFileName);
            long t1  = 0;
            long t2  = 0;
            long t3  = 0;
            long t4  = 0;
            long t5  = 0;
            long t6  = 0;
            long t7  = 0;
            long t77 = 0;
            long t8  = 0;

            NeoDatis.Odb.ODB                odb = null;
            NeoDatis.Odb.Objects <User>     l   = null;
            NeoDatis.Odb.Test.VO.Login.User so  = null;
            // Insert TEST_SIZE objects
            System.Console.Out.WriteLine("Inserting " + TestSize + " objects");
            t1  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User)).AddFullInstantiationHelper
                (new NeoDatis.Odb.Test.Performance.UserFullInstantiationHelper());
            for (int i = 0; i < TestSize; i++)
            {
                object o = GetUserInstance(i);
                odb.Store(o);
            }
            t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Closes the database
            odb.Close();
            t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Retrieving " + TestSize + " objects");
            // Reopen the database
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            // Gets retrieve the TEST_SIZE objects
            l  = odb.GetObjects <User>(inMemory);
            t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Actually get objects
            while (l.HasNext())
            {
                object o = l.Next();
            }
            t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Updating " + TestSize + " objects");
            so = null;
            l.Reset();
            // Actually get objects
            while (l.HasNext())
            {
                so = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                // so.setName(so.getName() + " updated");
                // so.setName(so.getName() + " updated-updated-updated-updated");
                so.GetProfile().SetName(so.GetName() + " updated-updated-updated");
                odb.Store(so);
            }
            t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb.Close();
            t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Deleting " + TestSize + " objects");
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            l   = odb.GetObjects <User>(inMemory);
            t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Actually get objects
            while (l.HasNext())
            {
                so = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                odb.Delete(so);
            }
            odb.Close();
            t8  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            odb.Close();
            DisplayResult("ODB " + TestSize + " User objects ", t1, t2, t3, t4, t5, t6, t7, t77
                          , t8);
        }