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 bool Match(NeoDatis.Odb.Test.VO.Login.User user)
 {
     return(user.GetProfile().GetName().StartsWith("profile"));
 }
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
 public bool Match(NeoDatis.Odb.Test.VO.Login.User user)
 {
     return(user.GetProfile().GetName().Equals("profile 5"));
 }
Example #7
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1WithCommit3()
		{
			if (!runAll)
			{
				return;
			}
			NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch();
			stopWatch.Start();
			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))));
			NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0"
				, f1);
			p.AddFunction(new Function("f1"));
			User user = new User("user name 0"
				, "user email 0", p);
			odb.Store(user);
			NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0"
				, f1);
			p2.AddFunction(new Function("f2"));
			User user2 = new User("user name 0"
				, "user email 0", p2);
			odb.Store(user2);
			odb.Close();
			odb = Open(FileName);
			NeoDatis.Odb.Objects<User> objects = null;
			for (int k = 0; k < 2; k++)
			{
				System.Console.Out.WriteLine(":" + k);
				objects = odb.GetObjects<User>();
				while (objects.HasNext())
				{
					user = (User)objects.Next();
					user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
					Println(user.GetProfile().GetName());
					odb.Store(user);
				}
			}
			odb.Close();
			odb = Open(FileName);
			objects = odb.GetObjects<User>();
			AssertEquals(2, objects.Count);
			odb.Close();
		}
Example #8
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 #9
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 #10
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 #11
0
		public void SetUp(string baseName)
		{
			NeoDatis.Odb.ODB odb = Open(baseName);
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			int size = 10;
			for (int i = 0; i < size; i++)
			{
				User u = new User("user" + 	i, "email" + i, new Profile("profile" + i, new Function	("function " + i)));
				odb.Store(u);
			}
			User user = new User("big user", "big email", new Profile("big profile", new Function("big function 1")));
			user.GetProfile().AddFunction(new Function("big function 2"));
			user.GetProfile().AddFunction(new Function("big function 3"	));
			user.GetProfile().AddFunction(new Function("big function 4"));
			odb.Store(user);
			user = new User("user no function", "email no function"	, new Profile("profile no function"));
			odb.Store(user);
			odb.Close();
		}
Example #12
0
			public bool Match(User user)
			{
				return user.GetProfile().GetName().Equals(newName);
			}
Example #13
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);
        }