コード例 #1
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 = (Function)odb
                                                     .GetObjects <Function>().GetFirst();
            AssertEquals(30000, f2.GetName().Length);
            odb.Close();
            odb = Open("big-data.neodatis");
            f2  = (Function)odb.GetObjects <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 <Function>().GetFirst();
            AssertEquals(newSize, f2.GetName().Length);
            AssertEquals(buffer.ToString() + "ola chico", f2.GetName());
            odb.Close();
        }
コード例 #2
0
        public virtual void Test3()
		{
			// LogUtil.objectReaderOn(true);
			DeleteBase("map-with-collections");
			NeoDatis.Odb.ODB odb = null;
			odb = Open("map-with-collections");
			MyMapObject o = new MyMapObject("test");
			System.Collections.Generic.IList<MyMapObject> c = new System.Collections.Generic.List<MyMapObject>();
			c.Add(o);
			Function f1 = new 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<MyMapObject> os = odb.GetObjects<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());
		}
コード例 #3
0
ファイル: TestBigData.cs プロジェクト: ekicyou/pasta
		/// <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 = (Function)odb
				.GetObjects<Function>().GetFirst();
			AssertEquals(30000, f2.GetName().Length);
			odb.Close();
			odb = Open("big-data.neodatis");
			f2 = (Function)odb.GetObjects<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<Function>().GetFirst();
			AssertEquals(newSize, f2.GetName().Length);
			AssertEquals(buffer.ToString() + "ola chico", f2.GetName());
			odb.Close();
		}
コード例 #4
0
ファイル: TestUnconnectedZone.cs プロジェクト: ekicyou/pasta
 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 <Function>().Count
                  );
     odb.Close();
 }
コード例 #5
0
        public virtual void Test1()
		{
			DeleteBase("t1u.neodatis");
			NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
			Function login = new Function
				("login");
			Function logout = new Function
				("logout");
			odb.Store(login);
			Println("--------");
			odb.Store(login);
			odb.Store(logout);
			// odb.commit();
			odb.Close();
			odb = Open("t1u.neodatis");
			NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(true);
			Function f2 = (Function)l.GetFirst
				();
			f2.SetName("login function");
			odb.Store(f2);
			odb.Close();
			NeoDatis.Odb.ODB odb2 = Open("t1u.neodatis");
			Function f = (Function)odb2
				.GetObjects<Function>().GetFirst();
			AssertEquals("login function", f.GetName());
			odb2.Close();
			DeleteBase("t1u.neodatis");
		}
コード例 #6
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estG1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            int size             = 1000;

            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(GetInstance("f" + i));
                if (simpleObject)
                {
                    NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                            GetObjectFromId(oids[i]);
                    f.SetName("function " + i);
                    odb.Store(f);
                    odb.Store(f);
                    odb.Store(f);
                    odb.Store(f);
                }
                else
                {
                    NeoDatis.Odb.Test.VO.Login.User f = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjectFromId
                                                            (oids[i]);
                    f.SetName("function " + i);
                    odb.Store(f);
                    odb.Store(f);
                    odb.Store(f);
                    odb.Store(f);
                }
            }
            odb.Commit();
        }
コード例 #7
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
        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");
		}
コード例 #8
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
 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");
 }
コード例 #9
0
        public virtual void Test2()
		{
			DeleteBase("t2.neodatis");
			NeoDatis.Odb.ODB odb = Open("t2.neodatis");
			int nbUsers = odb.GetObjects<User>().Count;
			int nbProfiles = odb.GetObjects<Profile>(true).Count;
			int nbFunctions = odb.GetObjects<Function>(true).Count;
			Function login = new Function
				("login");
			Function logout = new Function
				("logout");
            System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>();
			list.Add(login);
			list.Add(logout);
			Profile profile = new Profile("operator", list);
			User olivier = new User("olivier smadja"
				, "*****@*****.**", profile);
			User aisa = new User("Aísa Galvão Smadja"
				, "*****@*****.**", profile);
			odb.Store(olivier);
			odb.Store(aisa);
			odb.Commit();
			NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true);
			NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true);
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true);
			odb.Close();
			// println("Users:"+users);
			Println("Profiles:" + profiles);
			Println("Functions:" + functions);
			odb = Open("t2.neodatis");
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(true);
			odb.Close();
			AssertEquals(nbUsers + 2, users.Count);
			User user2 = (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");
			Objects<Function> l2 = odb2.GetObjects<Function>(true);
			Function function = l2.GetFirst();
			function.SetName("login function");
			odb2.Store(function);
			odb2.Close();
			NeoDatis.Odb.ODB odb3 = Open("t2.neodatis");
			NeoDatis.Odb.Objects<User> l3 = odb3.GetObjects<User>(true);
			int i = 0;
			while (l3.HasNext() && i < System.Math.Min(2, l3.Count))
			{
				User user = (User)l3.Next();
				AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0]
					);
				i++;
			}
			odb3.Close();
			DeleteBase("t2.neodatis");
		}
コード例 #10
0
ファイル: TestCommit.cs プロジェクト: ekicyou/pasta
        public virtual void TestInsertWithCommitsSimpleObject()
        {
            DeleteBase("commits");
            NeoDatis.Odb.ODB odb = null;
            int size             = isLocal ? 10000 : 3000;
            int commitInterval   = 1000;

            try
            {
                odb = Open("commits");
                for (int i = 0; i < size; i++)
                {
                    odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i));
                    if (i % commitInterval == 0)
                    {
                        odb.Commit();
                        Console.WriteLine(i);
                    }
                }
            }
            finally
            {
                // println("commiting "+i);
                odb.Close();
            }
            odb = Open("commits");
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>();
            int nbObjects = objects.Count;

            NeoDatis.Tool.Wrappers.Map.OdbHashMap <Function, int> map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <Function, int>();
            NeoDatis.Odb.Test.VO.Login.Function function = null;
            int j = 0;

            while (objects.HasNext())
            {
                function = (NeoDatis.Odb.Test.VO.Login.Function)objects.Next();
                int ii = (int)map[function];
                if (ii != 0)
                {
                    Println(j + ":" + function.GetName() + " already exist at " + ii);
                }
                else
                {
                    map.Add(function, j);
                }
                j++;
            }
            odb.Close();
            DeleteBase("commits");
            Println("Nb objects=" + nbObjects);
            AssertEquals(size, nbObjects);
        }
コード例 #11
0
ファイル: TestLazy.cs プロジェクト: ekicyou/pasta
		private object GetInstance()
		{
			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.List<Function> list = new System.Collections.Generic.List<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;
		}
コード例 #12
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
 private object GetInstance(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.Generic.IList <Function> list = new System.Collections.Generic.List <Function>();
     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("kiko"
                                                                                + i, "*****@*****.**" + i, profile);
     return(user);
 }
コード例 #13
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
 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);
     }
 }
コード例 #14
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
        public virtual void Test6()
        {
            DeleteBase("getid.neodatis");
            int size = isLocal ? 20001 : 2001;

            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(new NeoDatis.Odb.Test.VO.Login.Function("function " + 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.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oids[i]);
                AssertEquals("function " + i, f.GetName());
                if (i % 3000 == 0)
                {
                    Println(i + "/" + size);
                }
            }
            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.022 : 0.5;

            // 0.04294785260736963
            Println("time for each get = " + time + "/" + size + " = " + timeForEachGet);
            if (testPerformance && timeForEachGet > acceptableTime)
            {
                // ms
                Fail("Getting " + size + " simple objects by oid lasted more than " + acceptableTime
                     + "ms : " + timeForEachGet);
            }
        }
コード例 #15
0
ファイル: TestSession.cs プロジェクト: ekicyou/pasta
        public virtual void Test2()
		{
			DeleteBase("session.neodatis");
			NeoDatis.Odb.ODB odb = Open("session.neodatis");
			Function f = new Function("f1"
				);
			odb.Store(f);
			odb.Commit();
			f.SetName("f1 -1");
			odb.Store(f);
			odb.Close();
			odb = Open("session.neodatis");
			NeoDatis.Odb.Objects<Function> os = odb.GetObjects<Function>();
			AssertEquals(1, os.Count);
			Function f2 = (Function)os.
				GetFirst();
			odb.Close();
			DeleteBase("session.neodatis");
			AssertEquals("f1 -1", f2.GetName());
		}
コード例 #16
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void TestCompositeCollection2DifferentObjects()
		{
			DeleteBase("ti1.neodatis");
			NeoDatis.Odb.ODB odb = Open("ti1.neodatis");
			int nbUsers = odb.GetObjects<User>(true).Count;
			int nbProfiles = odb.GetObjects<Profile>(true).Count;
			int nbFunctions = odb.GetObjects<Function>(true).Count;
			Function login = new Function("login");
			Function logout = new Function("logout");
			Function disconnect = new Function("disconnect");
			System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>();
			list.Add(login);
			list.Add(logout);
            System.Collections.Generic.IList<Function> list2 = new System.Collections.Generic.List<Function>();
			list.Add(login);
			list.Add(logout);
			Profile profile1 = new Profile
				("operator 1", list);
			Profile profile2 = new Profile
				("operator 2", list2);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile1);
			User userB = new User("A√°sa Galv√£o Smadja"
				, "*****@*****.**", profile2);
			odb.Store(user);
			odb.Store(userB);
			odb.Commit();
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true);
			NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true);
			NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true);
			odb.Close();
			// assertEquals(nbUsers+2,users.size());
			User user2 = (User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			AssertEquals(nbProfiles + 2, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			DeleteBase("ti1.neodatis");
		}
コード例 #17
0
ファイル: TestNullObject.cs プロジェクト: ekicyou/pasta
 public virtual void Test5()
 {
     DeleteBase("nullo");
     NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("a simple value"
                                                                                     );
     NeoDatis.Odb.ODB odb = Open("nullo");
     odb.Store(f);
     odb.Close();
     odb = Open("nullo");
     NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                          ));
     NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
                                              .GetFirst();
     f2.SetName(null);
     odb.Store(f2);
     odb.Close();
     odb     = Open("nullo");
     objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
     f2      = (NeoDatis.Odb.Test.VO.Login.Function)objects.GetFirst();
     odb.Close();
     AssertEquals(null, f2.GetName());
 }
コード例 #18
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
        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);
            }
        }
コード例 #19
0
ファイル: TestTrigger.cs プロジェクト: ekicyou/pasta
        public virtual void Test2()
		{
			if (!isLocal)
			{
				return;
			}
			NeoDatis.Odb.ODB odb = null;
			DeleteBase("trigger.neodatis");
			NeoDatis.Odb.Test.Trigger.MyTrigger myTrigger = new NeoDatis.Odb.Test.Trigger.MyTrigger
				();
			try
			{
				odb = Open("trigger.neodatis");
				odb.AddInsertTrigger(typeof(Function), myTrigger);
				Function f1 = new Function(
					"function1");
				Function f2 = new Function(
					"function2");
				Profile profile = new Profile
					("profile1", f1);
				User user = new User("oli", 
					"*****@*****.**", profile);
				odb.Store(user);
				odb.Store(f2);
			}
			finally
			{
				if (odb != null)
				{
					odb.Close();
				}
			}
			odb = Open("trigger.neodatis");
			odb.Close();
			DeleteBase("trigger.neodatis");
			AssertEquals(2, myTrigger.nbInsertsBefore);
			AssertEquals(2, myTrigger.nbInsertsAfter);
		}
コード例 #20
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void TestCompositeCollection1()
		{
			DeleteBase("t31.neodatis");
			NeoDatis.Odb.ODB odb = Open("t31.neodatis");
			Function login = new Function
				("login");
			System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>();
			list.Add(login);
			Profile profile1 = new Profile
				("operator 1", list);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile1);
			odb.Store(user);
			odb.Close();
			odb = Open("t31.neodatis");
			NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true);
			odb.Close();
			// assertEquals(nbUsers+2,users.size());
			User user2 = (User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			DeleteBase("t31.neodatis");
		}
コード例 #21
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estL1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            odb.Store(GetInstance("f1"));
            odb.Store(GetInstance("f2"));
            NeoDatis.Odb.OID oid = odb.Store(GetInstance("f3"));
            odb.Commit();
            object o = odb.GetObjectFromId(oid);

            if (simpleObject)
            {
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)o;
                f.SetName("flksjdfjs;dfsljflsjflksjfksjfklsdjfksjfkalsjfklsdjflskd");
                odb.Store(f);
            }
            else
            {
                NeoDatis.Odb.Test.VO.Login.User f = (NeoDatis.Odb.Test.VO.Login.User)o;
                f.SetName("flksjdfjs;dfsljflsjflksjfksjfklsdjfksjfkalsjfklsdjflskd");
                odb.Store(f);
            }
            odb.Rollback();
        }
コード例 #22
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void Test6()
		{
			DeleteBase("t1u.neodatis");
			NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
			Function login = new Function
				("login");
			Function logout = new Function
				("logout");
			odb.Store(login);
			odb.Store(logout);
			odb.Close();
			odb = Open("t1u.neodatis");
			Function login2 = new Function
				("login2");
			Function logout2 = new Function
				("logout2");
			odb.Store(login2);
			odb.Store(logout2);
			// select without committing
			NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(true);
			AssertEquals(4, l.Count);
			// println(l);
			odb.Close();
			odb = Open("t1u.neodatis");
			l = odb.GetObjects<Function>(true);
			AssertEquals(4, l.Count);
			// println(l);
			odb.Close();
		}
コード例 #23
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void TestSimple()
		{
			DeleteBase("t2.neodatis");
			NeoDatis.Odb.ODB odb = Open("t2.neodatis");
			int nbFunctions = odb.GetObjects<Function>(true).Count;
			Function login = new Function("login");
			Function logout = new Function("logout");
			odb.Store(login);
			odb.Store(logout);
			odb.Close();
			odb = Open("t2.neodatis");
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true);
			Function f1 = (Function)functions.GetFirst();
			f1.SetName("login1");
			odb.Store(f1);
			odb.Close();
			odb = Open("t2.neodatis");
			functions = odb.GetObjects<Function>(true);
			odb.Close();
			AssertEquals(2, functions.Count);
			AssertEquals("login1", ((Function)functions.GetFirst()
				).GetName());
			DeleteBase("t2.neodatis");
		}
コード例 #24
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void TestBufferSize()
		{
			int size = NeoDatis.Odb.OdbConfiguration.GetDefaultBufferSizeForData();
			NeoDatis.Odb.OdbConfiguration.SetDefaultBufferSizeForData(5);
			DeleteBase("ti1.neodatis");
			NeoDatis.Odb.ODB odb = Open("ti1.neodatis");
			System.Text.StringBuilder b = new System.Text.StringBuilder();
			for (int i = 0; i < 1000; i++)
			{
				b.Append("login - login ");
			}
			Function login = new Function
				(b.ToString());
			Profile profile1 = new Profile
				("operator 1", login);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile1);
			odb.Store(user);
			odb.Commit();
			NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true);
			NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true);
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true);
			odb.Close();
			// assertEquals(nbUsers+2,users.size());
			User user2 = (User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			AssertEquals(b.ToString(), user2.GetProfile().GetFunctions().GetEnumerator().Current
				.ToString());
			DeleteBase("ti1.neodatis");
			NeoDatis.Odb.OdbConfiguration.SetDefaultBufferSizeForData(size);
		}
コード例 #25
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void TestUpdateRelation()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			// first create a function
			Function f = new Function("f1"
				);
			odb.Store(f);
			odb.Close();
			odb = Open(baseName);
			// reloads the function
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(new CriteriaQuery(Where.Equal("name", "f1")));
			Function f1 = functions.GetFirst();
			// Create a profile with the loaded function
			Profile profile = new Profile
				("test", f1);
			odb.Store(profile);
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>();
			functions = odb.GetObjects<Function>();
			odb.Close();
			DeleteBase(baseName);
			AssertEquals(1, functions.Count);
			AssertEquals(1, profiles.Count);
		}
コード例 #26
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void TestCompositeCollection3()
		{
			DeleteBase("t4.neodatis");
			NeoDatis.Odb.ODB odb = Open("t4.neodatis");
			// Configuration.addLogId("ObjectWriter");
			// Configuration.addLogId("ObjectReader");
			// Configuration.addLogId("FileSystemInterface");
			int nbUsers = odb.GetObjects<User>(true).Count;
			int nbProfiles = odb.GetObjects<Profile>(true).Count;
			int nbFunctions = odb.GetObjects<Function>(true).Count;
			Function login = new Function("login");
			Function logout = new Function("logout");
			System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>();
			list.Add(login);
			list.Add(logout);
			Profile profile1 = new Profile
				("operator 1", list);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile1);
			User userB = new User("Aísa Galvão Smadja"
				, "*****@*****.**", profile1);
			odb.Store(user);
			odb.Store(userB);
			odb.Close();
			odb = Open("t4.neodatis");
			NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true);
			NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true);
			NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true);
			// assertEquals(nbUsers+2,users.size());
			User user2 = (User)users.GetFirst
				();
			AssertEquals(user.ToString(), user2.ToString());
			AssertEquals(nbProfiles + 1, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			odb.Close();
			DeleteBase("t4.neodatis");
		}
コード例 #27
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void TestUpdateObjectReference4()
		{
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			Function function = new Function
				("login");
			User user = new User("olivier smadja"
				, "*****@*****.**", null);
			odb.Store(user);
			odb.Close();
			Profile profile2 = new Profile
				("new operator", function);
			odb = Open(FileName);
			odb.Store(profile2);
			User user2 = odb.GetObjects<User>().GetFirst();
			user2.SetProfile(profile2);
			odb.Store(user2);
			odb.Close();
			odb = Open(FileName);
			user2 = odb.GetObjects<User>().GetFirst();
			AssertEquals("new operator", user2.GetProfile().GetName());
			AssertEquals(1, odb.GetObjects<Profile>().Count);
			odb.Close();
		}
コード例 #28
0
ファイル: TestCriteriaQuery3.cs プロジェクト: ekicyou/pasta
        public virtual void TestCriteriaQueryQueryWithValueInList2_with_null_object()
		{
			string baseName = GetBaseName();
            SetUp(baseName);
			NeoDatis.Odb.ODB odb = Open(baseName);
			Profile p0 = new Profile("profile0"
				);
			p0.AddFunction(new Function("f1"));
			p0.AddFunction(new Function("f2"));
			Profile p1 = new Profile("profile1"
				);
			p0.AddFunction(new Function("f12"));
			p0.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 = new Function
				("f2");
			CriteriaQuery query = new CriteriaQuery
				(typeof(Profile), Where
				.Contain("functions", null));
			NeoDatis.Odb.Objects<Profile> l = odb.GetObjects<Profile>(query
				);
			AssertEquals(1, l.Count);
			p1 = l.GetFirst();
			AssertEquals("profile1", p1.GetName());
			odb.Close();
		}
コード例 #29
0
ファイル: TestResistance1.cs プロジェクト: ekicyou/pasta
		/// <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());
			}
		}
コード例 #30
0
ファイル: TestResistance1.cs プロジェクト: ekicyou/pasta
		/// <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());
			}
		}
コード例 #31
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void Test8()
		{
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			Function function = new Function
				("login");
			Profile profile = new Profile
				("operator", function);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile);
			odb.Store(user);
			odb.Close();
			odb = Open(FileName);
			User user2 = (User)odb.GetObjects<User>().GetFirst();
			user2.SetProfile(null);
			odb.Store(user2);
			odb.Close();
			odb = Open(FileName);
			User user3 = (User)odb.GetObjects<User>().GetFirst();
			AssertNull(user3.GetProfile());
			odb.Close();
		}
コード例 #32
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void Test5()
		{
			try
			{
				DeleteBase(FileName);
				NeoDatis.Odb.ODB odb = Open(FileName);
				System.Collections.IList list = new System.Collections.ArrayList();
				for (int i = 0; i < 15; i++)
				{
					Function function = new Function
						("function " + i);
					odb.Store(function);
					list.Add(function);
				}
				odb.Close();
				NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(15);
				odb = Open(FileName);
				NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where
					.Or().Add(Where.Like("name", "%9")).Add(Where
					.Like("name", "%8")));
				NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(query, false);
				AssertEquals(2, l.Count);
				l.Next();
				odb.Store(l.Next());
				odb.Close();
				odb = Open(FileName);
				AssertEquals(15, odb.Count(new CriteriaQuery()));
				odb.Close();
			}
			finally
			{
				NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(300000);
			}
		}
コード例 #33
0
ファイル: TestNQQuery2.cs プロジェクト: ekicyou/pasta
 public bool Match(NeoDatis.Odb.Test.VO.Login.Function function)
 {
     return(true);
 }
コード例 #34
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
        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);
			}
		}
コード例 #35
0
ファイル: TestGetObjectByOid.cs プロジェクト: ekicyou/pasta
        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);
			}
		}
コード例 #36
0
ファイル: TestInsert.cs プロジェクト: ekicyou/pasta
        public virtual void Test7()
		{
			DeleteBase("t1u.neodatis");
			NeoDatis.Odb.ODB odb = Open("t1u.neodatis");
			Function login = new Function("login");
			Function logout = new Function("logout");
			odb.Store(login);
			odb.Store(logout);
			odb.Commit();
			Function input = new Function("input");
			odb.Store(input);
			odb.Close();
			odb = Open("t1u.neodatis");
			NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(true);
			AssertEquals(3, l.Count);
			// println(l);
			odb.Close();
		}
コード例 #37
0
ファイル: TestResistance1.cs プロジェクト: ekicyou/pasta
		/// <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();
		}
コード例 #38
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void TestDirectSave()
		{
			if (!isLocal)
			{
				return;
			}
			NeoDatis.Odb.OdbConfiguration.SetSaveHistory(true);
			DeleteBase("btree.neodatis");
			NeoDatis.Odb.ODB odb = Open("btree.neodatis");
			Function function = new Function
				("f1");
			odb.Store(function);
			for (int i = 0; i < 2; i++)
			{
				function.SetName(function.GetName() + function.GetName() + function.GetName() + function
					.GetName());
				odb.Store(function);
			}
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(odb);
			if (isLocal)
			{
			}
			
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = engine.GetSession(true).GetMetaModel
				().GetClassInfo(typeof(Function).FullName, true);
			Println(ci);
			AssertEquals(null, ci.GetCommitedZoneInfo().first);
			AssertEquals(null, ci.GetCommitedZoneInfo().last);
			AssertEquals(1, ci.GetUncommittedZoneInfo().GetNbObjects());
			odb.Close();
		}
コード例 #39
0
ファイル: TestResistance1.cs プロジェクト: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1WithCommit4()
		{
			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(
				"function1");
			odb.Store(f1);
			Function f2 = new Function(
				"function2");
			odb.Store(f2);
			odb.Close();
			odb = Open(FileName);
            NeoDatis.Odb.Objects<Function> objects = odb.GetObjects<Function>();
			Function f = null;
			Println("got the object " + objects.Count);
			for (int k = 0; k < 2; k++)
			{
				objects.Reset();
				while (objects.HasNext())
				{
					f = (Function)objects.Next();
					f.SetName(f.GetName() + "updated-");
					odb.Store(f);
				}
			}
			odb.Close();
			odb = Open(FileName);
			objects = odb.GetObjects<Function>();
			odb.Close();
		}
コード例 #40
0
ファイル: StorageEngineTest.cs プロジェクト: ekicyou/pasta
		/// <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");
		}
コード例 #41
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void Test4()
		{
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(10);
			try
			{
				System.Collections.IList list = new System.Collections.ArrayList();
				for (int i = 0; i < 15; i++)
				{
					Function function = new Function
						("function " + i);
					try
					{
						odb.Store(function);
					}
					catch (System.Exception e)
					{
						odb.Rollback();
						odb.Close();
						AssertTrue(e.Message.IndexOf("Cache is full!") != -1);
						return;
					}
					list.Add(function);
				}
				odb.Close();
				odb = Open(FileName);
				NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>( true);
				l.Next();
				l.Next();
				odb.Store(l.Next());
				odb.Close();
				odb = Open(FileName);
				AssertEquals(15, odb.Count(new CriteriaQuery()));
				odb.Close();
			}
			finally
			{
				NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(300000);
			}
		}
コード例 #42
0
ファイル: TestNQQuery2.cs プロジェクト: ekicyou/pasta
 public bool Match(NeoDatis.Odb.Test.VO.Login.Function function)
 {
     return(function.GetName().Equals("function 5"));
 }
コード例 #43
0
ファイル: TestUpdate.cs プロジェクト: ekicyou/pasta
        public virtual void Test7()
		{
			DeleteBase(FileName);
			NeoDatis.Odb.ODB odb = Open(FileName);
			Function function = new Function
				("login");
			Profile profile = new Profile
				("operator", function);
			User user = new User("olivier smadja"
				, "*****@*****.**", profile);
			odb.Store(user);
			odb.Close();
			odb = Open(FileName);
			User user2 = odb.GetObjects<User>().GetFirst();
			user2.GetProfile().AddFunction(new Function("new Function"
				));
			odb.Store(user2);
			odb.Close();
			odb = Open(FileName);
			User user3 = (User)odb.GetObjects<User>().GetFirst();
			AssertEquals(2, user3.GetProfile().GetFunctions().Count);
			Function f1 = (Function)user3
				.GetProfile().GetFunctions()[0];
			Function f2 = (Function)user3
				.GetProfile().GetFunctions()[1];
			AssertEquals("login", f1.GetName());
			AssertEquals("new Function", f2.GetName());
			odb.Close();
		}