示例#1
0
        public virtual void Test4()
        {
            string baseName = GetBaseName();
            int    n        = isLocal ? 1000 : 10;

            NeoDatis.Odb.ODB odb  = Open(baseName);
            long             size = odb.Count(new CriteriaQuery(typeof(Function)));

            for (int i = 0; i < n; i++)
            {
                Function login = new Function("login - " + (i + 1));
                odb.Store(login);
                AssertEquals(size + i + 1, odb.Count(new CriteriaQuery(typeof(Function))));
                Console.WriteLine(i);
            }
            // IStorageEngine engine = Dummy.getEngine(odb);
            odb.Commit();
            NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true);
            int j = 0;

            while (l.HasNext())
            {
                Console.WriteLine(" i=" + j);
                Function f = (Function)l.Next();
                odb.Delete(f);
                NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>();
                AssertEquals(size + n - (j + 1), l2.Count);
                j++;
            }
            odb.Commit();
            odb.Close();
            DeleteBase(baseName);
        }
示例#2
0
        public virtual void Test20()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            Function f0 = new Function(
                "1function0");

            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");

            odb.Store(f1);
            odb.Commit();
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Like("name", "func%")));
            AssertEquals(1, objects.Count);
            Function f2 = (Function)objects
                          .GetFirst();

            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(1, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects <Function>();
            AssertEquals(1, objects.Count);
        }
示例#3
0
        public virtual void Test5()
        {
            DeleteBase("t5.neodatis");
            NeoDatis.Odb.ODB odb         = Open("t5.neodatis");
            long             nbFunctions = odb.Count(new CriteriaQuery(typeof(Function)));
            long             nbProfiles  = odb.Count(new CriteriaQuery(typeof(Profile)));
            long             nbUsers     = odb.Count(new CriteriaQuery(typeof(User)));
            Function         login       = new Function
                                               ("login");
            Function logout = new Function
                                  ("logout");

            System.Collections.Generic.List <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(profile);
            odb.Commit();
            odb.Close();
            odb = Open("t5.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);
            odb.Close();
            AssertEquals(nbUsers + 1, users.Count);
            AssertEquals(nbProfiles + 1, profiles.Count);
            AssertEquals(nbFunctions + 2, functions.Count);
        }
示例#4
0
        /// <exception cref="System.Exception"></exception>
        public override void SetUp()
        {
            base.SetUp();
            DeleteBase("t-school.neodatis");
            NeoDatis.Odb.ODB odb = Open("t-school.neodatis");
            NeoDatis.Odb.Objects <Student> students = odb.GetObjects <Student>(true);
            int    numStudents     = students.Count;
            Course computerScience = new Course
                                         ("Computer Science");
            Teacher teacher = new Teacher
                                  ("Jeremias", "Java");
            Discipline dw1 = new Discipline
                                 ("Des. Web 1", 3);
            Discipline @is = new Discipline
                                 ("Intranet/Segurança", 4);
            Student std1 = new Student
                               (20, computerScience, new System.DateTime(), "1cs", "Brenna");
            History h1 = new History(
                new System.DateTime(), dw1, 0, teacher);
            History h2 = new History(
                new System.DateTime(), @is, 0, teacher);

            std1.AddHistory(h1);
            std1.AddHistory(h2);
            odb.Store(std1);
            odb.Commit();
            odb.Close();
            odb      = Open("t-school.neodatis");
            students = odb.GetObjects <Student>(true);
            odb.Close();
            AssertEquals(numStudents + 1, students.Count);
        }
示例#5
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();
        }
示例#6
0
        public virtual void TestCompositeCollection4()
        {
            DeleteBase("t5.neodatis");
            NeoDatis.Odb.ODB odb = Open("t5.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");

            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.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(nbProfiles + 1, profiles.Count);
            AssertEquals(nbFunctions + 2, functions.Count);
        }
示例#7
0
        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);
        }
示例#8
0
        /// <summary>
        /// Stores on object and close database then Stores another object, commits
        /// without closing.
        /// </summary>
        /// <remarks>
        /// Stores on object and close database then Stores another object, commits
        /// without closing. Loads the object, gets its oid and delete by oid. In the
        /// case the commit has no write actions. And there was a bug : when there is
        /// no write actions, the commit process is much more simple! but in this the
        /// cache was not calling the transaction.clear and this was a reason for
        /// some connected/unconnected zone problem! (step14 of the turotial.)
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test20()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
                "1function0");
            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            odb.Commit();
            NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                              .Like("name", "func%")));
            AssertEquals(1, objects.Count);
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
                                                     .GetFirst();
            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
            AssertEquals(1, objects.Count);
        }
示例#9
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestObjectVersionWithoutClose2()
        {
            DeleteBase("ext2");
            NeoDatis.Odb.ODB odb = Open("ext2");
            int  size            = 1000;
            long updateDate      = 0;
            long creationDate    = 0;

            // LogUtil.allOn(true);
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f"));
            odb.Close();
            odb = Open("ext2");
            Java.Lang.Thread.Sleep(100);
            // LogUtil.allOn(true);
            for (int i = 0; i < size; i++)
            {
                // odb = open("ext");
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oid);
                f.SetName("f" + i);
                odb.Store(f);
                odb.Commit();
            }
            odb.Close();
        }
示例#10
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestObjectVersionWithoutClose()
        {
            DeleteBase("extd");
            NeoDatis.Odb.ODB odb = Open("extd");
            int  size            = 1000;
            long updateDate      = 0;
            long creationDate    = 0;

            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f"));
            odb.Close();
            odb = Open("extd");
            Java.Lang.Thread.Sleep(100);
            for (int i = 0; i < size; i++)
            {
                // odb = open("ext");
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                        GetObjectFromId(oid);
                int version = odb.Ext().GetObjectVersion(oid);
                // System.out.println("i="+i + " - v="+ version+ " - oid="+oid);
                AssertEquals(i + 1, version);
                f.SetName("f" + i);
                // update the object, should increase the version number
                odb.Store(f);
                odb.Commit();
            }
            odb.Close();
        }
示例#11
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestInsert()
        {
            DeleteBase("tinterfaces.neodatis");
            NeoDatis.Odb.ODB     odb = Open("tinterfaces.neodatis");
            ObjectWithInterfaces owi = new ObjectWithInterfaces("Ol√° chico");

            odb.Store(owi);
            odb.Commit();
            odb.Close();
        }
示例#12
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestInsertWithCommitsSimpleObject()
        {
            DeleteBase("commits");
            NeoDatis.Odb.ODB odb = null;
            int size             = isLocal ? 10000 : 3000;
            int commitInterval   = 1;

            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();
                    }
                }
            }
            finally
            {
                // println("commiting "+i);
                odb.Close();
            }
            odb = Open("commits");
            NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                 ));
            int nbObjects = objects.Count;

            System.Collections.IDictionary      map      = new NeoDatis.Tool.Wrappers.Map.OdbHashMap();
            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 != null)
                {
                    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);
        }
示例#13
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estJ1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            odb.Store(GetInstance("f1"));
            odb.Store(GetInstance("f2"));
            odb.Store(GetInstance("f3"));
            odb.Commit();
            object o = GetInstance("f4");

            odb.Store(o);
            odb.Delete(o);
        }
示例#14
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estK1()
        {
            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);

            odb.Delete(o);
            odb.Rollback();
        }
示例#15
0
 /// <exception cref="System.Exception"></exception>
 public virtual void T1estN1()
 {
     test.DeleteBase("acid1");
     NeoDatis.Odb.ODB odb = test.Open("acid1");
     for (int i = 0; i < 10; i++)
     {
         odb.Store(GetInstance("f" + i));
     }
     odb.Close();
     odb = test.Open("acid1");
     odb.Store(GetInstance("f1000"));
     odb.Commit();
 }
示例#16
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test4()
        {
            string baseName = GetBaseName();
            int    n        = isLocal ? 1000 : 10;

            NeoDatis.Odb.ODB odb  = Open(baseName);
            long             size = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
                                                                                                          NeoDatis.Odb.Test.VO.Login.Function)));

            for (int i = 0; i < n; i++)
            {
                NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                                ("login - " + (i + 1));
                odb.Store(login);
                AssertEquals(size + i + 1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            }
            // IStorageEngine engine = Dummy.getEngine(odb);
            odb.Commit();
            NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                           ), true);
            int j = 0;

            while (l.HasNext())
            {
                // println("i="+i);
                NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.Next
                                                            ();
                odb.Delete(f);
                NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                ));
                AssertEquals(size + n - (j + 1), l2.Count);
                j++;
            }
            odb.Commit();
            odb.Close();
            DeleteBase(baseName);
        }
示例#17
0
 /// <summary>Insert different objects on database</summary>
 /// <exception cref="System.Exception">System.Exception</exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public virtual void TestInsert()
 {
     DeleteBase(NewbieOdb);
     odb = Open(NewbieOdb);
     NeoDatis.Odb.Test.Newbie.VO.Driver marcelo = new NeoDatis.Odb.Test.Newbie.VO.Driver
                                                      ("marcelo");
     NeoDatis.Odb.Test.Newbie.VO.Car car = new NeoDatis.Odb.Test.Newbie.VO.Car("car1",
                                                                               4, "ranger", marcelo);
     NeoDatis.Odb.Test.Newbie.VO.Car car1 = new NeoDatis.Odb.Test.Newbie.VO.Car("car2"
                                                                                , 2, "porche");
     NeoDatis.Odb.Test.Newbie.VO.Car car2 = new NeoDatis.Odb.Test.Newbie.VO.Car("car3"
                                                                                , 2, "fusca");
     NeoDatis.Odb.Test.Newbie.VO.Car car3 = new NeoDatis.Odb.Test.Newbie.VO.Car("car4"
                                                                                , 4, "opala");
     NeoDatis.Odb.Test.Newbie.VO.Car car4 = new NeoDatis.Odb.Test.Newbie.VO.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 cars = odb.GetObjects(typeof(NeoDatis.Odb.Test.Newbie.VO.Car
                                                           ));
         AssertEquals("The objects weren't added correctly", 5, cars.Count);
         // find for a specific car object
         NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                         (typeof(NeoDatis.Odb.Test.Newbie.VO.Car), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                         .Equal("name", "car1"));
         cars = odb.GetObjects(query);
         AssertEquals("The objects couldn't be found correctly", 1, cars.Count);
         // find for a specific composition
         query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(NeoDatis.Odb.Test.Newbie.VO.Car
                                                                                ), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("driver.name", "marcelo"));
         cars = odb.GetObjects(query);
         AssertEquals("The objects couldn't be found correctly", 2, cars.Count);
         odb.Commit();
         odb.Close();
         DeleteBase(NewbieOdb);
     }
     catch (System.Exception e)
     {
         Sharpen.Runtime.PrintStackTrace(e);
     }
 }
示例#18
0
 /// <exception cref="System.Exception"></exception>
 public virtual void T1estN3()
 {
     NeoDatis.Odb.ODB odb = test.Open("acid1");
     if (simpleObject)
     {
         NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "new name")));
         odb.Delete(objects.GetFirst());
     }
     else
     {
         NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(new CriteriaQuery(Where.Equal("name", "new name")));
         odb.Delete(objects.GetFirst());
     }
     odb.Commit();
 }
示例#19
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestInsertWithCommitsComplexObject()
        {
            DeleteBase("commits");
            NeoDatis.Odb.ODB odb = null;
            int size             = isLocal ? 5300 : 500;
            int commitInterval   = 400;

            try
            {
                odb = Open("commits");
                for (int i = 0; i < size; i++)
                {
                    odb.Store(GetInstance(i));
                    if (i % commitInterval == 0)
                    {
                        odb.Commit();
                    }
                    // println("commiting "+i);
                    if (i % 100 == 0 && !isLocal)
                    {
                        Println(i);
                    }
                }
            }
            finally
            {
                odb.Close();
            }
            odb = Open("commits");
            NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                               ));
            NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                                  ));
            NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                   ));
            int nbUsers     = users.Count;
            int nbProfiles  = profiles.Count;
            int nbFunctions = functions.Count;

            odb.Close();
            DeleteBase("commits");
            Println("Nb users=" + nbUsers);
            Println("Nb profiles=" + nbProfiles);
            Println("Nb functions=" + nbFunctions);
            AssertEquals(size, nbUsers);
            AssertEquals(size, nbProfiles);
            AssertEquals(size * 2, nbFunctions);
        }
示例#20
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestCompositeCollection2DifferentObjects()
        {
            DeleteBase("ti1.neodatis");
            NeoDatis.Odb.ODB odb = Open("ti1.neodatis");
            int nbUsers          = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), true).Count;
            int nbProfiles       = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile), true)
                                   .Count;
            int nbFunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true
                                             ).Count;

            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");
            NeoDatis.Odb.Test.VO.Login.Function disconnect = new NeoDatis.Odb.Test.VO.Login.Function
                                                                 ("disconnect");
            System.Collections.IList list = new System.Collections.ArrayList();
            list.Add(login);
            list.Add(logout);
            System.Collections.IList list2 = new System.Collections.ArrayList();
            list.Add(login);
            list.Add(logout);
            NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
                                                              ("operator 1", list);
            NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile
                                                              ("operator 2", list2);
            NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
                                                                                       , "*****@*****.**", profile1);
            NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("A√°sa Galv√£o Smadja"
                                                                                        , "*****@*****.**", profile2);
            odb.Store(user);
            odb.Store(userB);
            odb.Commit();
            NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                   ), true);
            NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                                  ), true);
            NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                               ), true);
            odb.Close();
            // assertEquals(nbUsers+2,users.size());
            NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
                                                        ();
            AssertEquals(user.ToString(), user2.ToString());
            AssertEquals(nbProfiles + 2, profiles.Count);
            AssertEquals(nbFunctions + 2, functions.Count);
            DeleteBase("ti1.neodatis");
        }
示例#21
0
        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);
            }
        }
示例#22
0
        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);
			}
		}
示例#23
0
 /// <summary>Create, store and try retrieve the object without default constructor</summary>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual void TestUseInstanceHelper()
 {
     NeoDatis.Odb.OdbConfiguration.SetEnableEmptyConstructorCreation(false);
     try
     {
         NeoDatis.Odb.ClassRepresentation carRepresentation = odb.GetClassRepresentation(typeof(
                                                                                             NeoDatis.Odb.Test.Instantiationhelper.Car));
         // create a db and store a object that has not default constructor
         NeoDatis.Odb.Test.Instantiationhelper.Car car = new NeoDatis.Odb.Test.Instantiationhelper.Car
                                                             ("Ranger", 2006);
         odb.Store(car);
         odb.Commit();
         CloseAndReopenDb();
         NeoDatis.Odb.Objects cars;
         try
         {
             CheckCarRetrieval();
             Fail("Expected exception");
         }
         catch (NeoDatis.Odb.ODBRuntimeException)
         {
         }
         // expected
         CloseAndReopenDb();
         carRepresentation.AddInstantiationHelper(new _InstantiationHelper_76());
         CheckCarRetrieval();
         CloseAndReopenDb();
         carRepresentation.RemoveInstantiationHelper();
         carRepresentation.AddParameterHelper(new _ParameterHelper_84());
         try
         {
             CheckCarRetrieval();
             Fail("Expected Exception");
         }
         catch (NeoDatis.Odb.ODBRuntimeException)
         {
         }
         // expected
         odb.Close();
     }
     finally
     {
         NeoDatis.Odb.OdbConfiguration.SetEnableEmptyConstructorCreation(true);
     }
 }
示例#24
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();
 }
示例#25
0
        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();
        }
示例#26
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5()
        {
            DeleteBase("t5.neodatis");
            NeoDatis.Odb.ODB odb         = Open("t5.neodatis");
            long             nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.VO.Login.Function)));
            long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                            (typeof(NeoDatis.Odb.Test.VO.Login.Profile)));
            long nbUsers = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
                                         typeof(NeoDatis.Odb.Test.VO.Login.User)));

            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.IList list = new System.Collections.ArrayList();
            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 olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
                                                                                          , "*****@*****.**", profile);
            NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
                                                                                       , "*****@*****.**", profile);
            odb.Store(olivier);
            odb.Store(profile);
            odb.Commit();
            odb.Close();
            odb = Open("t5.neodatis");
            NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                               ), true);
            NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                                  ), true);
            NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                   ), true);
            odb.Close();
            AssertEquals(nbUsers + 1, users.Count);
            AssertEquals(nbProfiles + 1, profiles.Count);
            AssertEquals(nbFunctions + 2, functions.Count);
        }
示例#27
0
        /// <exception cref="System.Exception"></exception>
        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());
        }
示例#28
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test6()
        {
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function1"
                                                                                            );
            odb.Store(f);
            NeoDatis.Odb.OID id = odb.GetObjectId(f);
            odb.Commit();
            try
            {
                odb.Delete(f);
                odb.GetObjectFromId(id);
                Fail("The object has been deleted, the id should have been marked as deleted");
            }
            catch (NeoDatis.Odb.ODBRuntimeException)
            {
                odb.Close();
                DeleteBase("t-delete1.neodatis");
            }
        }
示例#29
0
        /// <summary>
        /// Opens a connection C1, then create the index in another connection C2 and
        /// then stores the object in connection C1
        /// </summary>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void TestCreateIndexInOtherConnectionNoClose()
        {
            if (isLocal || !testNewFeature)
            {
                return;
            }
            string baseName = GetBaseName();

            DeleteBase(baseName);
            NeoDatis.Odb.ODB odb1 = Open(baseName);
            NeoDatis.Odb.ODB odb2 = Open(baseName);
            NeoDatis.Odb.ClassRepresentation clazz = odb2.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3
                                                                                        ));
            string[] indexFields1 = new string[] { "i1" };
            clazz.AddUniqueIndexOn("index1", indexFields1, true);
            odb2.Commit();
            for (int i = 0; i < 10; i++)
            {
                NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3
                                                                (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime
                                                                    (), new System.DateTime());
                odb1.Store(io);
            }
            odb1.Close();
            NeoDatis.Odb.ODB odb             = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                   (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where
                                                   .Equal("i1", 1));
            NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> iis = odb.GetObjects
                                                                                    (q);
            odb.Close();
            odb2.Close();
            AssertEquals(1, iis.Count);
            AssertTrue(q.GetExecutionPlan().UseIndex());
            DeleteBase(baseName);
        }
示例#30
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();
        }
示例#31
0
 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;
     }
 }
示例#32
0
        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;
			}
		}