public virtual void Test16() { string baseName = GetBaseName(); int size = isLocal ? 10000 : 100; NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size]; for (int i = 0; i < size; i++) { oids[i] = odb.Store(new Function("function" + i)); } AssertEquals(size, odb.Count(new CriteriaQuery (typeof(Function)))); for (int i = 0; i < size; i++) { odb.DeleteObjectWithId(oids[i]); } AssertEquals(0, odb.Count(new CriteriaQuery (typeof(Function)))); for (int i = 0; i < size; i++) { oids[i] = odb.Store(new Function("function" + i)); } AssertEquals(size, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); AssertEquals(size, odb.GetObjects <Function>().Count ); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test6updateChangingKeyValue() { // to monitor in place updates NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.GetMap().Add("f1", "changed function"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals("changed function", dic.GetMap()["f1"]); odb.Close(); }
public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); decimal n = odb.Count(new CriteriaQuery(typeof( Function))); Function function1 = new Function ("function1"); Function function2 = new Function ("function2"); Function function3 = new Function ("function3"); odb.Store(function1); odb.Store(function2); odb.Store(function3); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "function2"))); Function function = l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(true); AssertEquals(n + 2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); DeleteBase(baseName); }
public virtual void Test5() { DeleteBase("t5.neodatis"); NeoDatis.Odb.ODB odb = Open("t5.neodatis"); long nbFunctions = odb.Count(new CriteriaQuery(typeof(Function))); long nbProfiles = odb.Count(new CriteriaQuery(typeof(Profile))); long nbUsers = odb.Count(new CriteriaQuery(typeof(User))); Function login = new Function ("login"); Function logout = new Function ("logout"); System.Collections.Generic.List <Function> list = new System.Collections.Generic.List <Function>(); list.Add(login); list.Add(logout); Profile profile = new Profile("operator", list); User olivier = new User("olivier smadja" , "*****@*****.**", profile); User aisa = new User("Aísa Galvão Smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Store(profile); odb.Commit(); odb.Close(); odb = Open("t5.neodatis"); NeoDatis.Odb.Objects <User> users = odb.GetObjects <User>(true); NeoDatis.Odb.Objects <Profile> profiles = odb.GetObjects <Profile>(true); NeoDatis.Odb.Objects <Function> functions = odb.GetObjects <Function>(true); odb.Close(); AssertEquals(nbUsers + 1, users.Count); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); }
public virtual void Test4() { string baseName = GetBaseName(); int n = isLocal ? 1000 : 10; NeoDatis.Odb.ODB odb = Open(baseName); long size = odb.Count(new CriteriaQuery(typeof(Function))); for (int i = 0; i < n; i++) { Function login = new Function("login - " + (i + 1)); odb.Store(login); AssertEquals(size + i + 1, odb.Count(new CriteriaQuery(typeof(Function)))); Console.WriteLine(i); } // IStorageEngine engine = Dummy.getEngine(odb); odb.Commit(); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true); int j = 0; while (l.HasNext()) { Console.WriteLine(" i=" + j); Function f = (Function)l.Next(); odb.Delete(f); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(); AssertEquals(size + n - (j + 1), l2.Count); j++; } odb.Commit(); odb.Close(); DeleteBase(baseName); }
public virtual void Test5updateIncreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where .Equal("name", "test2")); NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.SetMap(null); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects <Dictionnary>(query).GetFirst(); AssertNull(dic.GetMap()); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects <Dictionnary>(query).GetFirst(); dic.AddEntry("olivier", "Smadja"); odb.Store(dic); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects <Dictionnary>(query). GetFirst(); AssertNotNull(dic.GetMap()); AssertEquals("Smadja", dic.GetMap()["olivier"]); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.Function))); 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"); odb.Store(function1); odb.Store(function2); odb.Store(function3); odb.Close(); odb = Open(baseName); 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); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(n + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); DeleteBase(baseName); }
public virtual void Test15_by_oid_2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); NeoDatis.Odb.OID oid1 = odb.Store(f1); NeoDatis.Odb.OID oid2 = odb.Store(f2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); odb.DeleteObjectWithId(oid1); odb.DeleteObjectWithId(oid2); AssertEquals(0, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Store(f1); odb.Store(f2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); AssertEquals(2, odb.GetObjects <Function>().Count ); odb.Close(); DeleteBase(baseName); }
/// <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 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 virtual void Test6updateDecreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where .Equal("name", "test2")); NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); int mapSize = dictionnary.GetMap().Count; dictionnary.GetMap().Remove("f1"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects <Dictionnary>(query).GetFirst(); AssertEquals(mapSize - 1, dic.GetMap().Count); odb.Close(); }
/// <summary>creates 2 objects.</summary> /// <remarks>creates 2 objects. Delete them by oid. And create 2 new objects</remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test15_by_oid() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function( "function1"); NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function( "function2"); NeoDatis.Odb.OID oid1 = odb.Store(f1); NeoDatis.Odb.OID oid2 = odb.Store(f2); AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.DeleteObjectWithId(oid1); odb.DeleteObjectWithId(oid2); AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Store(f1); odb.Store(f2); AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); odb = Open(baseName); AssertEquals(2, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count ); odb.Close(); DeleteBase(baseName); }
public virtual void Test17() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Function f3 = new Function( "function2"); odb.Store(f1); odb.Store(f2); odb.Store(f3); AssertEquals(3, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Delete(f2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); // odb.store(f1); odb.Store(f2); // odb.store(f3); AssertEquals(3, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); AssertEquals(3, odb.GetObjects <Function>().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); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { NeoDatis.Odb.Test.Other.TestDownloadManager tdm = new NeoDatis.Odb.Test.Other.TestDownloadManager (); tdm.NewDownload("olivier", "*****@*****.**", "knowledger", "knowledger1.1"); tdm.NewDownload("olivier", "*****@*****.**", "knowledger", "knowledger1.1"); NeoDatis.Odb.ODB odb = Open("download.neodatis"); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Download.Download)))); AssertEquals(1, odb.Count(new CriteriaQuery (typeof(User)))); odb.Close(); }
public virtual void Test3() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long size = odb.Count(new CriteriaQuery(typeof(Dictionnary))); Dictionnary dictionnary1 = new Dictionnary("test1"); dictionnary1.SetMap(null); odb.Store(dictionnary1); odb.Close(); odb = Open("map.neodatis"); AssertEquals(size + 1, odb.GetObjects <Dictionnary>().Count); AssertEquals(size + 1, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestList1() { DeleteBase("list1.neodatis"); NeoDatis.Odb.ODB odb = Open("list1.neodatis"); long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( PlayerWithList))); PlayerWithList player = new PlayerWithList ("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list1.neodatis"); NeoDatis.Odb.Objects <PlayerWithList> l = odb2.GetObjects <PlayerWithList>(true); Println(l); AssertEquals(nb + 1, l.Count); // gets last player PlayerWithList player2 = (PlayerWithList)l.GetFirst(); AssertEquals(player.ToString(), player2.ToString()); odb2.Close(); DeleteBase("list1.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 Test5() { try { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); System.Collections.IList list = new System.Collections.ArrayList(); for (int i = 0; i < 15; i++) { Function function = new Function ("function " + i); odb.Store(function); list.Add(function); } odb.Close(); NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(15); odb = Open(FileName); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where .Or().Add(Where.Like("name", "%9")).Add(Where .Like("name", "%8"))); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(query, false); AssertEquals(2, l.Count); l.Next(); odb.Store(l.Next()); odb.Close(); odb = Open(FileName); AssertEquals(15, odb.Count(new CriteriaQuery())); odb.Close(); } finally { NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(300000); } }
public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long nbFunctions = odb.Count(new CriteriaQuery (typeof(Function))); decimal nbProfiles = odb.Count(new CriteriaQuery (typeof(Profile))); Function function1 = new Function ("function1"); Function function2 = new Function ("function2"); Function function3 = new Function ("function3"); System.Collections.Generic.List <Function> functions = new System.Collections.Generic.List <Function>(); functions.Add(function1); functions.Add(function2); functions.Add(function3); Profile profile1 = new Profile("profile1", functions); Profile profile2 = new Profile("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects <Function> lfunctions = odb.GetObjects <Function>(true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "function2"))); Function function = l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new CriteriaQuery (typeof(Function)))); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(true); // check Profile 1 NeoDatis.Odb.Objects <Profile> lprofile = odb.GetObjects <Profile>(new CriteriaQuery(Where.Equal("name", "profile1"))); Profile p1 = lprofile.GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
/// <summary>Test the timeof lazy get</summary> /// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase(Filename); // println("Start inserting " + SIZE + " objects"); long startinsert = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.ODB odb = Open(Filename); for (int i = 0; i < Size; i++) { odb.Store(GetInstance()); } odb.Close(); long endinsert = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("End inserting " + SIZE + " objects - " + // (endinsert-startinsert) + " ms"); // println("totalObjects = "+ odb.count(User.class)); odb = Open(Filename); long start1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Objects lazyList = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), false); long end1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); long startget1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); while (lazyList.HasNext()) { // t1 = OdbTime.getCurrentTimeInMs(); lazyList.Next(); } // t2 = OdbTime.getCurrentTimeInMs(); // println(t2-t1); long endget1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.User))), lazyList.Count); odb.Close(); long t01 = end1 - start1; long tget1 = endget1 - startget1; // long t2 = end2-start2; // long tget2 = endget2-startget2; // println("t1(lazy)="+t1 + " - " +tget1+ " t2(memory)="+t2 +" - " // + tget2); // println("t1(lazy)="+t1 + " - " +tget1); // assertTrue(t1<t2); // println(endinsert-startinsert); bool c = (isLocal ? 501 : 15000) > tget1; Println("Time for " + Size + " lazy gets : " + (tget1)); if (!c) { Println("Time for " + Size + " lazy gets : " + (tget1)); } DeleteBase(Filename); if (testPerformance && !c) { Fail("Time for " + Size + " lazy gets : " + (tget1)); } }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { NeoDatis.Odb.Test.Other.TestDownloadManager tdm = new NeoDatis.Odb.Test.Other.TestDownloadManager (); int size = (isLocal ? 1000 : 50); for (int i = 0; i < size; i++) { tdm.NewDownload("olivier", "*****@*****.**", "knowledger", "knowledger1.1"); tdm.NewDownload("olivier", "*****@*****.**", "knowledger", "knowledger1.1"); } NeoDatis.Odb.ODB odb = Open("download.neodatis"); AssertEquals(size * 2, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Download.Download)))); AssertEquals(1, odb.Count(new CriteriaQuery (typeof(User)))); odb.Close(); }
public virtual void Test6updateChangingKeyValue() { // to monitor in place updates NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new CriteriaQuery(typeof(Dictionnary))); IQuery query = new CriteriaQuery(typeof(Dictionnary), Where.Equal("name", "test2")); NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query); Dictionnary dictionnary = (Dictionnary)l.GetFirst(); dictionnary.GetMap()["f1"] = "changed function"; odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new CriteriaQuery(typeof(Dictionnary)))); Dictionnary dic = (Dictionnary)odb.GetObjects <Dictionnary>(query).GetFirst(); AssertEquals("changed function", dic.GetMap()["f1"]); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test3() { string baseName = GetBaseName(); string baseName2 = "2" + baseName; NeoDatis.Odb.ODB odb = Open(baseName); int size = 1000; for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), false); int j = 0; while (objects.HasNext() && j < objects.Count - 1) { odb.Delete(objects.Next()); j++; } odb.Close(); odb = Open(baseName); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); if (isLocal) { odb = Open(baseName); odb.DefragmentTo(NeoDatis.Odb.Test.ODBTest.Directory + baseName2); odb.Close(); odb = Open(baseName2); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); } DeleteBase(baseName); DeleteBase(baseName2); }
/// <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); }
/// <exception cref="System.Exception"></exception> public virtual void T1est() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria"); NeoDatis.Odb.OdbConfiguration.MonitorMemory(true); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2)); System.Decimal b = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2))); Println(b); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); AssertEquals(new System.Decimal("500000"), b); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test4() { string baseName = GetBaseName(); int n = isLocal ? 1000 : 10; NeoDatis.Odb.ODB odb = Open(baseName); long size = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.Function))); for (int i = 0; i < n; i++) { NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function ("login - " + (i + 1)); odb.Store(login); AssertEquals(size + i + 1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); } // IStorageEngine engine = Dummy.getEngine(odb); odb.Commit(); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); int j = 0; while (l.HasNext()) { // println("i="+i); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.Next (); odb.Delete(f); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function )); AssertEquals(size + n - (j + 1), l2.Count); j++; } odb.Commit(); odb.Close(); DeleteBase(baseName); }
public virtual void Test4() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where .Equal("name", "test2")); NeoDatis.Odb.Objects <Dictionnary> l = odb.GetObjects <Dictionnary>(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.SetMap(null); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects <Dictionnary>(query).GetFirst(); AssertEquals(null, dic.GetMap()); odb.Close(); }
public virtual void Test1WithCommit3() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p.AddFunction(new Function("f1")); User user = new User("user name 0" , "user email 0", p); odb.Store(user); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p2.AddFunction(new Function("f2")); User user2 = new User("user name 0" , "user email 0", p2); odb.Store(user2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <User> objects = null; for (int k = 0; k < 2; k++) { System.Console.Out.WriteLine(":" + k); objects = odb.GetObjects <User>(); while (objects.HasNext()) { user = (User)objects.Next(); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); Println(user.GetProfile().GetName()); odb.Store(user); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects <User>(); AssertEquals(2, objects.Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestList2() { DeleteBase("list1.neodatis"); NeoDatis.Odb.ODB odb = Open("list1.neodatis"); long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( PlayerWithList))); PlayerWithList player = new PlayerWithList ("kiko"); player.SetGames(null); odb.Store(player); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list1.neodatis"); NeoDatis.Odb.Objects l = odb2.GetObjects <PlayerWithList>(true); AssertEquals(nb + 1, l.Count); odb2.Close(); DeleteBase("list1.neodatis"); }