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 TestUpdateRelation() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); // first create a function Function f = new Function("f1" ); odb.Store(f); odb.Close(); odb = Open(baseName); // reloads the function NeoDatis.Odb.Objects <Function> functions = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "f1"))); Function f1 = functions.GetFirst(); // Create a profile with the loaded function Profile profile = new Profile ("test", f1); odb.Store(profile); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Profile> profiles = odb.GetObjects <Profile>(); functions = odb.GetObjects <Function>(); odb.Close(); DeleteBase(baseName); AssertEquals(1, functions.Count); AssertEquals(1, profiles.Count); }
public virtual void TestReuse() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <Profile> profiles = new System.Collections.Generic.List <Profile>(); profiles.Add(new Profile("p1", new Function ("f1"))); profiles.Add(new Profile("p2", new Function ("f2"))); ClassB cb = new ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); Profile p = (Profile)odb.GetObjects <Profile>().GetFirst(); CriteriaQuery query = odb.CriteriaQuery(typeof( ClassB), Where.Equal("profiles", p)); EqualCriterion ec = (EqualCriterion )query.GetCriteria(); try { NeoDatis.Odb.Objects <ClassB> l = odb.GetObjects <ClassB>( 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() { NeoDatis.Odb.ODB odb = Open(FileName); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("name", "function 10")); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(query); int size = l.Count; AssertFalse(l.Count == 0); Function f = (Function)l.GetFirst (); NeoDatis.Odb.OID id = odb.GetObjectId(f); AssertEquals("function 10", f.GetName()); string newName = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs().ToString(); f.SetName(newName); odb.Store(f); odb.Close(); odb = Open(FileName); l = odb.GetObjects <Function>(query); query = new CriteriaQuery(Where.Equal("name", newName)); AssertTrue(size == l.Count + 1); l = odb.GetObjects <Function>(query); AssertFalse(l.Count == 0); AssertEquals(1, l.Count); AssertEquals(id, odb.GetObjectId(l.GetFirst())); odb.Close(); }
/// <summary> /// Test updating a non native attribute than wall null with an already /// existing non native object without comit /// </summary> /// <exception cref="System.Exception"></exception> public virtual void TestUpdateObjectReference4() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); User user = new User("olivier smadja" , "*****@*****.**", null); odb.Store(user); odb.Close(); Profile profile2 = new Profile ("new operator", function); odb = Open(FileName); odb.Store(profile2); User user2 = odb.GetObjects <User>().GetFirst(); user2.SetProfile(profile2); odb.Store(user2); odb.Close(); odb = Open(FileName); user2 = odb.GetObjects <User>().GetFirst(); AssertEquals("new operator", user2.GetProfile().GetName()); AssertEquals(1, odb.GetObjects <Profile>().Count); odb.Close(); }
public virtual void Test19() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); Function f1 = new Function( "function1"); odb.Store(f1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); AssertEquals(1, objects.Count); Function f2 = (Function)objects .GetFirst(); NeoDatis.Odb.OID oid = odb.GetObjectId(f2); odb.DeleteObjectWithId(oid); AssertEquals(0, odb.GetObjects <Function>().Count ); odb.Close(); odb = Open(baseName); objects = odb.GetObjects <Function>(); AssertEquals(0, objects.Count); }
public virtual void TestSelectUnCommitedObject2() { NeoDatis.Odb.ODB odb = null; try { DeleteBase(BaseName); odb = Open(BaseName); for (int i = 0; i < 4; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Login.User("user" + i, "email" + i, new NeoDatis.Odb.Test.VO.Login.Profile ("profile" + i, new NeoDatis.Odb.Test.VO.Login.Function("function" + i)))); } odb.Close(); // reopen the database odb = Open(BaseName); // stores a new function odb.Store(new NeoDatis.Odb.Test.VO.Login.User("uncommited user", "uncommied email" , new NeoDatis.Odb.Test.VO.Login.Profile("uncommiedt profile", new NeoDatis.Odb.Test.VO.Login.Function ("uncommited function")))); NeoDatis.Odb.Objects <User> users = odb.GetObjects <User>(); AssertEquals(5, users.Count); NeoDatis.Odb.Objects <Function> functions = odb.GetObjects <Function>(); AssertEquals(5, functions.Count); NeoDatis.Odb.Objects <Profile> profiles = odb.GetObjects <Profile>(); AssertEquals(5, profiles.Count); } finally { if (odb != null) { odb.Close(); DeleteBase(BaseName); } } }
/// <exception cref="System.Exception"></exception> public virtual void Test6() { DeleteBase("t1u.neodatis"); NeoDatis.Odb.ODB odb = Open("t1u.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"); odb.Store(login); odb.Store(logout); odb.Close(); odb = Open("t1u.neodatis"); NeoDatis.Odb.Test.VO.Login.Function login2 = new NeoDatis.Odb.Test.VO.Login.Function ("login2"); NeoDatis.Odb.Test.VO.Login.Function logout2 = new NeoDatis.Odb.Test.VO.Login.Function ("logout2"); odb.Store(login2); odb.Store(logout2); // select without committing NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(4, l.Count); // println(l); odb.Close(); odb = Open("t1u.neodatis"); l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true); AssertEquals(4, l.Count); // println(l); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test6() { MyObject mo = null; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); mo = new MyObject(15, "oli"); mo.SetDate(new System.DateTime()); odb.Store(mo); odb.Close(); odb = Open(FileName); MyObject mo2 = odb.GetObjects <MyObject>().GetFirst(); mo2.SetDate(new System.DateTime(mo.GetDate().Millisecond + 10)); mo2.SetSize(mo.GetSize() + 1); odb.Store(mo2); odb.Close(); odb = Open(FileName); MyObject mo3 = (MyObject)odb.GetObjects <MyObject>().GetFirst(); AssertEquals(mo3.GetDate().Millisecond, mo2.GetDate().Millisecond); AssertTrue(mo3.GetDate().Millisecond > mo.GetDate().Millisecond); AssertTrue(mo3.GetSize() == mo.GetSize() + 1); odb.Close(); }
/// <summary>a problem reported by glsender - 1875544</summary> /// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode my = null; // creates 1000 objects for (int i = 0; i < 1000; i++) { my = new NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode(System.Convert.ToInt64(1000 )); odb.Store(my); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode )); AssertEquals(1000, objects.Count); while (objects.HasNext()) { my = (NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode)objects.Next(); odb.Delete(my); } odb.Close(); odb = Open(baseName); objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode)); odb.Close(); NeoDatis.Tool.IOUtil.DeleteFile(baseName); AssertEquals(0, objects.Count); }
// deleteBase("t5.neodatis"); /// <exception cref="System.Exception"></exception> public virtual void TestSimple() { DeleteBase("t2.neodatis"); NeoDatis.Odb.ODB odb = Open("t2.neodatis"); 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"); odb.Store(login); odb.Store(logout); odb.Close(); odb = Open("t2.neodatis"); NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); NeoDatis.Odb.Test.VO.Login.Function f1 = (NeoDatis.Odb.Test.VO.Login.Function)functions .GetFirst(); f1.SetName("login1"); odb.Store(f1); odb.Close(); odb = Open("t2.neodatis"); functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true); odb.Close(); AssertEquals(2, functions.Count); AssertEquals("login1", ((NeoDatis.Odb.Test.VO.Login.Function)functions.GetFirst() ).GetName()); DeleteBase("t2.neodatis"); }
/// <summary>Stores an object User that has a non null reference to a Profile.</summary> /// <remarks> /// Stores an object User that has a non null reference to a Profile. 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() { Println("************START OF TEST1***************"); string baseName = GetBaseName(); DeleteBase("index-object"); NeoDatis.Odb.ODB odb = Open("index-object"); string[] fields = new string[] { "object" }; odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject2)).AddUniqueIndexOn ("index1", fields, true); NeoDatis.Odb.Test.Index.IndexedObject2 o1 = new NeoDatis.Odb.Test.Index.IndexedObject2 ("Object1", new NeoDatis.Odb.Test.Index.IndexedObject("Inner Object 1", 10, new System.DateTime())); odb.Store(o1); odb.Close(); odb = Open("index-object"); // First get the object used to index NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Index.IndexedObject )); NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject )objects.GetFirst(); NeoDatis.Odb.Core.Query.IQuery q = odb.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject2 ), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("object", io)); objects = odb.GetObjects(q); NeoDatis.Odb.Test.Index.IndexedObject2 o2 = (NeoDatis.Odb.Test.Index.IndexedObject2 )objects.GetFirst(); odb.Close(); AssertEquals(o1.GetName(), o2.GetName()); Println(q.GetExecutionPlan().GetDetails()); AssertFalse(q.GetExecutionPlan().GetDetails().IndexOf("index1") == -1); DeleteBase("index-object"); Println("************END OF TEST1***************"); }
public virtual void TestList4Update3() { DeleteBase("list5.neodatis"); NeoDatis.Odb.ODB odb = Open("list5.neodatis"); ObjectWithListOfInteger o = new ObjectWithListOfInteger ("test"); o.GetListOfIntegers().Add(System.Convert.ToInt32("100")); odb.Store(o); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list5.neodatis"); NeoDatis.Odb.Objects <ObjectWithListOfInteger> l = odb2.GetObjects <ObjectWithListOfInteger>(true); ObjectWithListOfInteger o2 = (ObjectWithListOfInteger )l.GetFirst(); o2.GetListOfIntegers().Clear(); o2.GetListOfIntegers().Add(System.Convert.ToInt32("200")); odb2.Store(o2); odb2.Close(); odb2 = Open("list5.neodatis"); l = odb2.GetObjects <ObjectWithListOfInteger>(true); AssertEquals(1, l.Count); ObjectWithListOfInteger o3 = l.GetFirst(); AssertEquals(1, o3.GetListOfIntegers().Count); AssertEquals(System.Convert.ToInt32("200"), o3.GetListOfIntegers()[0]); odb2.Close(); DeleteBase("list5.neodatis"); }
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 "); } Function login = new Function (b.ToString()); Profile profile1 = new Profile ("operator 1", login); User user = new User("olivier smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Commit(); 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+2,users.size()); User user2 = (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); }
// println("before:" + mo.getDate().getTime() + " - " + mo.getSize()); // println("after:" + mo3.getDate().getTime() + " - " + mo3.getSize()); /// <summary> /// When an object an a collection attribute, and this colllection is changed /// (adding one object),no update in place is possible for instance. /// </summary> /// <remarks> /// When an object an a collection attribute, and this colllection is changed /// (adding one object),no update in place is possible for instance. /// </remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test7() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); Profile profile = new Profile ("operator", function); User user = new User("olivier smadja" , "*****@*****.**", profile); odb.Store(user); odb.Close(); odb = Open(FileName); User user2 = odb.GetObjects <User>().GetFirst(); user2.GetProfile().AddFunction(new Function("new Function" )); odb.Store(user2); odb.Close(); odb = Open(FileName); User user3 = (User)odb.GetObjects <User>().GetFirst(); AssertEquals(2, user3.GetProfile().GetFunctions().Count); Function f1 = (Function)user3 .GetProfile().GetFunctions()[0]; Function f2 = (Function)user3 .GetProfile().GetFunctions()[1]; AssertEquals("login", f1.GetName()); AssertEquals("new Function", f2.GetName()); odb.Close(); }
public virtual void Test10() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); long size = odb.GetObjects <Function>().Count; Function f1 = new Function( "function1"); odb.Store(f1); odb.Close(); odb = Open(baseName); Function f1bis = (Function) odb.GetObjects <Function>().GetFirst(); odb.Delete(f1bis); odb.Close(); odb = Open(baseName); AssertEquals(size, odb.GetObjects <Function>().Count ); odb.Store(new Function("last function")); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(); odb.Close(); AssertEquals(size + 1, l.Count); }
/// <summary>setting one attribute to null</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test8() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); Profile profile = new Profile ("operator", function); User user = new User("olivier smadja" , "*****@*****.**", profile); odb.Store(user); odb.Close(); odb = Open(FileName); User user2 = (User)odb.GetObjects <User>().GetFirst(); user2.SetProfile(null); odb.Store(user2); odb.Close(); odb = Open(FileName); User user3 = (User)odb.GetObjects <User>().GetFirst(); AssertNull(user3.GetProfile()); odb.Close(); }
public virtual void Test20() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); Function f0 = new Function( "1function0"); odb.Store(f0); odb.Close(); odb = Open(baseName); Function f1 = new Function( "function1"); odb.Store(f1); odb.Commit(); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Like("name", "func%"))); AssertEquals(1, objects.Count); Function f2 = (Function)objects .GetFirst(); NeoDatis.Odb.OID oid = odb.GetObjectId(f2); odb.DeleteObjectWithId(oid); AssertEquals(1, odb.GetObjects <Function>().Count ); odb.Close(); odb = Open(baseName); objects = odb.GetObjects <Function>(); AssertEquals(1, objects.Count); }
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 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(); }
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(); }
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); }
/// <exception cref="System.Exception"></exception> public virtual void Test6() { // LogUtil.objectWriterOn(true); DeleteBase("t6.neodatis"); NeoDatis.Odb.ODB odb = Open("t6.neodatis"); NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function ("login"); NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function ("logout"); System.Collections.IList list = new System.Collections.ArrayList(); list.Add(login); list.Add(logout); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator", list); NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Close(); Println("----------"); odb = Open("t6.neodatis"); NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), true); NeoDatis.Odb.Test.VO.Login.User u1 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst (); u1.GetProfile().SetName("operator 234567891011121314"); odb.Store(u1); odb.Close(); odb = Open("t6.neodatis"); NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile ), true); AssertEquals(1, profiles.Count); NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)profiles .GetFirst(); AssertEquals(u1.GetProfile().GetName(), p1.GetName()); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { NeoDatis.Odb.ODB odb = Open("big-data.neodatis"); System.Text.StringBuilder buffer = new System.Text.StringBuilder(); for (int i = 0; i < 30000; i++) { buffer.Append('a'); } NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function (buffer.ToString()); odb.Store(function); odb.Close(); odb = Open("big-data.neodatis"); NeoDatis.Odb.Test.VO.Login.Function f2 = (Function)odb .GetObjects <Function>().GetFirst(); AssertEquals(30000, f2.GetName().Length); odb.Close(); odb = Open("big-data.neodatis"); f2 = (Function)odb.GetObjects <Function>().GetFirst(); f2.SetName(f2.GetName() + "ola chico"); int newSize = f2.GetName().Length; odb.Store(f2); odb.Close(); odb = Open("big-data.neodatis"); f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjects <Function>().GetFirst(); AssertEquals(newSize, f2.GetName().Length); AssertEquals(buffer.ToString() + "ola chico", f2.GetName()); odb.Close(); }
public virtual void TestCriteriaQueryQueryWithValueInList2() { string baseName = GetBaseName(); SetUp(baseName); NeoDatis.Odb.ODB odb = Open(baseName); Profile p0 = new Profile("profile0" ); p0.AddFunction(new Function("f1")); p0.AddFunction(new Function("f2")); Profile p1 = new Profile("profile1" ); p0.AddFunction(new Function("f12")); p0.AddFunction(new Function("f22")); User user = new User("The user" , "themail", p0); User user2 = new User("The user2" , "themail2", p1); odb.Store(user); odb.Store(user2); odb.Close(); odb = Open(baseName); Function f2bis = (Function) odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "f2"))).GetFirst(); CriteriaQuery query = odb.CriteriaQuery(typeof(Profile), Where.Contain("functions", f2bis)); NeoDatis.Odb.Objects <Profile> l = odb.GetObjects <Profile>(query); AssertEquals(1, l.Count); p1 = l.GetFirst(); AssertEquals("profile0", p1.GetName()); odb.Close(); }
/// <summary>one object has a list.</summary> /// <remarks> /// one object has a list. we delete one of the object of the list of the /// object. And the main object still has it /// </remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestDeletingOneElementOfTheList() { if (!testNewFeature) { return; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Sport.Team t1 = new NeoDatis.Odb.Test.VO.Sport.Team("team1"); t1.AddPlayer(Player("player1", new System.DateTime(), new Sport("sport1"))); t1.AddPlayer(new NeoDatis.Odb.Test.VO.Sport.Player("player2", new System.DateTime(), new Sport.Sport("sport2"))); odb.Store(t1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Team> teams = odb.GetObjects <Team>(); Team team = teams.GetFirst(); AssertEquals(2, team.GetPlayers().Count); NeoDatis.Odb.Objects <Player> players = odb.GetObjects <Player>(); Player p1 = players.GetFirst(); odb.Delete(p1); odb.Close(); AssertEquals(1, team.GetPlayers().Count); }
/// <exception cref="System.Exception"></exception> public override void SetUp() { base.SetUp(); DeleteBase("t-school.neodatis"); NeoDatis.Odb.ODB odb = Open("t-school.neodatis"); NeoDatis.Odb.Objects <Student> students = odb.GetObjects <Student>(true); int numStudents = students.Count; Course computerScience = new Course ("Computer Science"); Teacher teacher = new Teacher ("Jeremias", "Java"); Discipline dw1 = new Discipline ("Des. Web 1", 3); Discipline @is = new Discipline ("Intranet/Segurança", 4); Student std1 = new Student (20, computerScience, new System.DateTime(), "1cs", "Brenna"); History h1 = new History( new System.DateTime(), dw1, 0, teacher); History h2 = new History( new System.DateTime(), @is, 0, teacher); std1.AddHistory(h1); std1.AddHistory(h2); odb.Store(std1); odb.Commit(); odb.Close(); odb = Open("t-school.neodatis"); students = odb.GetObjects <Student>(true); odb.Close(); AssertEquals(numStudents + 1, students.Count); }
// possiveis consultas // Listar todos os alunos de determinado professor // Listar alunos com nota abaixo de x // Listar disciplinas que um professor ministrou no semestre /// <exception cref="System.Exception"></exception> public virtual void Test1() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = Open("t-school.neodatis"); // List students by name SchoolNativeQueryStudent natQuery = new SchoolNativeQueryStudent("Brenna", 23); NeoDatis.Odb.Objects <Student> students = odb.GetObjects <Student>(natQuery); SchoolSimpleNativeQueryStudent sNatQuery = new SchoolSimpleNativeQueryStudent("Brenna"); students = odb.GetObjects <Student>(sNatQuery); // list disciplines of one teacher by semester SchoolNativeQueryTeacher natQuery2 = new SchoolNativeQueryTeacher ("Jeremias"); NeoDatis.Odb.Objects <History> historys = odb.GetObjects <History>(natQuery2); System.Collections.Hashtable listDiscipline = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <string, Discipline>(); for (System.Collections.IEnumerator iter = historys.GetEnumerator(); iter.MoveNext ();) { History h = (History)iter .Current; listDiscipline.Add(h.GetDiscipline().GetName(), h.GetDiscipline()); } odb.Close(); }
public virtual void Test8RollbackDeleteAndStore() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("f1")); odb.Store(new Function("f2")); odb.Store(new Function("f3")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { Function f = (Function)objects .Next(); f.SetName(OdbString.Substring(f.GetName(), 1)); odb.Store(f); } objects.Reset(); while (objects.HasNext()) { odb.Delete(objects.Next()); } for (int i = 0; i < 500; i++) { odb.Store(new Function("f3 - " + i)); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
public virtual void TestInsert() { DeleteBase(NewbieOdb); odb = Open(NewbieOdb); Driver marcelo = new Driver ("marcelo"); Car car = new Car("car1", 4, "ranger", marcelo); Car car1 = new Car("car2" , 2, "porche"); Car car2 = new Car("car3" , 2, "fusca"); Car car3 = new Car("car4" , 4, "opala"); Car car4 = new Car("car5" , 4, "vectra", marcelo); try { // open is called on NewbieTest // insert 5 car's odb.Store(car); odb.Store(car1); odb.Store(car2); odb.Store(car3); odb.Store(car4); // find for all car objects NeoDatis.Odb.Objects<Car> cars = odb.GetObjects<Car>(); AssertEquals("The objects weren't added correctly", 5, cars.Count); // find for a specific car object CriteriaQuery query = new CriteriaQuery(typeof(Car), Where.Equal("name", "car1")); cars = odb.GetObjects<Car>(query); AssertEquals("The objects couldn't be found correctly", 1, cars.Count); // find for a specific composition query = new CriteriaQuery(typeof(Car), Where.Equal("driver.name", "marcelo")); cars = odb.GetObjects<Car>(query); AssertEquals("The objects couldn't be found correctly", 2, cars.Count); odb.Commit(); odb.Close(); DeleteBase(NewbieOdb); } catch (System.Exception e) { Console.WriteLine(e); } }
public virtual void TestUpdate() { try { DeleteBase(NewbieOdb); odb = Open(NewbieOdb); Driver marcelo = new Driver("marcelo"); Car car = new Car("car1", 4, "ranger", marcelo); odb.Store(car); CriteriaQuery query = new CriteriaQuery(Where.Equal("driver.name", "marcelo")); Car newCar = (Car)odb.GetObjects<Car>(query).GetFirst(); newCar.SetDriver(new Driver("dani")); odb.Store(newCar); odb.Commit(); query = new CriteriaQuery(Where.Equal("driver.name", "dani")); AssertEquals(1, odb.GetObjects<Car>(query).Count); odb.Close(); DeleteBase(NewbieOdb); } catch (System.Exception e) { throw e; } }