Exemple #1
0
        public virtual void TestAndy2()
        {
            // LogUtil.allOn(true);
            NeoDatis.Odb.ODB        odb = Open("test-oid");
            NeoDatis.Odb.Test.Oid.B b1  = new NeoDatis.Odb.Test.Oid.B("b");
            NeoDatis.Odb.Test.Oid.A a1  = new NeoDatis.Odb.Test.Oid.A("a", b1);
            odb.Store(a1);
            long oida = ((NeoDatis.Odb.OID)odb.GetObjectId(a1)).GetObjectId();
            long oidb = ((NeoDatis.Odb.OID)odb.GetObjectId(b1)).GetObjectId();

            odb.Close();
            odb = Open("test-oid");
            NeoDatis.Odb.Test.Oid.A a2 = (NeoDatis.Odb.Test.Oid.A)odb.GetObjectFromId(new NeoDatis.Odb.Impl.Core.Oid.OdbObjectOID
                                                                                          (oida));
            NeoDatis.Odb.Test.Oid.B b2 = (NeoDatis.Odb.Test.Oid.B)odb.GetObjectFromId(new NeoDatis.Odb.Impl.Core.Oid.OdbObjectOID
                                                                                          (oidb));
            odb.Close();
            AssertNotNull(a2);
            AssertNotNull(b2);
            AssertNotNull(a2.GetB());
        }
Exemple #2
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5_byOid()
        {
            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 oid = odb.GetObjectId(f);
            try
            {
                odb.DeleteObjectWithId(oid);
                NeoDatis.Odb.OID id2 = odb.GetObjectId(f);
                Fail("The object has been deleted, the id should have been marked as deleted");
            }
            catch (NeoDatis.Odb.ODBRuntimeException)
            {
                odb.Close();
                DeleteBase(baseName);
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
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();
        }
Exemple #5
0
 /// <exception cref="System.Exception"></exception>
 public virtual void TestGetObjectId()
 {
     DeleteBase("extb");
     NeoDatis.Odb.ODB odb = null;
     odb = Open("extb");
     NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("Test Function"
                                                                                     );
     NeoDatis.Odb.OID         oid    = odb.Store(f);
     NeoDatis.Odb.ExternalOID extOid = odb.Ext().GetObjectExternalOID(f);
     AssertEquals(oid.GetObjectId(), extOid.GetObjectId());
     AssertEquals(odb.Ext().GetDatabaseId(), extOid.GetDatabaseId());
     odb.Close();
     odb = Open("extb");
     // Getting object via external oid
     NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
                                              .GetObjectFromId(extOid);
     NeoDatis.Odb.OID lastOid = odb.GetObjectId(f2);
     AssertEquals(oid, lastOid);
     AssertEquals(f.GetName(), f2.GetName());
     odb.Close();
 }
Exemple #6
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();
        }
Exemple #7
0
        public virtual void Test7()
        {
            string baseName = GetBaseName();

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

            odb.Store(f1);
            odb.Store(f2);
            odb.Store(f3);
            NeoDatis.Odb.OID id = odb.GetObjectId(f3);
            odb.Close();
            try
            {
                odb = Open(baseName);
                Function f3bis = (Function)
                                 odb.GetObjectFromId(id);
                odb.Delete(f3bis);
                odb.Close();
                odb = Open(baseName);
                NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>();
                odb.Close();
                AssertEquals(2, l.Count);
            }
            catch (NeoDatis.Odb.ODBRuntimeException)
            {
                odb.Close();
                DeleteBase(baseName);
            }
        }
Exemple #8
0
        public virtual void Test6()
        {
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            odb = Open(baseName);
            Function f = new 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");
            }
        }