예제 #1
0
파일: InsertTest.cs 프로젝트: ekicyou/pasta
        public virtual void TestInsert()
		{
			DeleteBase(NewbieOdb);
			odb = Open(NewbieOdb);
			Driver marcelo = new Driver
				("marcelo");
			Car car = new Car("car1", 
				4, "ranger", marcelo);
			Car car1 = new Car("car2"
				, 2, "porche");
			Car car2 = new Car("car3"
				, 2, "fusca");
			Car car3 = new Car("car4"
				, 4, "opala");
			Car car4 = new Car("car5"
				, 4, "vectra", marcelo);
			try
			{
				// open is called on NewbieTest
				// insert 5 car's
				odb.Store(car);
				odb.Store(car1);
				odb.Store(car2);
				odb.Store(car3);
				odb.Store(car4);
				// find for all car objects
				NeoDatis.Odb.Objects<Car> cars = odb.GetObjects<Car>();
				AssertEquals("The objects weren't added correctly", 5, cars.Count);
				// find for a specific car object
				CriteriaQuery query = new CriteriaQuery(typeof(Car), Where.Equal("name", "car1"));
				cars = odb.GetObjects<Car>(query);
				AssertEquals("The objects couldn't be found correctly", 1, cars.Count);
				// find for a specific composition
				query = new CriteriaQuery(typeof(Car), Where.Equal("driver.name", "marcelo"));
				cars = odb.GetObjects<Car>(query);
				AssertEquals("The objects couldn't be found correctly", 2, cars.Count);
				odb.Commit();
				odb.Close();
				DeleteBase(NewbieOdb);
			}
			catch (System.Exception e)
			{
                Console.WriteLine(e);
			}
		}
예제 #2
0
 /// <exception cref="System.Exception"></exception>
 public override void SetUp()
 {
     base.SetUp();
     DeleteBase("cyclic.neodatis");
     NeoDatis.Odb.ODB odb = Open("cyclic.neodatis");
     for (int i = 0; i < 1; i++)
     {
         City brasilia = new City
                             ("Brasilia" + i);
         Country2 brasil = new Country2
                               ("Brasil" + i);
         brasilia.SetCountry(brasil);
         brasil.SetCapital(brasilia);
         brasil.SetPopulation(450000);
         odb.Store(brasil);
     }
     odb.Store(new User("name", "email", new Profile("profile")));
     odb.Close();
 }
예제 #3
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Populate()
        {
            NeoDatis.Odb.ODB odb  = Open("perfOValuesVsCriteriaIndex");
            string[]         atts = new string[] { "name" };
            try
            {
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User2)).AddUniqueIndexOn
                    ("Index", atts, true);
            }
            catch (System.Exception)
            {
            }
            // TODO: handle exception
            int nbProfiles = 200;
            int nbUsers    = 500000;

            NeoDatis.Odb.Test.VO.Login.Profile[] profiles = new NeoDatis.Odb.Test.VO.Login.Profile
                                                            [nbProfiles];
            NeoDatis.Odb.Test.VO.Login.User2[] users = new NeoDatis.Odb.Test.VO.Login.User2[nbUsers
                                                       ];
            int userStart    = 1500000;
            int profileStart = 600;

            // First creates profiles
            for (int i = 0; i < nbProfiles; i++)
            {
                profiles[i] = new NeoDatis.Odb.Test.VO.Login.Profile("profile " + (i + profileStart
                                                                                   ), new NeoDatis.Odb.Test.VO.Login.Function("function Profile" + i));
                odb.Store(profiles[i]);
            }
            // Then creates users
            for (int i = 0; i < nbUsers; i++)
            {
                users[i] = new NeoDatis.Odb.Test.VO.Login.User2("user" + (i + userStart), "user mail"
                                                                + i, profiles[GetProfileIndex(nbProfiles)], i);
                odb.Store(users[i]);
                if (i % 10000 == 0)
                {
                    Println(i);
                }
            }
            odb.Close();
        }
예제 #4
0
파일: TestArray.cs 프로젝트: ekicyou/pasta
 public virtual void TestArray1()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         DeleteBase("array1.neodatis");
         odb = Open("array1.neodatis");
         decimal nb = odb.Count(new CriteriaQuery(typeof(
                                                      PlayerWithArray)));
         PlayerWithArray player = new PlayerWithArray
                                      ("kiko");
         player.AddGame("volley-ball");
         player.AddGame("squash");
         player.AddGame("tennis");
         player.AddGame("ping-pong");
         odb.Store(player);
         odb.Close();
         odb = Open("array1.neodatis");
         NeoDatis.Odb.Objects <PlayerWithArray> l = odb.GetObjects <PlayerWithArray>(true);
         AssertEquals(nb + 1, l.Count);
         // gets first player
         PlayerWithArray player2 = l.GetFirst();
         AssertEquals(player.ToString(), player2.ToString());
     }
     catch (System.Exception e)
     {
         if (odb != null)
         {
             odb.Rollback();
             odb = null;
         }
         Console.WriteLine(e);
         throw e;
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
         DeleteBase("array1.neodatis");
     }
 }
예제 #5
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.Exception"></exception>
 public virtual void Test17()
 {
     DeleteBase("valuesA2");
     NeoDatis.Odb.ODB odb = Open("valuesA2");
     odb.Store(new NeoDatis.Odb.Test.VO.Login.User("user1", "email1", new NeoDatis.Odb.Test.VO.Login.Profile
                                                       ("profile name", new NeoDatis.Odb.Test.VO.Login.Function("f111"))));
     odb.Close();
     odb = Open("valuesA2");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.VO.Login.User)).Field("name").Field("profile"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     odb.Close();
     AssertEquals("user1", ov.GetByAlias("name"));
     AssertEquals("user1", ov.GetByIndex(0));
     NeoDatis.Odb.Test.VO.Login.Profile p2 = (NeoDatis.Odb.Test.VO.Login.Profile)ov.GetByAlias
                                                 ("profile");
     AssertEquals("profile name", p2.GetName());
 }
예제 #6
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test2()
 {
     DeleteBase("native.neodatis");
     NeoDatis.Odb.ODB @base = Open("native.neodatis");
     try
     {
         string[] array = new string[] { "olivier", "joao", "peter" };
         @base.Store(array);
     }
     catch (NeoDatis.Odb.ODBRuntimeException)
     {
         @base.Close();
         DeleteBase("native.neodatis");
         return;
     }
     @base.Close();
     Fail("Allow native object direct persistence");
     DeleteBase("native.neodatis");
 }
예제 #7
0
 /// <exception cref="System.Exception"></exception>
 public virtual void T1estN2()
 {
     NeoDatis.Odb.ODB odb = test.Open("acid1");
     if (simpleObject)
     {
         NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "f1000")));
         Function f = objects.GetFirst();
         f.SetName("new name");
         odb.Store(f);
     }
     else
     {
         NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(new CriteriaQuery(Where.Equal("name", "f1000")));
         User f = objects.GetFirst();
         f.SetName("new name");
         odb.Store(f);
     }
     odb.Commit();
 }
예제 #8
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estH1()
        {
            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.Delete(f);
                    oids[i] = odb.Store(f);
                    odb.Delete(f);
                    oids[i] = odb.Store(f);
                    odb.Delete(f);
                    oids[i] = 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.Delete(f);
                    oids[i] = odb.Store(f);
                    odb.Delete(f);
                    oids[i] = odb.Store(f);
                    odb.Delete(f);
                    oids[i] = odb.Store(f);
                }
            }
            for (int i = 0; i < size; i++)
            {
                object o = odb.GetObjectFromId(oids[i]);
                odb.Delete(o);
            }
        }
예제 #9
0
        /// <summary>Using Object representation instead of real object</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5()
        {
            int sublistSize = 400;

            if (!isLocal && !useSameVmOptimization)
            {
                sublistSize = 40;
            }
            string baseName = GetBaseName();

            DeleteBase(baseName);
            NeoDatis.Odb.ODB odb = Open(baseName);
            NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                                 ();
            for (int i = 0; i < sublistSize; i++)
            {
                handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value "
                                                                                  + i));
            }
            odb.Store(handler);
            odb.Close();
            odb = Open("valuesSubList3");
            long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Sublist("parameters", "sub", 0,
                                                                                                                  2, true);
            NeoDatis.Odb.Values values = odb.GetValues(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens for " + sublistSize + " : " + (end - start
                                                                                    ));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(2, sublist.Count);
            NeoDatis.Odb.Test.Query.Values.Parameter parameter = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                                  )sublist[1];
            AssertEquals("value 1", parameter.GetValue());
            NeoDatis.Odb.OID oid = odb.GetObjectId(parameter);
            Println(oid);
            odb.Close();
        }
예제 #10
0
 public virtual void Test4()
 {
     DeleteBase("nullo");
     NeoDatis.Odb.Test.Nullobject.GenericClass gc = new NeoDatis.Odb.Test.Nullobject.GenericClass
                                                        (null);
     string[] strings = new string[] { "OBJ1", "obj2" };
     gc.SetObject(strings);
     NeoDatis.Odb.ODB odb = Open("nullo");
     odb.Store(gc);
     odb.Close();
     odb = Open("nullo");
     NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Nullobject.GenericClass
                                                          ));
     NeoDatis.Odb.Test.Nullobject.GenericClass gc2 = (NeoDatis.Odb.Test.Nullobject.GenericClass
                                                      )objects.GetFirst();
     gc2.SetObject("Ola");
     odb.Store(gc2);
     odb.Close();
 }
예제 #11
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test5()
 {
     DeleteBase("multi");
     NeoDatis.Odb.ODB odb = Open("multi");
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine"));
     odb.Close();
     odb = Open("multi");
     NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                  (typeof(NeoDatis.Odb.Test.VO.Human.Man)).Field("specie");
     q.SetPolymorphic(true);
     NeoDatis.Odb.Values os = odb.GetValues(q);
     Println(os);
     odb.Close();
     AssertEquals(1, os.Count);
     DeleteBase("multi");
 }
예제 #12
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("multi");
     NeoDatis.Odb.ODB odb = Open("multi");
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine"));
     odb.Close();
     odb = Open("multi");
     NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                            (typeof(object));
     q.SetPolymorphic(true);
     NeoDatis.Odb.Objects os = odb.GetObjects(q);
     Println(os);
     odb.Close();
     AssertEquals(4, os.Count);
     DeleteBase("multi");
 }
예제 #13
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test6()
 {
     DeleteBase("multi");
     NeoDatis.Odb.ODB odb = Open("multi");
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe"));
     odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine"));
     odb.Close();
     odb = Open("multi");
     NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                 (typeof(object));
     q.SetPolymorphic(true);
     System.Decimal nb = odb.Count(q);
     Println(nb);
     odb.Close();
     AssertEquals(new System.Decimal("4"), nb);
     DeleteBase("multi");
 }
예제 #14
0
파일: TestBTree.cs 프로젝트: ekicyou/pasta
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.Exception"></exception>
 public virtual void RunJava()
 {
     NeoDatis.Odb.ODB          odb  = null;
     NeoDatis.Odb.Test.ODBTest test = new NeoDatis.Odb.Test.ODBTest();
     try
     {
         test.DeleteBase("mydb7.neodatis");
         // Open the database
         odb = test.Open("mydb7.neodatis");
         long start0   = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         int  nRecords = 100000;
         for (int i = 0; i < nRecords; i++)
         {
             NeoDatis.Odb.Test.Dotnet.AA ao = new NeoDatis.Odb.Test.Dotnet.AA();
             ao.ccc = "csdcsdc";
             ao.ww  = i;
             odb.Store(ao);
         }
         long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.Dotnet.AA));
         query.OrderByAsc("ww");
         long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         NeoDatis.Odb.Objects object12 = odb.GetObjects(query, false);
         while (object12.HasNext())
         {
             NeoDatis.Odb.Test.Dotnet.AA s = (NeoDatis.Odb.Test.Dotnet.AA)object12.Next();
             int id = s.ww;
         }
         // println(id);
         long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         test.Println("Time=" + (end - start) + " / " + (end - start0) + " / " + (end0 - start0
                                                                                  ));
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
 }
예제 #15
0
 public virtual void Test12()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         odb = Open("t-school.neodatis");
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                             .GetEngine(odb).GetSession(true).GetMetaModel().GetClassInfo(typeof(Student
                                                                                                                                 ).FullName, true);
         AssertFalse(ci.HasCyclicReference());
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
예제 #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
        /// <exception cref="System.Exception"></exception>
        public virtual void NewDownload(string name, string email, string downloadType, string
                                        fileName)
        {
            NeoDatis.Odb.ODB odb  = null;
            User             user = null;

            try
            {
                odb = Open("download.neodatis");
                NeoDatis.Odb.Objects <User> users = odb.GetObjects <User>(new CriteriaQuery(Where.Equal("email", email)));
                if (users.Count != 0 ())
                {
                    user = (User)users.GetFirst();
                    user.SetLastDownload(new System.DateTime());
                    user.SetNbDownloads(user.GetNbDownloads() + 1);
                    odb.Store(user);
                }
                else
                {
                    user = new User();
                    user.SetName(name);
                    user.SetEmail(email);
                    user.SetLastDownload(new System.DateTime());
                    user.SetNbDownloads(1);
                    odb.Store(user);
                }
                NeoDatis.Odb.Test.VO.Download.Download download = new NeoDatis.Odb.Test.VO.Download.Download
                                                                      ();
                download.SetFileName(fileName);
                download.SetType(downloadType);
                download.SetUser(user);
                download.SetWhen(new System.DateTime());
                odb.Store(download);
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
            }
        }
예제 #18
0
        /// <summary>Test the creation of an index after having created objects.</summary>
        /// <remarks>
        /// Test the creation of an index after having created objects. In this case
        /// ODB should creates the index and update it with already existing objects
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test20000Objects()
        {
            string OdbFileName = "index2";
            long   start       = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.ODB odb = null;
            int size             = isLocal ? 20000 : 2000;

            try
            {
                DeleteBase(OdbFileName);
                odb = Open(OdbFileName);
                for (int i = 0; i < size; i++)
                {
                    NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
                                                                   ("name" + i, i, new System.DateTime());
                    odb.Store(io);
                }
                odb.Close();
                odb = Open(OdbFileName);
                string[] names = new string[] { "name" };
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
                    ("index1", names, true);
                NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                  (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                  .Equal("name", "name0")), true);
                AssertEquals(1, objects.Count);
                objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
                                             typeof(NeoDatis.Odb.Test.Index.IndexedObject)), true);
                NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("BTREE", true);
                AssertEquals(size, objects.Count);
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
                long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
                Println((end - start) + "ms");
            }
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
파일: TestUpdate.cs 프로젝트: ekicyou/pasta
        /// <exception cref="System.Exception"></exception>
        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)
            {
            }
            System.Collections.IDictionary history = engine.GetSession(true).GetMetaModel().GetHistory
                                                         ();
            System.Collections.IList functionHistory = (System.Collections.IList)history[typeof(
                                                                                             Function).FullName];
            NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.History.InsertHistoryInfo ihi = (NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.History.InsertHistoryInfo
                                                                                       )functionHistory[functionHistory.Count - 1];
            Println(functionHistory);
            Println(ihi);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = engine.GetSession(true).GetMetaModel
                                                                    ().GetClassInfo(typeof(Function).FullName, true);
            Println(ci);
            AssertEquals(ihi.GetOid(), ci.GetUncommittedZoneInfo().first);
            AssertEquals(ihi.GetOid(), ci.GetUncommittedZoneInfo().last);
            AssertEquals(null, ci.GetCommitedZoneInfo().first);
            AssertEquals(null, ci.GetCommitedZoneInfo().last);
            AssertEquals(1, ci.GetUncommittedZoneInfo().GetNbObjects());
            odb.Close();
        }
예제 #21
0
        public virtual void Test5Sort()
        {
            string BaseName = GetBaseName();

            SetUp(BaseName);
            NeoDatis.Odb.ODB odb = Open(BaseName);
            CriteriaQuery    aq  = new CriteriaQuery(Where
                                                     .Not(Where.Or().Add(Where
                                                                         .Equal("string1", "test class 2")).Add(Where.Equal
                                                                                                                    ("string1", "test class 3"))));

            // aq.orderByDesc("double1,boolean1,int1");
            aq.OrderByDesc("double1,int1");
            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass> (aq, true, -1, -1);
            AssertEquals(48, l.Count);
            TestClass testClass = l.GetFirst();

            AssertEquals("test class 9", testClass.GetString1());
            odb.Close();
        }
예제 #22
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestWithoutUserAndPassword2()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            odb.Store(new NeoDatis.Odb.Test.Update.MyObject(10, "t1"));
            odb.Close();
            try
            {
                odb = Open(baseName, "user", "password");
                Fail("it should have stop for invalid user/password");
            }
            catch (NeoDatis.Odb.ODBAuthenticationRuntimeException)
            {
            }
            // odb.rollback();
            // odb.close();
            // e.printStackTrace();
            DeleteBase(baseName);
        }
예제 #23
0
파일: TestMap.cs 프로젝트: ekicyou/pasta
        public virtual void Test6updateChangingKeyValue()
        {
            // to monitor in place updates
            NeoDatis.Odb.ODB odb   = Open("map.neodatis");
            long             n     = odb.Count(new CriteriaQuery(typeof(Dictionnary)));
            IQuery           query = new CriteriaQuery(typeof(Dictionnary), Where.Equal("name", "test2"));

            NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query);
            Dictionnary dictionnary = (Dictionnary)l.GetFirst();

            dictionnary.GetMap()["f1"] = "changed function";
            odb.Store(dictionnary);
            odb.Close();
            odb = Open("map.neodatis");
            AssertEquals(n, odb.Count(new CriteriaQuery(typeof(Dictionnary))));
            Dictionnary dic = (Dictionnary)odb.GetObjects <Dictionnary>(query).GetFirst();

            AssertEquals("changed function", dic.GetMap()["f1"]);
            odb.Close();
        }
예제 #24
0
 /// <exception cref="System.Exception"></exception>
 public virtual void TestListSize1()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         odb = Open(BaseName);
         CriteriaQuery query = new CriteriaQuery
                                   (typeof(User), Where
                                   .SizeEq("profile.functions", 1));
         NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query);
         AssertEquals(10, l.Count);
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
예제 #25
0
        public virtual void Test1()
        {
            DeleteBase("hook.neodatis");
            NeoDatis.Odb.ODB obase = Open("hook.neodatis");
            obase.GetObjects <TestClass>();
            obase.Store(new NeoDatis.Odb.Test.VO.Attribute.TestClass());
            obase.Close();
            bool exception = false;

            try
            {
                obase.Close();
            }
            catch (System.Exception e)
            {
                exception = true;
                AssertTrue(e.Message.IndexOf("ODB session has already been closed") != -1);
            }
            AssertTrue(exception);
        }
예제 #26
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estN4()
        {
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            int nb = 0;

            if (simpleObject)
            {
                NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "f1000")));
                nb = objects.Count;
            }
            else
            {
                NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(new CriteriaQuery(Where.Equal("name", "f1000")));
                nb = objects.Count;
            }
            if (nb != 0)
            {
                throw new System.Exception("Object f1000 still exist :-(");
            }
        }
예제 #27
0
 public virtual void Test4()
 {
     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);
     function1.SetName("function login and logout");
     odb.Store(function1);
     NeoDatis.Odb.OID id1 = odb.GetObjectId(function1);
     NeoDatis.Odb.OID id2 = odb.GetObjectId(function2);
     NeoDatis.Odb.Test.VO.Login.Function function1bis = (NeoDatis.Odb.Test.VO.Login.Function
                                                         )odb.GetObjectFromId(id1);
     odb.Close();
     AssertEquals(function1.GetName(), function1bis.GetName());
     DeleteBase("getid.neodatis");
 }
예제 #28
0
        public virtual void Test2()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            odb.Store(new Class1("c1"));
            odb.Store(new Class1("c1"));
            odb.Store(new Class1("c2"));
            odb.Store(new Class1("c2"));
            odb.Store(new Class1("c3"));
            odb.Store(new Class1("c4"));
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
            // q.orderByAsc("name");
            NeoDatis.Odb.Objects <Class1> objects = odb.GetObjects <Class1>(q);
            AssertEquals(6, objects.Count);
            Println(objects);
            odb.Close();
        }
예제 #29
0
 public virtual void TestListSizeNotEqulTo1()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         string baseName = GetBaseName();
         SetUp(baseName);
         odb = Open(baseName);
         CriteriaQuery query           = new CriteriaQuery(Where.SizeNe("profile.functions", 1));
         NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query);
         AssertEquals(2, l.Count);
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
예제 #30
0
 /// <exception cref="System.Exception"></exception>
 public virtual void TestListSize0()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         odb = Open(BaseName);
         CriteriaQuery query           = new CriteriaQuery(Where.SizeEq("profile.functions", 0));
         NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query);
         AssertEquals(1, l.Count);
         User u = (User)l.GetFirst();
         AssertEquals("profile no function", u.GetProfile().GetName());
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
예제 #31
0
 public virtual void Test4RollbackXXXStores()
 {
     DeleteBase("rollback.neodatis");
     NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1");
     odb.Store(new Function("f1"));
     odb.Store(new Function("f2"));
     odb.Store(new Function("f3"));
     odb.Close();
     odb = Open("rollback.neodatis", "u1", "p1");
     for (int i = 0; i < 500; i++)
     {
         odb.Store(new Function("f3 - " + i));
     }
     odb.Rollback();
     odb.Close();
     odb = Open("rollback.neodatis", "u1", "p1");
     AssertEquals(3, odb.GetObjects <Function>().Count
                  );
     odb.Close();
 }
예제 #32
0
파일: UpdateTest.cs 프로젝트: ekicyou/pasta
        public virtual void TestUpdate()
		{
			try
			{
				DeleteBase(NewbieOdb);
				odb = Open(NewbieOdb);
				Driver marcelo = new Driver("marcelo");
				Car car = new Car("car1", 4, "ranger", marcelo);
				odb.Store(car);
				CriteriaQuery query = new CriteriaQuery(Where.Equal("driver.name", "marcelo"));
				Car newCar = (Car)odb.GetObjects<Car>(query).GetFirst();
				newCar.SetDriver(new Driver("dani"));
				odb.Store(newCar);
				odb.Commit();
				query = new CriteriaQuery(Where.Equal("driver.name", "dani"));
				AssertEquals(1, odb.GetObjects<Car>(query).Count);
				odb.Close();
				DeleteBase(NewbieOdb);
			}
			catch (System.Exception e)
			{
                throw e;
			}
		}
예제 #33
0
		public virtual void SetOdb(NeoDatis.Odb.ODB odb)
		{
			this.odb = odb;
		}
예제 #34
0
		/// <exception cref="System.Exception"></exception>
		public override void SetUp()
		{
			base.SetUp();
			DeleteBase(Testdbname);
			odb = Open(Testdbname);
		}
예제 #35
0
		/// <exception cref="System.Exception"></exception>
		private void CloseAndReopenDb()
		{
			odb.Close();
			odb = Open(Testdbname);
		}
예제 #36
0
파일: TestExt.cs 프로젝트: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void TestConcurrentObjectVersion3()
		{
			if (isLocal || (useSameVmOptimization && !testNewFeature))
			{
				return;
			}
			// LogUtil.allOn(true);
			DeleteBase("exta1");
			NeoDatis.Odb.ODB odb = Open("exta1");
			NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
			int version = odb.Ext().GetObjectVersion(oid);
			Println(version);
			odb.Close();
			int nbThreads = 100;
			NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
			int[] versions = new int[nbThreads];
			NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
				[nbThreads];
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				odbs[i] = Open("exta1");
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
				AssertEquals(1, versions[i]);
				AssertEquals("f1", functions[i].GetName());
			}
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				functions[i].SetName("function " + i);
				odbs[i].Store(functions[i]);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				Println("Function with name " + functions[i].GetName() + " has version " + versions
					[i]);
				odbs[i].Close();
				AssertEquals(i + 2, versions[i]);
				// Just to check the version number after commit
				odb = Open("exta1");
				int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
				Println("After commit = " + committedVersionNumber);
				AssertEquals(i + 2, committedVersionNumber);
				odb.Close();
			}
			NeoDatis.Odb.ODB odb4 = Open("exta1");
			// Check committed object value
			NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
				.GetObjectFromId(oid);
			AssertEquals("function " + (nbThreads - 1), f4.GetName());
			AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
			odb4.Close();
		}
예제 #37
0
파일: TestExt.cs 프로젝트: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void TestConcurrentObjectVersion2()
		{
			// LogUtil.allOn(true);
			int port = Port + 8;
			NeoDatis.Tool.IOUtil.DeleteFile(Directory + "exta1");
			NeoDatis.Odb.ODBServer server = NeoDatis.Odb.ODBFactory.OpenServer(port);
			server.StartServer(true);
			NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
				 + "exta1");
			NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
			int version = odb.Ext().GetObjectVersion(oid);
			Println(version);
			odb.Close();
			int nbThreads = 100;
			NeoDatis.Odb.ODB[] odbs = new NeoDatis.Odb.ODB[nbThreads];
			int[] versions = new int[nbThreads];
			NeoDatis.Odb.Test.VO.Login.Function[] functions = new NeoDatis.Odb.Test.VO.Login.Function
				[nbThreads];
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				odbs[i] = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1"
					);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				functions[i] = (NeoDatis.Odb.Test.VO.Login.Function)odbs[i].GetObjectFromId(oid);
				AssertEquals(1, versions[i]);
				AssertEquals("f1", functions[i].GetName());
			}
			// Open all Odbs and get the object
			for (int i = 0; i < nbThreads; i++)
			{
				functions[i].SetName("function " + i);
				odbs[i].Store(functions[i]);
				versions[i] = odbs[i].Ext().GetObjectVersion(oid);
				Println("Function with name " + functions[i].GetName() + " has version " + versions
					[i]);
				odbs[i].Close();
				AssertEquals(i + 2, versions[i]);
				// Just to check the version number after commit
				odb = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory + "exta1");
				int committedVersionNumber = odb.Ext().GetObjectVersion(oid);
				Println("After commit = " + committedVersionNumber);
				AssertEquals(i + 2, committedVersionNumber);
				odb.Close();
			}
			NeoDatis.Odb.ODB odb4 = NeoDatis.Odb.ODBFactory.OpenClient("localhost", port, Directory
				 + "exta1");
			// Check committed object value
			NeoDatis.Odb.Test.VO.Login.Function f4 = (NeoDatis.Odb.Test.VO.Login.Function)odb4
				.GetObjectFromId(oid);
			AssertEquals("function " + (nbThreads - 1), f4.GetName());
			AssertEquals(nbThreads + 1, odb4.Ext().GetObjectVersion(oid));
			odb4.Close();
			server.Close();
		}