Exemple #1
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2()
		{
			if (!isLocal)
			{
				return;
			}
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
			NeoDatis.Odb.ODB odb = Open(OdbFileName1);
			NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile"
				);
			for (int i = 0; i < 500; i++)
			{
				NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier "
					 + i, "[email protected] " + i, p);
				odb.Store(user);
			}
			odb.Close();
			odb = Open(OdbFileName1);
			odb.DefragmentTo(Directory + OdbFileName2);
			NeoDatis.Odb.ODB newOdb = Open(OdbFileName2);
			AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Login.User))), newOdb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.User))));
			AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Login.Profile))), newOdb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile))));
			odb.Close();
			newOdb.Close();
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
		}
Exemple #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"
				, "[email protected]", null);
			NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine"
				, "[email protected]", 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("[email protected]", user1.GetEmail());
			AssertEquals(null, user1.GetProfile());
			user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next();
			AssertEquals("karine", user2.GetName());
			AssertEquals("[email protected]", 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");
		}
Exemple #3
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 #4
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			if (!isLocal)
			{
				return;
			}
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
			NeoDatis.Odb.ODB odb = Open(OdbFileName1);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier"
				, "[email protected]", null);
			odb.Store(user);
			odb.Close();
			odb = Open(OdbFileName1);
			odb.DefragmentTo(Directory + OdbFileName2);
			NeoDatis.Odb.ODB newOdb = Open(OdbFileName2);
			// int n = odb.getObjects(User.class).size();
			// println("n="+n);
			System.Decimal nbUser = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.User)));
			System.Decimal nbNewUser = newOdb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.User)));
			AssertEquals(nbUser, nbNewUser);
			AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Login.Profile))), newOdb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile))));
			odb.Close();
			newOdb.Close();
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
		}
Exemple #5
0
        public virtual void TestClassInfo()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoList classInfoList = classIntrospector
				.Introspect(user.GetType(), true);
			AssertEquals(user.GetType().FullName, classInfoList.GetMainClassInfo().GetFullClassName
				());
			AssertEquals(3, classInfoList.GetMainClassInfo().GetAttributes().Count);
			AssertEquals(2, classInfoList.GetClassInfos().Count);
		}
Exemple #6
0
		private object GetUserInstance(int i)
		{
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login" + i);
			NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function
				("logout" + i);
			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" + i, list);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				 + i, "oliv[email protected]", profile);
			return user;
		}
Exemple #7
0
		private object GetUserInstance()
		{
			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.Generic.IList<NeoDatis.Odb.Test.VO.Login.Function> list = new 
				System.Collections.Generic.List<NeoDatis.Odb.Test.VO.Login.Function>();
			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 user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", profile);
			return user;
		}
Exemple #8
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"
				, "[email protected]", profile1);
			NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("A√°sa Galv√£o Smadja"
				, "[email protected]", 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");
		}
Exemple #9
0
        public virtual void TestInstanceInfo2()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			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));
			AssertEquals(instanceInfo.GetClassInfo().GetFullClassName(), user.GetType().FullName
				);
			AssertEquals(instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("name")).ToString
				(), "olivier smadja");
		}
Exemple #10
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 #11
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCompositeCollection1()
		{
			DeleteBase("t31.neodatis");
			NeoDatis.Odb.ODB odb = Open("t31.neodatis");
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			System.Collections.IList list = new System.Collections.ArrayList();
			list.Add(login);
			NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator 1", list);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", profile1);
			odb.Store(user);
			odb.Close();
			odb = Open("t31.neodatis");
			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());
			DeleteBase("t31.neodatis");
		}
Exemple #12
0
        public virtual void Test4()
		{
			DeleteBase("sublist4");
			NeoDatis.Odb.ODB odb = Open("sublist4");
			int i = 0;
			System.Collections.IList functions1 = new System.Collections.ArrayList();
			for (i = 0; i < 30; i++)
			{
				functions1.Add(new NeoDatis.Odb.Test.VO.Login.Function("f1-" + i));
			}
			System.Collections.IList functions2 = new System.Collections.ArrayList();
			for (i = 0; i < 60; i++)
			{
				functions2.Add(new NeoDatis.Odb.Test.VO.Login.Function("f2-" + i));
			}
			System.Collections.IList functions3 = new System.Collections.ArrayList();
			for (i = 0; i < 90; i++)
			{
				functions3.Add(new NeoDatis.Odb.Test.VO.Login.Function("f3-" + i));
			}
			NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("User1"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("profile1", functions1
				));
			NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("User2"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("profile2", functions2
				));
			NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User("User3"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("profile3", functions3
				));
			odb.Store(user1);
			odb.Store(user2);
			odb.Store(user3);
			odb.Close();
			odb = Open("sublist4");
			NeoDatis.Odb.Test.VO.Login.User u = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects
				(typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst();
			System.Console.Out.WriteLine(u);
			NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.Profile)).Field("name").Sublist("functions", 
				1, 2, false).Size("functions", "fsize");
			NeoDatis.Odb.Values v = odb.GetValues(q);
			i = 0;
			while (v.HasNext())
			{
				NeoDatis.Odb.ObjectValues ov = v.NextValues();
				string profileName = (string)ov.GetByAlias("name");
				Println(profileName);
				AssertEquals("profile" + (i + 1), profileName);
				AssertEquals(System.Convert.ToInt64(30 * (i + 1)), ov.GetByAlias("fsize"));
				System.Collections.IList l = (System.Collections.IList)ov.GetByAlias("functions");
				Println(l);
				AssertEquals(2, l.Count);
				i++;
			}
			odb.Close();
		}
Exemple #13
0
		public virtual object Instantiate(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi)
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User();
			return user;
		}
Exemple #14
0
        public virtual void TestCompareCollection1()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			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("Olivier Smadja");
			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());
			AssertEquals(1, comparator.GetChangedAttributeActions().Count);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = 
				(NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator
				.GetChangedAttributeActions()[0];
			AssertEquals("Olivier Smadja", cnaa.GetNoiWithNewValue().GetObject());
		}
Exemple #15
0
        public virtual void TestCopy()
		{
			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"
				, "[email protected]", profile);
			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));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo copy = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.CreateCopy(new NeoDatis.Tool.Wrappers.Map.OdbHashMap(), true);
			AssertEquals(3, copy.GetAttributeValues().Length);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] aois = copy.GetAttributeValues
				();
			for (int i = 0; i < aois.Length; i++)
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = aois[i];
				AssertEquals(instanceInfo.GetAttributeValues()[i].GetOdbTypeId(), aoi.GetOdbTypeId
					());
			}
		}
Exemple #16
0
        public virtual void TestGetDependentObjects()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
				 callback = new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
				();
			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, callback);
			AssertEquals(user.GetType().FullName, instanceInfo.GetClassInfo().GetFullClassName
				());
			AssertEquals("olivier smadja", instanceInfo.GetAttributeValueFromId(ci.GetAttributeId
				("name")).ToString());
			AssertEquals(typeof(NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo), 
				instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("name")).GetType());
			System.Collections.ICollection objects = callback.GetObjects();
			AssertEquals(2, objects.Count);
			AssertTrue(objects.Contains(user.GetProfile()));
			AssertTrue(objects.Contains(user.GetProfile().GetFunctions()[0]));
		}
Exemple #17
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"
				, "[email protected]", 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());
		}
Exemple #18
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCompositeCollection3()
		{
			DeleteBase("t4.neodatis");
			NeoDatis.Odb.ODB odb = Open("t4.neodatis");
			// Configuration.addLogId("ObjectWriter");
			// Configuration.addLogId("ObjectReader");
			// Configuration.addLogId("FileSystemInterface");
			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");
			System.Collections.IList list = 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.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", profile1);
			NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
				, "[email protected]", profile1);
			odb.Store(user);
			odb.Store(userB);
			odb.Close();
			odb = Open("t4.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);
			// 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 + 1, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			odb.Close();
			DeleteBase("t4.neodatis");
		}
Exemple #19
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test3()
		{
			if (!isLocal)
			{
				return;
			}
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
			NeoDatis.Odb.OdbConfiguration.SetAutomaticallyIncreaseCacheSize(true);
			NeoDatis.Odb.ODB odb = Open(OdbFileName1);
			for (int i = 0; i < 15000; i++)
			{
				NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier "
					 + i, "[email protected] " + i, new NeoDatis.Odb.Test.VO.Login.Profile("profile"
					 + i));
				odb.Store(user);
			}
			odb.Close();
			odb = Open(OdbFileName1);
			odb.DefragmentTo(Directory + OdbFileName2);
			NeoDatis.Odb.ODB newOdb = Open(OdbFileName2);
			AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Login.User))), newOdb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Login.User))));
			odb.Close();
			newOdb.Close();
			DeleteBase(OdbFileName1);
			DeleteBase(OdbFileName2);
		}
Exemple #20
0
		/// <exception cref="System.Exception"></exception>
		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 ");
			}
			NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function
				(b.ToString());
			NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator 1", login);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "[email protected]", profile1);
			odb.Store(user);
			odb.Commit();
			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+2,users.size());
			NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.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);
		}
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2()
		{
			DeleteBase("t2.neodatis");
			NeoDatis.Odb.ODB odb = Open("t2.neodatis");
			int nbUsers = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User)).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");
			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"
				, "[email protected]", profile);
			NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
				, "[email protected]", profile);
			odb.Store(olivier);
			odb.Store(aisa);
			odb.Commit();
			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();
			// println("Users:"+users);
			Println("Profiles:" + profiles);
			Println("Functions:" + functions);
			odb = Open("t2.neodatis");
			NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), 
				true);
			odb.Close();
			AssertEquals(nbUsers + 2, users.Count);
			NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			AssertEquals(olivier.ToString(), user2.ToString());
			AssertEquals(nbProfiles + 1, profiles.Count);
			AssertEquals(nbFunctions + 2, functions.Count);
			NeoDatis.Odb.ODB odb2 = Open("t2.neodatis");
			l = odb2.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true);
			NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
				)l.GetFirst();
			function.SetName("login function");
			odb2.Store(function);
			odb2.Close();
			NeoDatis.Odb.ODB odb3 = Open("t2.neodatis");
			NeoDatis.Odb.Objects l2 = odb3.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User)
				, true);
			int i = 0;
			while (l2.HasNext() && i < System.Math.Min(2, l2.Count))
			{
				NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l2.Next();
				AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0]
					);
				i++;
			}
			odb3.Close();
			DeleteBase("t2.neodatis");
		}
		/// <exception cref="System.Exception"></exception>
		public virtual void Test6()
		{
			// LogUtil.objectWriterOn(true);
			DeleteBase("t6.neodatis");
			NeoDatis.Odb.ODB odb = Open("t6.neodatis");
			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"
				, "[email protected]", profile);
			odb.Store(olivier);
			odb.Close();
			Println("----------");
			odb = Open("t6.neodatis");
			NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User
				), true);
			NeoDatis.Odb.Test.VO.Login.User u1 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst
				();
			u1.GetProfile().SetName("operator 234567891011121314");
			odb.Store(u1);
			odb.Close();
			odb = Open("t6.neodatis");
			NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile
				), true);
			AssertEquals(1, profiles.Count);
			NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)profiles
				.GetFirst();
			AssertEquals(u1.GetProfile().GetName(), p1.GetName());
		}
		/// <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"
				, "[email protected]", profile);
			NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja"
				, "[email protected]", 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);
		}