Example #1
0
        public override void SetUp()
        {
            base.SetUp();
            DeleteBase(BaseName);
            NeoDatis.Odb.ODB odb   = Open(BaseName);
            long             start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            int size = 50;

            for (int i = 0; i < size; i++)
            {
                TestClass tc = new TestClass
                                   ();
                tc.SetBigDecimal1(new System.Decimal(i));
                tc.SetBoolean1(i % 3 == 0);
                tc.SetChar1((char)(i % 5));
                tc.SetDate1(new System.DateTime(1000 + start + i));
                tc.SetDouble1(((double)(i % 10)) / size);
                tc.SetInt1(size - i);
                tc.SetString1("test class " + i);
                odb.Store(tc);
            }
            TestClass testClass = new TestClass
                                      ();

            testClass.SetBigDecimal1(new System.Decimal(190.95));
            testClass.SetBoolean1(true);
            testClass.SetChar1('s');
            correctDate = new System.DateTime();
            testClass.SetDate1(correctDate);
            testClass.SetDouble1(190.99);
            testClass.SetInt1(190);
            testClass.SetString1("test class with values");
            odb.Store(testClass);
            TestClass testClass2 = new TestClass
                                       ();

            testClass2.SetBigDecimal1(0);
            testClass2.SetBoolean1(true);
            testClass2.SetChar1('s');
            correctDate = new System.DateTime();
            testClass2.SetDate1(correctDate);
            testClass2.SetDouble1(191.99);
            testClass2.SetInt1(1901);
            testClass2.SetString1("test class with null BigDecimal");
            odb.Store(testClass2);
            TestClass testClass3 = new TestClass
                                       ();

            odb.Store(testClass3);
            odb.Close();
        }
Example #2
0
        public virtual void Test6()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            int size             = 5;

            for (int i = 0; i < size; i++)
            {
                odb.Store(new Function("f1"));
            }
            odb.Store(new Function(null));
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(Where.IsNull("name"));
            // q.orderByAsc("name");
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(q, true, 0, 10);
            System.Collections.IList        l       = new System.Collections.Generic.List <Function
                                                                                           >(objects);
            AssertEquals(1, l.Count);
            odb.Close();
            odb = Open(baseName);
            q   = new CriteriaQuery(Where.IsNull("name"));
            q.OrderByAsc("name");
            objects = odb.GetObjects <Function>(q, true, 0, 10);
            l       = new System.Collections.Generic.List <Function>(objects
                                                                     );
            AssertEquals(1, l.Count);
            odb.Close();
            odb = Open(baseName);
            q   = new CriteriaQuery(Where.IsNull("name"));
            q.OrderByDesc("name");
            objects = odb.GetObjects <Function>(q, true, 0, 10);
            l       = new System.Collections.Generic.List <Function>(objects
                                                                     );
            AssertEquals(1, l.Count);
            odb.Close();
        }
Example #3
0
 // To test if triggers are called on recursive objects
 /// <exception cref="System.Exception"></exception>
 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);
 }
Example #4
0
 /// <summary>Test select objects that are not yet commited</summary>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual void TestSelectUnCommitedObject2()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         DeleteBase(BaseName);
         odb = Open(BaseName);
         for (int i = 0; i < 4; i++)
         {
             odb.Store(new NeoDatis.Odb.Test.VO.Login.User("user" + i, "email" + i, new NeoDatis.Odb.Test.VO.Login.Profile
                                                               ("profile" + i, new NeoDatis.Odb.Test.VO.Login.Function("function" + i))));
         }
         odb.Close();
         // reopen the database
         odb = Open(BaseName);
         // stores a new function
         odb.Store(new NeoDatis.Odb.Test.VO.Login.User("uncommited user", "uncommied email"
                                                       , new NeoDatis.Odb.Test.VO.Login.Profile("uncommiedt profile", new NeoDatis.Odb.Test.VO.Login.Function
                                                                                                    ("uncommited function"))));
         NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
                                                            ));
         AssertEquals(5, users.Count);
         NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                ));
         AssertEquals(5, functions.Count);
         NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                               ));
         AssertEquals(5, profiles.Count);
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
             DeleteBase(BaseName);
         }
     }
 }
Example #5
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestCriteriaQueryQueryWithValueInList()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            Profile          p0  = new Profile("profile0"
                                               );

            p0.AddFunction(null);
            p0.AddFunction(new Function("f1"));
            p0.AddFunction(new Function("f2"));
            Profile p1 = new Profile("profile1"
                                     );

            p1.AddFunction(null);
            p1.AddFunction(new Function("f12"));
            p1.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 = (Function)
                             odb.GetObjects <Function> (new CriteriaQuery(Where.Equal("name", "f2"))).GetFirst();
            CriteriaQuery query = odb.CriteriaQuery(typeof(
                                                        User), Where.Contain
                                                        ("profile.functions", f2bis));

            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query);
            AssertEquals(1, l.Count);
            user = (User)l.GetFirst();
            AssertEquals("The user", user.GetName());
            odb.Close();
        }
Example #6
0
        public virtual void Test2()
        {
            NeoDatis.Odb.ODB odb = Open(FileName);
            int nbProfiles       = odb.GetObjects <Profile>().Count;

            NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("profile.name", "profile 10"));
            NeoDatis.Odb.Objects <User>    l     = odb.GetObjects <User>(query);
            int size = l.Count;

            AssertFalse(l.Count == 0);
            User u = (User)l.GetFirst();

            AssertEquals("profile 10", u.GetProfile().GetName());
            Profile p2      = u.GetProfile();
            string  newName = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs().ToString() +
                              "-";

            p2.SetName(newName);
            odb.Store(p2);
            odb.Close();
            odb = Open(FileName);
            l   = odb.GetObjects <User>(query);
            AssertTrue(l.Count == size - 1);
            if (!isLocal)
            {
                query = new CriteriaQuery(Where.Equal("profile.name", newName));
            }
            else
            {
                query = new _SimpleNativeQuery_134(newName);
            }
            l = odb.GetObjects <User> (query);
            AssertFalse(l.Count == 0);
            Objects <Profile> l2 = odb.GetObjects <Profile>(false);

            AssertEquals(nbProfiles, l2.Count);
            odb.Close();
        }
Example #7
0
        public virtual void Test18()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            DeleteBase(baseName);
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");
            Function f2 = new Function(
                "function2");
            Function f3 = new Function(
                "function2");

            NeoDatis.Odb.OID oid1 = odb.Store(f1);
            NeoDatis.Odb.OID oid2 = odb.Store(f2);
            NeoDatis.Odb.OID oid3 = odb.Store(f3);
            AssertEquals(3, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            odb.Close();
            odb = Open(baseName);
            odb.DeleteObjectWithId(oid2);
            AssertEquals(2, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            // odb.store(f1);
            odb.Store(new Function("f11"));
            odb.Store(new Function("f12"));
            odb.Store(new Function("f13"));
            // odb.store(f3);
            AssertEquals(5, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(5, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            DeleteBase(baseName);
        }
Example #8
0
        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();
        }
Example #9
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     try
     {
         DeleteBase("mydb.neodatis");
         // Open the database
         odb = Open("mydb.neodatis");
         long t0       = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         int  nRecords = 100000;
         for (int i = 0; i < nRecords; i++)
         {
             NeoDatis.Odb.Test.Performance.Class1 ao = new NeoDatis.Odb.Test.Performance.Class1
                                                           (189, "csdcsdc");
             odb.Store(ao);
         }
         odb.Close();
         long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         odb = Open("mydb.neodatis");
         NeoDatis.Odb.Objects ssss = odb.GetObjects(typeof(NeoDatis.Odb.Test.Performance.Class1
                                                           ));
         long t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
         Println("Elapsed time for inserting " + nRecords + " records: " + (t1 - t0) + " / select = "
                 + (t2 - t1));
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
 }
Example #10
0
        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);
            }
        }
Example #11
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestIndexFail()
        {
            string baseName = GetBaseName();

            DeleteBase(baseName);
            NeoDatis.Odb.ODB @base     = Open(baseName);
            string           indexName = "index1";

            NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3
                                                                                         ));
            string[] indexFields1 = new string[] { "i1", "i2", "i3" };
            clazz.AddUniqueIndexOn(indexName, indexFields1, true);
            @base.Close();
            @base = Open(baseName);
            NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3
                                                            (1, 2, 3, "1", "2", "3", new System.DateTime(), new System.DateTime(), new System.DateTime
                                                                ());
            @base.Store(io);
            try
            {
                NeoDatis.Odb.Test.Index.IndexedObject3 io2 = new NeoDatis.Odb.Test.Index.IndexedObject3
                                                                 (1, 2, 3, "1", "2", "3", new System.DateTime(), new System.DateTime(), new System.DateTime
                                                                     ());
                @base.Store(io2);
            }
            catch (System.Exception e)
            {
                AssertTrue(e.Message.IndexOf(indexName) != -1);
            }
            // println(e.getMessage());
            @base.Close();
            @base = Open(baseName);
            NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> oo3 = @base.GetObjects
                                                                                    (typeof(NeoDatis.Odb.Test.Index.IndexedObject3));
            @base.Close();
            AssertEquals(0, oo3.Count);
            DeleteBase(baseName);
        }
Example #12
0
        /// <summary>Check if objects of list are known by ODB</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test6()
        {
            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.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                   (typeof(NeoDatis.Odb.Test.Query.Values.Handler));
            NeoDatis.Odb.Objects objects = odb.GetObjects(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.Test.Query.Values.Handler h = (NeoDatis.Odb.Test.Query.Values.Handler
                                                        )objects.GetFirst();
            NeoDatis.Odb.Test.Query.Values.Parameter parameter = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                                  )h.GetListOfParameters()[0];
            AssertEquals("value 0", parameter.GetValue());
            NeoDatis.Odb.OID oid = odb.GetObjectId(parameter);
            AssertNotNull(oid);
            odb.Close();
        }
Example #13
0
        /// <summary>Using Object representation instead of real object</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test3()
        {
            int sublistSize = 10000;

            DeleteBase("valuesSubList3");
            NeoDatis.Odb.ODB odb = Open("valuesSubList3");
            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", 9990
                                                                                                                  , 5, true);
            q.SetReturnInstance(false);
            NeoDatis.Odb.Values values = odb.GetValues(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens from 40000 : " + (end - start));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(5, sublist.Count);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                             )sublist[0];
            AssertEquals("value 9990", nnoi.GetValueOf("value"));
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi2 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                              )sublist[4];
            AssertEquals("value 9994", nnoi2.GetValueOf("value"));
            odb.Close();
        }
Example #14
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestWithUserAndPassword()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName, "user", "password");
            odb.Store(new NeoDatis.Odb.Test.Update.MyObject(10, "t1"));
            odb.Close();
            try
            {
                odb = Open(baseName);
                Fail("it should have stop for invalid user/password");
            }
            catch (NeoDatis.Odb.ODBAuthenticationRuntimeException)
            {
            }
            // odb.rollback();
            // odb.close();
            // e.printStackTrace();
            odb = Open(baseName, "user", "password");
            AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.Update.MyObject)).Count);
            odb.Close();
            DeleteBase(baseName);
        }
Example #15
0
        public virtual void Test5()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB odb = Open("valuesA2");
            int size             = isLocal ? 100000 : 1000;

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                   ();
                tc1.SetInt1(45);
                odb.Store(tc1);
            }
            odb.Close();
            odb = Open("valuesA2");
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Count("nb objects"));
            Println(values);
            NeoDatis.Odb.ObjectValues ov = values.NextValues();
            odb.Close();
            AssertEquals(size, ov.GetByAlias("nb objects"));
            AssertEquals(1, values.Count);
        }
Example #16
0
        public virtual void Test7()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB odb = Open("valuesA2");
            int size             = isLocal ? 100000 : 1000;

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                   ();
                tc1.SetInt1(i);
                odb.Store(tc1);
            }
            odb.Close();
            odb = Open("valuesA2");
            decimal nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
                                                                                               NeoDatis.Odb.Test.VO.Attribute.TestClass), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                                           .Equal("int1", 2)));

            Println(nb);
            odb.Close();
            AssertEquals(1, nb);
        }
Example #17
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test4Sort()
        {
            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,int1");
            NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass> (aq, true, -1, -1);
            // println(l);
            AssertEquals(48, l.Count);
            TestClass testClass = l.GetFirst();

            AssertEquals("test class 9", testClass.GetString1());
            odb.Close();
        }
Example #18
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("map-with-collections");
     NeoDatis.Odb.ODB odb = null;
     odb = Open("map-with-collections");
     NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject o = new NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject
                                                              ("test");
     System.Collections.ICollection c = new System.Collections.ArrayList();
     c.Add("ola");
     o.GetMap().Add("c", c);
     odb.Store(o);
     odb.Close();
     odb = Open("map-with-collections");
     NeoDatis.Odb.Objects os = odb.GetObjects(typeof(NeoDatis.Odb.Test.Arraycollectionmap.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(o.GetMap().Count, mmo.GetMap().Count);
     AssertEquals(o.GetMap()["c"], mmo.GetMap()["c"]);
 }
Example #19
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     NeoDatis.Odb.ODB odb = Open("criteria.neodatis");
     NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                  (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                  .Or().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "function 2")).Add
                                                                      (NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "function 3")));
     NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1);
     AssertEquals(2, l.Count);
     NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst
                                                 ();
     AssertEquals("function 2", f.GetName());
     odb.Close();
 }
Example #20
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test3()
 {
     DeleteBase("t1u2.neodatis");
     NeoDatis.Odb.ODB odb = Open("t1u2.neodatis");
     NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
                                                     (null);
     odb.Store(login);
     odb.Close();
     odb   = Open("t1u2.neodatis");
     login = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                     (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                     .IsNull("name"))).GetFirst();
     AssertTrue(login.GetName() == null);
     login.SetName("login");
     odb.Store(login);
     odb.Close();
     odb   = Open("t1u2.neodatis");
     login = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
                                                                        )).GetFirst();
     AssertTrue(login.GetName().Equals("login"));
     odb.Close();
     DeleteBase("t1u2.neodatis");
 }
Example #21
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("valuesA1");
     NeoDatis.Odb.ODB odb = Open("valuesA1");
     NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                          ();
     for (int i = 0; i < 10; i++)
     {
         handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value"
                                                                           + i));
     }
     odb.Store(handler);
     odb.Close();
     odb = Open("valuesA1");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Field("parameters"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     System.Collections.IList  l  = (System.Collections.IList)ov.GetByAlias("parameters"
                                                                            );
     AssertEquals(10, l.Count);
     odb.Close();
 }
Example #22
0
        public virtual void Test11()
        {
            string baseName = GetBaseName();

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

            odb.Store(f1);
            odb.Close();
            odb = Open(baseName);
            Function f1bis = (Function)odb.GetObjects <Function>().GetFirst();

            odb.Delete(f1bis);
            odb.Store(new Function("last function"));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(size + 1, odb.GetObjects <Function>().Count);
            odb.Close();
        }
Example #23
0
        public virtual void Test2()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            System.Collections.Generic.IList <Profile> profiles = new
                                                                  System.Collections.Generic.List <Profile>();
            profiles.Add(new Profile("p1", new Function("f1")));
            profiles.Add(new Profile("p2", new Function("f2")));
            ClassB cb = new ClassB("name", profiles);

            odb.Store(cb);
            odb.Close();
            odb = Open(baseName);
            Profile       p     = (Profile)odb.GetObjects <Profile>().GetFirst();
            CriteriaQuery query = odb.CriteriaQuery(typeof(ClassB), Where
                                                    .Contain("profiles", p));

            NeoDatis.Odb.Objects <ClassB> l = odb.GetObjects <ClassB>(
                query);
            odb.Close();
            AssertEquals(1, l.Count);
        }
Example #24
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estI1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            odb.Store(GetInstance("f1"));
            odb.Store(GetInstance("f2"));
            odb.Store(GetInstance("f3"));
            odb.Close();
            odb = test.Open("acid1");
            object o = GetInstance("f4");

            odb.Store(o);
            odb.Delete(o);
        }
Example #25
0
 public virtual void Test2()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = Open("get.neodatis");
     // println("++++TestNQQuery.test2:"+odb.getObjects
     // (Function.class,true));
     NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(new _SimpleNativeQuery_89());
     odb.Close();
     AssertFalse(l.Count == 0);
     AssertEquals(1, l.Count);
 }
Example #26
0
        public virtual void Test1()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("My Function"
                                                                                     ));
            odb.Close();
            NeoDatis.Tool.IOUtil.DeleteFile(baseName);
            string soid = oid.OidToString();

            NeoDatis.Odb.OID oid2 = NeoDatis.Odb.Core.Oid.OIDFactory.OidFromString(soid);
            AssertEquals(oid, oid2);
        }
Example #27
0
        public virtual void Test2()
        {
            DeleteBase("nullo");
            NeoDatis.Odb.Test.Nullobject.GenericClass gc = new NeoDatis.Odb.Test.Nullobject.GenericClass
                                                               (null);
            NeoDatis.Odb.ODB odb = Open("nullo");
            odb.Store(gc);
            odb.Close();
            odb = Open("nullo");
            NeoDatis.Odb.Objects <GenericClass>       objects = odb.GetObjects <GenericClass>();
            NeoDatis.Odb.Test.Nullobject.GenericClass gc2     = (NeoDatis.Odb.Test.Nullobject.GenericClass
                                                                 )objects.GetFirst();
            gc2.SetObject("Ola");
            odb.Store(gc2);
            odb.Close();
            odb     = Open("nullo");
            objects = odb.GetObjects <GenericClass>();
            AssertEquals(1, objects.Count);
            GenericClass gc3 = (GenericClass)objects.GetFirst();

            AssertEquals("Ola", gc3.GetObject());
            odb.Close();
        }
Example #28
0
        public virtual void Test5()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB  odb   = Open("get.neodatis");
            SimpleNativeQuery query = new _SimpleNativeQuery_139();

            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query, true, 5, 6);
            odb.Close();
            AssertFalse(l.Count == 0);
            AssertEquals(1, l.Count);
        }
Example #29
0
        public virtual void TestGetObects3()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("Test"));
            NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.Function> functions = odb.GetObjects
                                                                                       (typeof(NeoDatis.Odb.Test.VO.Login.Function));
            System.Collections.Generic.IEnumerator <NeoDatis.Odb.Test.VO.Login.Function> iterator
                = functions.GetEnumerator();
            NeoDatis.Odb.Test.VO.Login.Function f = iterator.Current;
            odb.Close();
            AssertEquals(1, functions.Count);
        }
Example #30
0
        public virtual void Test4()
        {
            NeoDatis.Odb.ODB odb = Open("map.neodatis");
            long             n   = odb.Count(new CriteriaQuery(typeof(
                                                                   NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));

            NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
                                                       (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
                                                       .Equal("name", "test2"));
            NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query);
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                               )l.GetFirst();
            dictionnary.SetMap(null);
            odb.Store(dictionnary);
            odb.Close();
            odb = Open("map.neodatis");
            AssertEquals(n, odb.Count(new CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
            NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
                                                                       )odb.GetObjects <Dictionnary>(query).GetFirst();
            AssertEquals(null, dic.GetMap());
            odb.Close();
        }
Example #31
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);
			}
		}
Example #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;
			}
		}