Пример #1
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			DeleteBase("null.neodatis");
			NeoDatis.Odb.ODB odb = Open("null.neodatis");
			NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli"
				, "oli@sdsadf", null);
			NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine"
				, "karine@sdsadf", null);
			NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null, 
				null, null);
			odb.Store(user1);
			odb.Store(user2);
			odb.Store(user3);
			odb.Close();
			odb = Open("null.neodatis");
			NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), 
				true);
			AssertEquals(3, l.Count);
			user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals("oli", user1.GetName());
			AssertEquals("oli@sdsadf", user1.GetEmail());
			AssertEquals(null, user1.GetProfile());
			user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals("karine", user2.GetName());
			AssertEquals("karine@sdsadf", user2.GetEmail());
			AssertEquals(null, user2.GetProfile());
			user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals(null, user3.GetName());
			AssertEquals(null, user3.GetEmail());
			AssertEquals(null, user3.GetProfile());
			odb.Close();
			DeleteBase("null.neodatis");
		}
Пример #2
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("null.neodatis");
     NeoDatis.Odb.ODB odb = Open("null.neodatis");
     NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli"
                                                                                 , "oli@sdsadf", null);
     NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine"
                                                                                 , "karine@sdsadf", null);
     NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null,
                                                                                 null, null);
     odb.Store(user1);
     odb.Store(user2);
     odb.Store(user3);
     odb.Close();
     odb = Open("null.neodatis");
     NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User),
                                             true);
     AssertEquals(3, l.Count);
     user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals("oli", user1.GetName());
     AssertEquals("oli@sdsadf", user1.GetEmail());
     AssertEquals(null, user1.GetProfile());
     user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals("karine", user2.GetName());
     AssertEquals("karine@sdsadf", user2.GetEmail());
     AssertEquals(null, user2.GetProfile());
     user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
     AssertEquals(null, user3.GetName());
     AssertEquals(null, user3.GetEmail());
     AssertEquals(null, user3.GetProfile());
     odb.Close();
     DeleteBase("null.neodatis");
 }
Пример #3
0
        /// <summary>Test performance of retrieving many complex objects by oid</summary>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test7()
        {
            DeleteBase("getid.neodatis");
            int size = isLocal ? 10001 : 1000;

            NeoDatis.Odb.ODB   odb  = Open("getid.neodatis");
            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(GetInstance(i));
            }
            odb.Close();
            odb = Open("getid.neodatis");
            long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Login.User u = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjectFromId
                                                        (oids[i]);
                AssertEquals("kiko" + i, u.GetName());
            }
            long t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            odb.Close();
            DeleteBase("getid.neodatis");
            long   time           = t2 - t1;
            double timeForEachGet = (double)time / (double)size;
            double acceptableTime = isLocal ? 0.086 : 1.6;

            // 0.1561843815618438
            Println("time for each get = " + timeForEachGet + " - Total time for " + size + " objects = "
                    + time);
            if (testPerformance && timeForEachGet > acceptableTime)
            {
                // ms
                Println("time for each get = " + timeForEachGet + " - Total time for " + size + " objects = "
                        + time);
                Fail("Getting " + size + " complex objects by oid lasted more than " + acceptableTime
                     + "ms : " + timeForEachGet);
            }
        }
Пример #4
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test7Ordering()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB odb = Open("get.neodatis");
            NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_183();
            query.OrderByDesc("name");
            NeoDatis.Odb.Objects l = odb.GetObjects(query, true);
            int i = l.Count - 1;

            while (l.HasNext())
            {
                NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                AssertEquals("olivier " + i, user.GetName());
                // println(user.getName());
                i--;
            }
            odb.Close();
        }
Пример #5
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test8Ordering()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.ODB odb = Open("get.neodatis");
            NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_208();
            query.OrderByAsc("name,email");
            NeoDatis.Odb.Objects l = odb.GetObjects(query, true);
            int i = 0;

            while (l.HasNext())
            {
                NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                // println(user.getName() + " / " + user.getEmail());
                AssertEquals("olivier " + i / 3, user.GetName());
                AssertEquals("[email protected] " + ((i % 3) + 1), user.GetEmail());
                i++;
            }
            odb.Close();
        }
Пример #6
0
 /// <summary>Stores an object User that has a non null reference to a Profile.</summary>
 /// <remarks>
 /// Stores an object User that has a non null reference to a Profile. Then
 /// deletes the profile. Loads the user again and updates the user profile
 /// with a new created profile. ODB did not detect the change Detected by
 /// Olivier.
 /// </remarks>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual void Test8()
 {
     // reset counter to checks update type (normal or updates)
     NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates();
     if (!isLocal)
     {
         return;
     }
     DeleteBase(Name);
     NeoDatis.Odb.ODB odb = Open(Name);
     NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("name"
                                                                                , "email", new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function
                                                                                                                                      ("function")));
     odb.Store(user);
     odb.Close();
     odb = Open(Name);
     NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects
                                                (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst();
     odb.Delete(p);
     odb.Close();
     odb = Open(Name);
     NeoDatis.Odb.Test.VO.Login.User user3 = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects
                                                 (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst();
     AssertNull(user3.GetProfile());
     user3.SetProfile(new NeoDatis.Odb.Test.VO.Login.Profile("new profile", new NeoDatis.Odb.Test.VO.Login.Function
                                                                 ("f1")));
     user3.SetEmail("email2");
     user3.SetName("name2");
     odb.Store(user3);
     odb.Close();
     odb = Open(Name);
     NeoDatis.Odb.Test.VO.Login.User user4 = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects
                                                 (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst();
     odb.Close();
     DeleteBase(Name);
     AssertEquals("new profile", user4.GetProfile().GetName());
     AssertEquals("email2", user4.GetEmail());
     AssertEquals("name2", user4.GetName());
 }
Пример #7
0
        public virtual void TestCompareCollection9()
		{
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", function);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new 
				NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			// Sets attributes offsets - this is normally done by reading then from
			// disk, but in this junit,
			// we must set them manually
			long[] offsets = new long[] { 1L, 2L, 3L };
			int[] ids = new int[] { 1, 2, 3 };
			instanceInfo.GetHeader().SetAttributesIdentification(offsets);
			instanceInfo.GetHeader().SetAttributesIds(ids);
			instanceInfo.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1
				));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			user.SetName("Kiko");
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			instanceInfo3.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(
				1));
			nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)instanceInfo3
				.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
			AssertEquals(1, comparator.GetNbChanges());
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = 
				(NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator
				.GetChangedAttributeActions()[0];
			AssertEquals(1, comparator.GetChangedAttributeActions().Count);
			AssertEquals(user.GetName(), cnaa.GetNoiWithNewValue().GetObject());
		}
Пример #8
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestInsertSimpleObjectODB()
        {
            bool inMemory = true;

            // Deletes the database file
            NeoDatis.Tool.IOUtil.DeleteFile(OdbFileName);
            long t1  = 0;
            long t2  = 0;
            long t3  = 0;
            long t4  = 0;
            long t5  = 0;
            long t6  = 0;
            long t7  = 0;
            long t77 = 0;
            long t8  = 0;

            NeoDatis.Odb.ODB                odb = null;
            NeoDatis.Odb.Objects            l   = null;
            NeoDatis.Odb.Test.VO.Login.User so  = null;
            // Insert TEST_SIZE objects
            System.Console.Out.WriteLine("Inserting " + TestSize + " objects");
            t1  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User)).AddFullInstantiationHelper
                (new NeoDatis.Odb.Test.Performance.UserFullInstantiationHelper());
            for (int i = 0; i < TestSize; i++)
            {
                object o = GetUserInstance(i);
                odb.Store(o);
            }
            t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Closes the database
            odb.Close();
            t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Retrieving " + TestSize + " objects");
            // Reopen the database
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            // Gets retrieve the TEST_SIZE objects
            l  = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), inMemory);
            t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Actually get objects
            while (l.HasNext())
            {
                object o = l.Next();
            }
            t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Updating " + TestSize + " objects");
            so = null;
            l.Reset();
            // Actually get objects
            while (l.HasNext())
            {
                so = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                // so.setName(so.getName() + " updated");
                // so.setName(so.getName() + " updated-updated-updated-updated");
                so.GetProfile().SetName(so.GetName() + " updated-updated-updated");
                odb.Store(so);
            }
            t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb.Close();
            t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            System.Console.Out.WriteLine("Deleting " + TestSize + " objects");
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            l   = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), inMemory);
            t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // Actually get objects
            while (l.HasNext())
            {
                so = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
                odb.Delete(so);
            }
            odb.Close();
            t8  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName);
            odb.Close();
            DisplayResult("ODB " + TestSize + " User objects ", t1, t2, t3, t4, t5, t6, t7, t77
                          , t8);
        }