/// <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); }
/// <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" , "*****@*****.**", 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); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase("t1.neodatis"); // LogUtil.allOn(true); NeoDatis.Odb.ODB odb = Open("t1.neodatis"); // LogUtil.objectWriterOn(true); 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" , "*****@*****.**", profile1); odb.Store(user); odb.Close(); odb = Open("t1.neodatis"); NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), true); // assertEquals(nbUsers+2,users.size()); NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst (); odb.Close(); AssertEquals(user.ToString(), user2.ToString()); DeleteBase("t1.neodatis"); }
/// <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); }
/// <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"); }
/// <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()); }
/// <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()); }
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" , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("profile1", functions1 )); NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("User2" , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("profile2", functions2 )); NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User("User3" , "*****@*****.**", 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(); }
public virtual void TestClassInfo() { 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.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); }
private object GetInstance(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("kiko" + i, "*****@*****.**" + i, profile); return(user); }
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, "*****@*****.**", profile); return user; }
/// <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" , "*****@*****.**", profile1); NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("A√°sa Galv√£o Smadja" , "*****@*****.**", 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"); }
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" , "*****@*****.**", profile); return(user); }
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" , "*****@*****.**", profile); return user; }
public virtual void TestInstanceInfo2() { 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.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"); }
/// <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" , "*****@*****.**", profile1); NeoDatis.Odb.Test.VO.Login.User userB = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja" , "*****@*****.**", 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"); }
/// <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); } }
/// <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(); }
/// <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" , "*****@*****.**", 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(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); }
/// <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 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(); }
/// <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 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" , "*****@*****.**", 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"); }
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 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])); }
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; }
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); }
/// <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); }
/// <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 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" , "*****@*****.**", 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 ()); } }
public bool Match(NeoDatis.Odb.Test.VO.Login.User user) { return(user.GetProfile().GetName().Equals("profile 5")); }
public virtual void TestCompareCollection1() { 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.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()); }
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()); }