/// <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); }
public virtual void TestComplexInstance() { DeleteBase("t-complex-instance.neodatis"); NeoDatis.Odb.ODB odb = Open("t-complex-instance.neodatis"); Function login = new Function ("login"); Function logout = new Function ("logout"); List <Function> functions = new List <Function>(); functions.Add(login); functions.Add(logout); Profile profile = new Profile("profile1", functions); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("oliver" , "*****@*****.**", profile); NeoDatis.Odb.Test.VO.Login.User user22 = new NeoDatis.Odb.Test.VO.Login.User("oliver2" , "*****@*****.**", profile); odb.Store(user); odb.Store(user22); odb.Close(); odb = Open("t-complex-instance.neodatis"); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.User> l = odb.GetObjects <NeoDatis.Odb.Test.VO.Login.User>(true); NeoDatis.Odb.Test.VO.Login.User user2 = l.GetFirst(); // println("#### " + l.size() + " : " + l); AssertEquals(user.GetName(), user2.GetName()); AssertEquals(user.GetEmail(), user2.GetEmail()); AssertEquals(user.GetProfile().GetName(), user2.GetProfile().GetName()); AssertEquals(user.GetProfile().GetFunctions()[0].ToString(), user2.GetProfile().GetFunctions ()[0].ToString()); odb.Close(); DeleteBase("t-complex-instance.neodatis"); }
/// <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 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 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(); }
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); } }
/// <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(); }
public virtual void Test6() { DeleteBase("t1u.neodatis"); NeoDatis.Odb.ODB odb = Open("t1u.neodatis"); Function login = new Function ("login"); Function logout = new Function ("logout"); odb.Store(login); odb.Store(logout); odb.Close(); odb = Open("t1u.neodatis"); Function login2 = new Function ("login2"); Function logout2 = new Function ("logout2"); odb.Store(login2); odb.Store(logout2); // select without committing NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true); AssertEquals(4, l.Count); // println(l); odb.Close(); odb = Open("t1u.neodatis"); l = odb.GetObjects <Function>(true); AssertEquals(4, l.Count); // println(l); odb.Close(); }
public virtual void Test2_2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; int k = 10; long t1 = OdbTime.GetCurrentTimeInMs(); string[] fields = new string[] { "ok", "id", "name" }; odb = Open(baseName); for (int i = 0; i < k; i++) { odb.Store(new NeoDatis.Odb.Test.List.User("john" + (k - i), "*****@*****.**", "ny 875" , k - i + 1, new System.DateTime(t1 - i * 1000), i % 2 == 0)); odb.Store(new NeoDatis.Odb.Test.List.User("john" + (k - i), "*****@*****.**", "ny 875" , k - i, new System.DateTime(t1 - i * 1000), (i + 1) % 2 == 0)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.List.User)).OrderByDesc("ok,id,name"); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.List.User> users = odb.GetObjects <User>(q); odb.Close(); if (k < 11) { //NeoDatis.Tool.DisplayUtility.Display("test1", users); } NeoDatis.Odb.Test.List.User user = users.GetFirst(); AssertTrue(user.GetName().StartsWith("john10")); AssertEquals(11, user.GetId()); }
public virtual void TestDeleteListElements() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("name" ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f1")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f2")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("3")); odb.Store(p); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects <Profile>(); while (objects.HasNext()) { NeoDatis.Odb.Test.VO.Login.Profile profile = objects.Next(); System.Collections.IList functions = profile.GetFunctions(); for (int j = 0; j < functions.Count; j++) { odb.Delete(functions[j]); } odb.Delete(profile); } odb.Close(); }
/// <summary>Test select objects that are not yet commited</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestSelectUnCommitedObject() { 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.Function("function " + i)); } odb.Close(); // reopen the database odb = Open(BaseName); // stores a new function odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function uncommited")); NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function )); AssertEquals(5, functions.Count); } finally { if (odb != null) { odb.Close(); DeleteBase(BaseName); } } }
public virtual void Test22URL() { Java.Net.URL url1 = new Java.Net.URL("http://wiki.neodatis.org"); Java.Net.URL url2 = new Java.Net.URL("http://www.neodatis.org"); object o1 = url1.GetContent(); object o2 = url2.GetContent(); int h1 = url1.GetHashCode(); int h2 = url2.GetHashCode(); Println(h1 + " - " + h2); Println(url1.GetHost() + " - " + url1.GetDefaultPort() + " - " + url1.GetFile() + " - " + url1.GetRef()); Println(url2.GetHost() + " - " + url2.GetDefaultPort() + " - " + url2.GetFile() + " - " + url2.GetRef()); Println(url1.GetHost().GetHashCode() + " - " + url1.GetDefaultPort() + " - " + url1 .GetFile().GetHashCode() + " - " + url1.GetRef()); Println(url2.GetHost().GetHashCode() + " - " + url2.GetDefaultPort() + " - " + url2 .GetFile().GetHashCode() + " - " + url2.GetRef()); NeoDatis.Odb.ODB odb = Open(Name); odb.Store(url1); odb.Store(url2); odb.Close(); odb = Open(Name); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(Java.Net.URL)); odb.Close(); if (testNewFeature) { AssertEquals("Same HashCode Problem", 2, l.Count); } }
public virtual void TestCompositeCollection4() { DeleteBase("t5.neodatis"); NeoDatis.Odb.ODB odb = Open("t5.neodatis"); int nbUsers = odb.GetObjects <User>(true).Count; int nbProfiles = odb.GetObjects <Profile>(true).Count; int nbFunctions = odb.GetObjects <Function>(true).Count; Function login = new Function("login"); Function logout = new Function("logout"); System.Collections.Generic.IList <Function> list = new System.Collections.Generic.List <Function>(); list.Add(login); list.Add(logout); Profile profile1 = new Profile ("operator 1", list); User user = new User("olivier smadja" , "*****@*****.**", profile1); User userB = new User("Aísa Galvão Smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Store(userB); 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(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); }
public virtual void TestBigList() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); int size = 10000; int size2 = 4; long t0 = DateTime.Now.Ticks; for (int i = 0; i < size; i++) { PlayerWithList player = new PlayerWithList("player " + i); for (int j = 0; j < size2; j++) { player.AddGame("game " + j); } odb.Store(player); } odb.Close(); long t1 = DateTime.Now.Ticks; Console.WriteLine("insert : " + (t1 - t0) / 10000); NeoDatis.Odb.ODB odb2 = Open(baseName); NeoDatis.Odb.Objects <PlayerWithList> l = odb2.GetObjects <PlayerWithList>(false); long t2 = DateTime.Now.Ticks; AssertEquals(size, l.Count); Console.WriteLine("get objects " + l.Count + " : " + (t2 - t1) / 10000); odb2.Close(); DeleteBase(baseName); }
/// <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 Test4Sort() { string baseName = GetBaseName(); SetUp(baseName); int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree(); try { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40); NeoDatis.Odb.ODB odb = Open(baseName); CriteriaQuery aq = new CriteriaQuery (typeof(Function), Where .Not(Where.Or().Add(Where .Equal("name", "function 2")).Add(Where.Equal("name" , "function 3")))); aq.OrderByDesc("name"); // aq.orderByAsc("name"); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(aq, true, -1, -1); odb.Close(); AssertEquals(48, l.Count); Function f = (Function)l.GetFirst (); AssertEquals("function 9", f.GetName()); } finally { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d); } }
public virtual void Test1() { DeleteBase("t1.neodatis"); // LogUtil.allOn(true); NeoDatis.Odb.ODB odb = Open("t1.neodatis"); // LogUtil.objectWriterOn(true); Function login = new Function ("login"); System.Collections.Generic.IList <Function> list = new System.Collections.Generic.List <Function>(); list.Add(login); Profile profile1 = new Profile ("operator 1", list); User user = new User("olivier smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Close(); odb = Open("t1.neodatis"); NeoDatis.Odb.Objects <User> users = odb.GetObjects <User>(true); // assertEquals(nbUsers+2,users.size()); User user2 = (User)users.GetFirst (); odb.Close(); AssertEquals(user.ToString(), user2.ToString()); DeleteBase("t1.neodatis"); }
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"); }
public virtual void TestStringPersistence() { NeoDatis.Odb.ODB odb = null; try { odb = Open("date.neodatis"); TestClass tc1 = new TestClass (); tc1.SetString1(string.Empty); odb.Store(tc1); odb.Close(); odb = Open("date.neodatis"); NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(); AssertEquals(1, l.Count); TestClass tc2 = (TestClass )l.GetFirst(); AssertEquals(string.Empty, tc2.GetString1()); AssertEquals(null, tc2.GetBigDecimal1()); AssertEquals(null, tc2.GetDouble1()); } finally { if (odb != null) { odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void DisplayObjectsOf(System.Type clazz, string label1, string label2 ) { // Open the database NeoDatis.Odb.ODB odb = null; try { odb = Open(OdbName); // Get all object of type clazz NeoDatis.Odb.Objects objects = odb.GetObjects(clazz); System.Console.Out.WriteLine("\n" + label1 + " : " + objects.Count + label2); int i = 1; // display each object while (objects.HasNext()) { System.Console.Out.WriteLine((i++) + "\t: " + objects.Next()); } } finally { if (odb != null) { // Close the database odb.Close(); } } }
public virtual void TestDatePersistence() { NeoDatis.Odb.ODB odb = null; DeleteBase("date.neodatis"); try { odb = Open("date.neodatis"); TestClass tc1 = new TestClass (); tc1.SetDate1(new System.DateTime()); long t1 = tc1.GetDate1().Millisecond; odb.Store(tc1); odb.Close(); odb = Open("date.neodatis"); NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(); AssertEquals(1, l.Count); TestClass tc2 = (TestClass)l.GetFirst(); AssertEquals(t1, tc2.GetDate1().Millisecond); AssertEquals(tc1.GetDate1(), tc2.GetDate1()); } finally { if (odb != null) { odb.Close(); } } DeleteBase("date.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); }
public virtual void TestSimple() { DeleteBase("t2.neodatis"); NeoDatis.Odb.ODB odb = Open("t2.neodatis"); int nbFunctions = odb.GetObjects <Function>(true).Count; Function login = new Function("login"); Function logout = new Function("logout"); odb.Store(login); odb.Store(logout); odb.Close(); odb = Open("t2.neodatis"); NeoDatis.Odb.Objects <Function> functions = odb.GetObjects <Function>(true); Function f1 = (Function)functions.GetFirst(); f1.SetName("login1"); odb.Store(f1); odb.Close(); odb = Open("t2.neodatis"); functions = odb.GetObjects <Function>(true); odb.Close(); AssertEquals(2, functions.Count); AssertEquals("login1", ((Function)functions.GetFirst() ).GetName()); DeleteBase("t2.neodatis"); }
public virtual void Test2() { DeleteBase("map-with-collections"); NeoDatis.Odb.ODB odb = null; odb = Open("map-with-collections"); NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject o = new NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject ("test"); System.Collections.Generic.IList <MyMapObject> c = new System.Collections.Generic.List <MyMapObject>(); c.Add(o); o.GetMap().Add("c", c); odb.Store(o); odb.Close(); odb = Open("map-with-collections"); NeoDatis.Odb.Objects <MyMapObject> os = odb.GetObjects <MyMapObject>(); MyMapObject mmo = os.GetFirst(); odb.Close(); DeleteBase("map-with-collections"); AssertEquals(o.GetName(), mmo.GetName()); AssertEquals(o.GetMap().Count, mmo.GetMap().Count); System.Collections.ICollection c1 = (System.Collections.ICollection)o.GetMap()["c" ]; System.Collections.ICollection c2 = (System.Collections.ICollection)mmo.GetMap()[ "c"]; AssertEquals(c1.Count, c2.Count); AssertEquals(mmo, c2.GetEnumerator().Current); }
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 Test3() { // LogUtil.objectReaderOn(true); DeleteBase("map-with-collections"); NeoDatis.Odb.ODB odb = null; odb = Open("map-with-collections"); MyMapObject o = new MyMapObject("test"); System.Collections.Generic.IList <MyMapObject> c = new System.Collections.Generic.List <MyMapObject>(); c.Add(o); Function f1 = new Function("function1"); o.GetMap().Add("a", c); int size = 1; for (int i = 0; i < size; i++) { o.GetMap().Add("A" + i, f1); } o.GetMap().Add("c", f1); Println("RealMap" + o.GetMap()); odb.Store(o); odb.Close(); odb = Open("map-with-collections"); NeoDatis.Odb.Objects <MyMapObject> os = odb.GetObjects <MyMapObject>(); NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject mmo = (NeoDatis.Odb.Test.Arraycollectionmap.MyMapObject )os.GetFirst(); odb.Close(); DeleteBase("map-with-collections"); AssertEquals(o.GetName(), mmo.GetName()); AssertEquals(size + 2, mmo.GetMap().Count); AssertEquals(mmo, ((System.Collections.ICollection)mmo.GetMap()["a"]).GetEnumerator ().Current); AssertEquals("function1", mmo.GetMap()["c"].ToString()); }
public virtual void TestList4Update5() { 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(); int size = isLocal ? 1000 : 100; for (int i = 0; i < size; i++) { NeoDatis.Odb.ODB odb2 = Open("list5.neodatis"); NeoDatis.Odb.Objects <ObjectWithListOfInteger> ll = odb2.GetObjects <ObjectWithListOfInteger>(true); ObjectWithListOfInteger o2 = (ObjectWithListOfInteger )ll.GetFirst(); o2.GetListOfIntegers().Add(200 + i); odb2.Store(o2); odb2.Close(); } NeoDatis.Odb.ODB odb3 = Open("list5.neodatis"); NeoDatis.Odb.Objects <ObjectWithListOfInteger> l = odb3.GetObjects <ObjectWithListOfInteger>(true); AssertEquals(1, l.Count); ObjectWithListOfInteger o3 = l.GetFirst(); AssertEquals(size + 1, o3.GetListOfIntegers().Count); odb3.Close(); DeleteBase("list5.neodatis"); }
public virtual void TestDate1() { string baseName = GetBaseName(); SetUp(baseName); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.Query.Criteria.MyDates myDates = new NeoDatis.Odb.Test.Query.Criteria.MyDates (); System.DateTime d1 = new System.DateTime(); Thread.Sleep(100); System.DateTime d2 = new System.DateTime(); Thread.Sleep(100); System.DateTime d3 = new System.DateTime(); myDates.SetDate1(d1); myDates.SetDate2(d3); myDates.SetI(5); odb.Store(myDates); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery (typeof(MyDates), Where .And().Add(Where.Le("date1", d2)).Add(Where .Ge("date2", d2)).Add(Where.Equal("i", 5))); NeoDatis.Odb.Objects <MyDates> objects = odb.GetObjects <MyDates>(query); AssertEquals(1, objects.Count); odb.Close(); }
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(new Player("player1", new System.DateTime(), new Sport("sport1"))); t1.AddPlayer(new Player("player2", new System.DateTime(), new 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 virtual void Test4Sort() { int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree(); try { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40); NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Or().Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function 2")).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name" , "function 3")))); aq.OrderByDesc("name"); // aq.orderByAsc("name"); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(48, l.Count); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst (); AssertEquals("function 9", f.GetName()); odb.Close(); } finally { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d); } }
public GetMessageResponse(string baseId, string connectionId, NeoDatis.Odb.Objects <NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo> metaObjects, NeoDatis.Odb.Core.Query.Execution.IQueryExecutionPlan plan) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command.Get, baseId, connectionId) { this.metaObjects = metaObjects; this.plan = plan; }