/// <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); }
public User(string name, string email, NeoDatis.Odb.Test.VO.Login.Profile profile ) : base() { this.name = name; this.email = email; this.profile = profile; }
/// <exception cref="System.Exception"></exception> public virtual void Populate() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria"); int nbProfiles = 200; int nbUsers = 500000; NeoDatis.Odb.Test.VO.Login.Profile[] profiles = new NeoDatis.Odb.Test.VO.Login.Profile [nbProfiles]; NeoDatis.Odb.Test.VO.Login.User2[] users = new NeoDatis.Odb.Test.VO.Login.User2[nbUsers ]; // First creates profiles for (int i = 0; i < nbProfiles; i++) { profiles[i] = new NeoDatis.Odb.Test.VO.Login.Profile("profile " + i, new NeoDatis.Odb.Test.VO.Login.Function ("function Profile" + i)); odb.Store(profiles[i]); } // Then creates users for (int i = 0; i < nbUsers; i++) { users[i] = new NeoDatis.Odb.Test.VO.Login.User2("user" + i, "user mail" + i, profiles [GetProfileIndex(nbProfiles)], i); odb.Store(users[i]); if (i % 10000 == 0) { Println(i); } } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst(); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Contain("profiles", p)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); odb.Close(); AssertEquals(1, l.Count); }
public User(string name, string email, NeoDatis.Odb.Test.VO.Login.Profile profile ) : base() { this.name = name; this.email = email; this.profile = profile; }
/// <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() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList<NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List<NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); // this object is not known y NeoDatis so the query will not return anything NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("p1" , (System.Collections.IList)null); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Contain("profiles", p)); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); odb.Close(); AssertEquals(0, l.Count); }
/// <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 Populate() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria"); int nbProfiles = 200; int nbUsers = 500000; NeoDatis.Odb.Test.VO.Login.Profile[] profiles = new NeoDatis.Odb.Test.VO.Login.Profile [nbProfiles]; NeoDatis.Odb.Test.VO.Login.User2[] users = new NeoDatis.Odb.Test.VO.Login.User2[nbUsers ]; // First creates profiles for (int i = 0; i < nbProfiles; i++) { profiles[i] = new NeoDatis.Odb.Test.VO.Login.Profile("profile " + i, new NeoDatis.Odb.Test.VO.Login.Function ("function Profile" + i)); odb.Store(profiles[i]); } // Then creates users for (int i = 0; i < nbUsers; i++) { users[i] = new NeoDatis.Odb.Test.VO.Login.User2("user" + i, "user mail" + i, profiles [GetProfileIndex(nbProfiles)], i); odb.Store(users[i]); if (i % 10000 == 0) { Println(i); } } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestReuse() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst(); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("profiles", p)); NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion ec = (NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion )query.GetCriteria(); try { NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); } catch (System.Exception e) { AssertTrue(NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, true).IndexOf("1063" ) != -1); } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); // this object is not known y NeoDatis so the query will not return anything NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("p1" , (System.Collections.IList)null); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Contain("profiles", p)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); odb.Close(); AssertEquals(0, l.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. 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 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 Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); 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))); NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function ("function1"); NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function ("function2"); NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function ("function3"); System.Collections.IList functions = new System.Collections.ArrayList(); functions.Add(function1); functions.Add(function2); functions.Add(function3); NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile1", functions); NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function2"))); NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function )l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); // check Profile 1 NeoDatis.Odb.Objects lprofile = 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", "profile1"))); NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile .GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); 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))); NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function ("function1"); NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function ("function2"); NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function ("function3"); System.Collections.IList functions = new System.Collections.ArrayList(); functions.Add(function1); functions.Add(function2); functions.Add(function3); NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile1", functions); NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function2"))); NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function )l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); // check Profile 1 NeoDatis.Odb.Objects lprofile = 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", "profile1"))); NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile .GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
public virtual bool Equals2(object obj) { if (obj == null || obj.GetType() != typeof(NeoDatis.Odb.Test.VO.Login.Profile)) { return(false); } NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)obj; if (name == null && p.name != null) { return(false); } return((name == null && p.name == null) || (name.Equals(p.name))); }
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; }
/// <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"); }
/// <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"); }
/// <exception cref="System.Exception"></exception> public virtual void Populate() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteriaIndex"); string[] atts = new string[] { "name" }; try { odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User2)).AddUniqueIndexOn ("Index", atts, true); } catch (System.Exception) { } // TODO: handle exception int nbProfiles = 200; int nbUsers = 500000; NeoDatis.Odb.Test.VO.Login.Profile[] profiles = new NeoDatis.Odb.Test.VO.Login.Profile [nbProfiles]; NeoDatis.Odb.Test.VO.Login.User2[] users = new NeoDatis.Odb.Test.VO.Login.User2[nbUsers ]; int userStart = 1500000; int profileStart = 600; // First creates profiles for (int i = 0; i < nbProfiles; i++) { profiles[i] = new NeoDatis.Odb.Test.VO.Login.Profile("profile " + (i + profileStart ), new NeoDatis.Odb.Test.VO.Login.Function("function Profile" + i)); odb.Store(profiles[i]); } // Then creates users for (int i = 0; i < nbUsers; i++) { users[i] = new NeoDatis.Odb.Test.VO.Login.User2("user" + (i + userStart), "user mail" + i, profiles[GetProfileIndex(nbProfiles)], i); odb.Store(users[i]); if (i % 10000 == 0) { Println(i); } } odb.Close(); }
public virtual void Test17() { DeleteBase("valuesA2"); NeoDatis.Odb.ODB odb = Open("valuesA2"); odb.Store(new NeoDatis.Odb.Test.VO.Login.User("user1", "email1", new NeoDatis.Odb.Test.VO.Login.Profile ("profile name", new NeoDatis.Odb.Test.VO.Login.Function("f111")))); odb.Close(); odb = Open("valuesA2"); NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User)).Field("name").Field("profile")); Println(values); NeoDatis.Odb.ObjectValues ov = values.NextValues(); odb.Close(); AssertEquals("user1", ov.GetByAlias("name")); AssertEquals("user1", ov.GetByIndex(0)); NeoDatis.Odb.Test.VO.Login.Profile p2 = (NeoDatis.Odb.Test.VO.Login.Profile)ov.GetByAlias ("profile"); AssertEquals("profile name", p2.GetName()); }
/// <exception cref="System.Exception"></exception> public virtual void Populate() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteriaIndex"); string[] atts = new string[] { "name" }; try { odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User2)).AddUniqueIndexOn ("Index", atts, true); } catch (System.Exception) { } // TODO: handle exception int nbProfiles = 200; int nbUsers = 500000; NeoDatis.Odb.Test.VO.Login.Profile[] profiles = new NeoDatis.Odb.Test.VO.Login.Profile [nbProfiles]; NeoDatis.Odb.Test.VO.Login.User2[] users = new NeoDatis.Odb.Test.VO.Login.User2[nbUsers ]; int userStart = 1500000; int profileStart = 600; // First creates profiles for (int i = 0; i < nbProfiles; i++) { profiles[i] = new NeoDatis.Odb.Test.VO.Login.Profile("profile " + (i + profileStart ), new NeoDatis.Odb.Test.VO.Login.Function("function Profile" + i)); odb.Store(profiles[i]); } // Then creates users for (int i = 0; i < nbUsers; i++) { users[i] = new NeoDatis.Odb.Test.VO.Login.User2("user" + (i + userStart), "user mail" + i, profiles[GetProfileIndex(nbProfiles)], i); odb.Store(users[i]); if (i % 10000 == 0) { Println(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); }
public virtual void Test3() { DeleteBase("values2"); NeoDatis.Odb.ODB odb = Open("values2"); NeoDatis.Odb.Test.VO.Login.Profile p1 = new NeoDatis.Odb.Test.VO.Login.Profile("profile1" , new NeoDatis.Odb.Test.VO.Login.Function("f1")); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile2" , new NeoDatis.Odb.Test.VO.Login.Function("f2")); NeoDatis.Odb.Test.VO.Login.User u1 = new NeoDatis.Odb.Test.VO.Login.User2("user1" , "*****@*****.**", p1, 1); NeoDatis.Odb.Test.VO.Login.User u2 = new NeoDatis.Odb.Test.VO.Login.User2("user2" , "*****@*****.**", p1, 2); NeoDatis.Odb.Test.VO.Login.User u3 = new NeoDatis.Odb.Test.VO.Login.User2("user3" , "*****@*****.**", p1, 3); NeoDatis.Odb.Test.VO.Login.User u4 = new NeoDatis.Odb.Test.VO.Login.User2("user4" , "*****@*****.**", p2, 4); NeoDatis.Odb.Test.VO.Login.User u5 = new NeoDatis.Odb.Test.VO.Login.User2("user5" , "*****@*****.**", p2, 5); odb.Store(u1); odb.Store(u2); odb.Store(u3); odb.Store(u4); odb.Store(u5); odb.Close(); odb = Open("values2"); NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2)).Field("profile.name").Count("count"). Avg("nbLogins", "avg").GroupBy("profile.name"); q.OrderByAsc("name"); NeoDatis.Odb.Values values = odb.GetValues(q); Println(values); NeoDatis.Odb.ObjectValues ov = values.NextValues(); AssertEquals(2, values.Count); AssertEquals("profile1", ov.GetByAlias("profile.name")); AssertEquals(new System.Decimal("3"), ov.GetByAlias("count")); AssertEquals(new System.Decimal("2.00"), ov.GetByAlias("avg")); odb.Close(); AssertEquals(2, values.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 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"); }
/// <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); }
public virtual void SetProfile(NeoDatis.Odb.Test.VO.Login.Profile profile) { this.profile = profile; }
/// <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"); }
/// <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"); }
/// <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"); }
/// <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()); }
public virtual void SetProfile(NeoDatis.Odb.Test.VO.Login.Profile profile) { this.profile = profile; }
public virtual void Test3() { DeleteBase("values2"); NeoDatis.Odb.ODB odb = Open("values2"); NeoDatis.Odb.Test.VO.Login.Profile p1 = new NeoDatis.Odb.Test.VO.Login.Profile("profile1" , new NeoDatis.Odb.Test.VO.Login.Function("f1")); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile2" , new NeoDatis.Odb.Test.VO.Login.Function("f2")); NeoDatis.Odb.Test.VO.Login.User u1 = new NeoDatis.Odb.Test.VO.Login.User2("user1" , "*****@*****.**", p1, 1); NeoDatis.Odb.Test.VO.Login.User u2 = new NeoDatis.Odb.Test.VO.Login.User2("user2" , "*****@*****.**", p1, 2); NeoDatis.Odb.Test.VO.Login.User u3 = new NeoDatis.Odb.Test.VO.Login.User2("user3" , "*****@*****.**", p1, 3); NeoDatis.Odb.Test.VO.Login.User u4 = new NeoDatis.Odb.Test.VO.Login.User2("user4" , "*****@*****.**", p2, 4); NeoDatis.Odb.Test.VO.Login.User u5 = new NeoDatis.Odb.Test.VO.Login.User2("user5" , "*****@*****.**", p2, 5); odb.Store(u1); odb.Store(u2); odb.Store(u3); odb.Store(u4); odb.Store(u5); odb.Close(); odb = Open("values2"); NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2)).Field("profile.name").Count("count"). Avg("nbLogins", "avg").GroupBy("profile.name"); q.OrderByAsc("name"); NeoDatis.Odb.Values values = odb.GetValues(q); Println(values); NeoDatis.Odb.ObjectValues ov = values.NextValues(); AssertEquals(2, values.Count); AssertEquals("profile1", ov.GetByAlias("profile.name")); AssertEquals(new System.Decimal("3"), ov.GetByAlias("count")); AssertEquals(new System.Decimal("2.00"), ov.GetByAlias("avg")); odb.Close(); AssertEquals(2, values.Count); }
public User2(string name, string email, NeoDatis.Odb.Test.VO.Login.Profile profile , int nbLogins) : base(name, email, profile) { this.nbLogins = nbLogins; }
/// <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); }
public virtual void TestCompareCollection9() { NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function ("login"); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator", function); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile); NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect( user.GetType(), true).GetMainClassInfo(); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true , null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore (null, null, false)); // Sets attributes offsets - this is normally done by reading then from // disk, but in this junit, // we must set them manually long[] offsets = new long[] { 1L, 2L, 3L }; int[] ids = new int[] { 1, 2, 3 }; instanceInfo.GetHeader().SetAttributesIdentification(offsets); instanceInfo.GetHeader().SetAttributesIds(ids); instanceInfo.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1 )); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )instanceInfo.GetAttributeValueFromId(2); nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2)); user.SetName("Kiko"); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true , null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore (null, null, false)); instanceInfo3.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID( 1)); nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)instanceInfo3 .GetAttributeValueFromId(2); nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2)); AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3)); AssertEquals(1, comparator.GetNbChanges()); NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = (NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator .GetChangedAttributeActions()[0]; AssertEquals(1, comparator.GetChangedAttributeActions().Count); AssertEquals(user.GetName(), cnaa.GetNoiWithNewValue().GetObject()); }
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 ()); } }