Example #1
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 #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
 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 #4
0
        public virtual void Test9Ordering()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB odb = Open("get.neodatis");
            NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_235();
            query.OrderByDesc("name,email");
            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();
                // println(user.getName() + " / " + user.getEmail());
                AssertEquals("olivier " + i / 3, user.GetName());
                AssertEquals("[email protected] " + ((i % 3) + 1), user.GetEmail());
                i--;
            }
            odb.Close();
        }
Example #5
0
 public bool Match(NeoDatis.Odb.Test.VO.Login.User user)
 {
     return(user.GetProfile().GetName().StartsWith("profile") && user.GetEmail().StartsWith
                ("[email protected] 2"));
 }
Example #6
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 #7
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 #8
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");
		}