/// <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()); }
/// <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" , "*****@*****.**", 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 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"); }
/// <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()); }
/// <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" , "*****@*****.**", 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" , "*****@*****.**", profile); NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja" , "*****@*****.**", 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"); }
public bool Match(NeoDatis.Odb.Test.VO.Login.User user) { return(user.GetProfile().GetName().StartsWith("profile")); }
public bool Match(NeoDatis.Odb.Test.VO.Login.User user) { return(user.GetProfile().GetName().StartsWith("profile") && user.GetEmail().StartsWith ("[email protected] 2")); }
public bool Match(NeoDatis.Odb.Test.VO.Login.User user) { return(user.GetProfile().GetName().Equals("profile 5")); }
public virtual void TestGetDependentObjects() { NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", 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])); }
/// <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); }