Exemple #1
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. Creates
 /// a new profile.
 /// Update the last profile and sets it a the new user profile.ODB detects
 /// the reference change but does not update the profile Detected by Olivier.
 /// 22/05/2007
 /// </remarks>
 /// <exception cref="System.Exception">System.Exception</exception>
 public virtual void Test9()
 {
     // reset counter to checks update type (normal or updates)
     NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates();
     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.Store(new NeoDatis.Odb.Test.VO.Login.Profile("new profile"));
     odb.Close();
     odb = Open(Name);
     NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects
                                                (new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(NeoDatis.Odb.Test.VO.Login.Profile
                                                                                                                ), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "new profile"))).GetFirst
                                                ();
     p.SetName("new profile2");
     NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects
                                                 (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst();
     user2.SetProfile(p);
     odb.Store(user2);
     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();
     AssertNotNull(user3.GetProfile());
     odb.Close();
     DeleteBase(Name);
     AssertEquals("new profile2", user3.GetProfile().GetName());
 }
Exemple #2
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());
 }
Exemple #3
0
        public virtual void TestIntrospectWithNull2()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", null);
			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
				));
			object o = instanceInfo.GetAttributeValueFromId(2);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)o;
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			user.SetProfile(new NeoDatis.Odb.Test.VO.Login.Profile("pname"));
			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));
			bool b = comparator.HasChanged(instanceInfo, instanceInfo3);
			AssertTrue(b);
			AssertEquals(1, comparator.GetNbChanges());
			AssertEquals(0, comparator.GetChangedAttributeActions().Count);
			AssertEquals(1, comparator.GetNewObjectMetaRepresentations().Count);
		}
Exemple #4
0
        public virtual void TestCompareCollection8()
		{
			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);
			user.SetProfile(null);
			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));
			AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
			AssertEquals(1, comparator.GetNbChanges());
			AssertEquals(1, comparator.GetAttributeToSetToNull().Count);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction o = (NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction
				)comparator.GetAttributeToSetToNull()[0];
			AssertEquals(0, comparator.GetChangedAttributeActions().Count);
			AssertEquals(2, o.GetAttributeId());
		}