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 Test21() { DeleteBase("nullo"); GenericClass gc = new GenericClass(null); NeoDatis.Odb.ODB odb = Open("nullo"); odb.Store(gc); odb.Close(); odb = Open("nullo"); NeoDatis.Odb.Objects <GenericClass> objects = odb.GetObjects <GenericClass>(); GenericClass gc2 = objects.GetFirst(); long[] longs = { 1, 2 }; gc2.SetObjects(longs); odb.Store(gc2); odb.Close(); odb = Open("nullo"); objects = odb.GetObjects <GenericClass>(); AssertEquals(1, objects.Count); GenericClass gc3 = objects.GetFirst(); Long[] longs2 = (Long[])gc3.GetObjects(); AssertEquals(2, longs2.Length); AssertEquals(System.Convert.ToInt64(1), longs2[0]); AssertEquals(System.Convert.ToInt64(2), longs2[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(); }
/// <exception cref="System.Exception"></exception> public virtual void Test21() { DeleteBase("nullo"); NeoDatis.Odb.Test.Nullobject.GenericClass gc = new NeoDatis.Odb.Test.Nullobject.GenericClass (null); NeoDatis.Odb.ODB odb = Open("nullo"); odb.Store(gc); odb.Close(); odb = Open("nullo"); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Nullobject.GenericClass )); NeoDatis.Odb.Test.Nullobject.GenericClass gc2 = (NeoDatis.Odb.Test.Nullobject.GenericClass )objects.GetFirst(); long[] longs = new long[] { System.Convert.ToInt64(1), System.Convert.ToInt64(2) }; gc2.SetObjects(longs); odb.Store(gc2); odb.Close(); odb = Open("nullo"); objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Nullobject.GenericClass)); AssertEquals(1, objects.Count); NeoDatis.Odb.Test.Nullobject.GenericClass gc3 = (NeoDatis.Odb.Test.Nullobject.GenericClass )objects.GetFirst(); long[] longs2 = (long[])gc3.GetObjects(); AssertEquals(2, longs2.Length); AssertEquals(System.Convert.ToInt64(1), longs2[0]); AssertEquals(System.Convert.ToInt64(2), longs2[1]); odb.Close(); }
public virtual void Test23() { DeleteBase("nullo"); NeoDatis.Odb.Test.Nullobject.GenericClass gc = new NeoDatis.Odb.Test.Nullobject.GenericClass (null); gc.GetObjects()[0] = new NeoDatis.Odb.Test.VO.Login.Function("f1"); NeoDatis.Odb.ODB odb = Open("nullo"); odb.Store(gc); odb.Close(); odb = Open("nullo"); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Nullobject.GenericClass )); NeoDatis.Odb.Test.Nullobject.GenericClass gc2 = (NeoDatis.Odb.Test.Nullobject.GenericClass )objects.GetFirst(); gc2.GetObjects()[0] = System.Convert.ToInt64(1); gc2.GetObjects()[1] = System.Convert.ToInt64(2); odb.Store(gc2); odb.Close(); odb = Open("nullo"); objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Nullobject.GenericClass)); AssertEquals(1, objects.Count); NeoDatis.Odb.Test.Nullobject.GenericClass gc3 = (NeoDatis.Odb.Test.Nullobject.GenericClass )objects.GetFirst(); object[] longs2 = (object[])gc3.GetObjects(); AssertEquals(10, longs2.Length); AssertEquals(System.Convert.ToInt64(1), longs2[0]); AssertEquals(System.Convert.ToInt64(2), longs2[1]); odb.Close(); }
/// <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***************"); }
/// <summary>Test update object list.</summary> /// <remarks>Test update object list. A list of Integer</remarks> /// <exception cref="System.Exception"></exception> 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 TestArray5() { NeoDatis.Odb.ODB odb = null; int size = 50; try { NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); } ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumber(0, new System.Decimal(1)); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = l.GetFirst(); AssertEquals(owna2.GetNumber(0), o.GetNumber(0)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); if (isLocal) { // check that it was in place update and not normal update (by // creatig now object) AssertEquals(0, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbInPlaceUpdates()); AssertEquals(1, NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter. GetNbNormalUpdates()); } } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void TestArrayUpdateDecreasingArraySize() { NeoDatis.Odb.ODB odb = null; int size = 50; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.Decimal[] array = new System.Decimal[size]; System.Decimal[] array2 = new System.Decimal[size + 1]; for (int i = 0; i < size; i++) { array[i] = new System.Decimal(((double)i) * 78954545 / 89); array2[i] = new System.Decimal(((double)i) * 78954545 / 89); } array[size - 1] = new System.Decimal(99); array2[size] = new System.Decimal(100); ObjectWithNativeArrayOfBigDecimal owna = new ObjectWithNativeArrayOfBigDecimal("t1", array2 ); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfBigDecimal> l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal owna2 = l.GetFirst(); owna2.SetNumbers(array); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects <ObjectWithNativeArrayOfBigDecimal>(); ObjectWithNativeArrayOfBigDecimal o = (ObjectWithNativeArrayOfBigDecimal )l.GetFirst(); AssertEquals(size, o.GetNumbers().Length); AssertEquals(new System.Decimal(99), o.GetNumber(size - 1)); AssertEquals(owna2.GetNumber(1), o.GetNumber(1)); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
/// <exception cref="System.Exception"></exception> public virtual void Test4() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); string[] fields = new string[] { "object" }; odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject2)).AddUniqueIndexOn ("index1", fields, true); string[] fields2 = new string[] { "name" }; odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn ("index2", fields2, true); int size = isLocal ? 5000 : 500; for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.Index.IndexedObject2("Object " + i, new NeoDatis.Odb.Test.Index.IndexedObject ("Inner Object " + i, i, new System.DateTime()))); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "Inner Object " + (size - 1))); // First get the object used to index, the last one. There is no index // on the class and field long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Objects objects = odb.GetObjects(q); long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // check if index has been used AssertTrue(q.GetExecutionPlan().UseIndex()); NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject )objects.GetFirst(); Println("d0=" + (end0 - start0)); Println(q.GetExecutionPlan().GetDetails()); q = odb.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject2), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("object", io)); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); objects = odb.GetObjects(q); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println("d=" + (end - start)); NeoDatis.Odb.Test.Index.IndexedObject2 o2 = (NeoDatis.Odb.Test.Index.IndexedObject2 )objects.GetFirst(); odb.Close(); AssertEquals("Object " + (size - 1), o2.GetName()); Println(q.GetExecutionPlan().GetDetails()); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
public virtual void TestArray61() { NeoDatis.Odb.ODB odb = null; int size = 50; try { NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = i; } ObjectWithNativeArrayOfInt owna = new ObjectWithNativeArrayOfInt ("t1", array); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfInt> l = odb.GetObjects <ObjectWithNativeArrayOfInt>(); ObjectWithNativeArrayOfInt owna2 = (ObjectWithNativeArrayOfInt )l.GetFirst(); owna2.SetNumber(1, 78); odb.Store(owna2); odb.Close(); odb = Open("array1.neodatis"); l = odb.GetObjects <ObjectWithNativeArrayOfInt>(); ObjectWithNativeArrayOfInt o = l.GetFirst(); AssertEquals(0, o.GetNumber(0)); AssertEquals(78, o.GetNumber(1)); } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
/// <exception cref="System.Exception"></exception> 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> private void CheckCarRetrieval() { NeoDatis.Odb.Objects cars = odb.GetObjects(typeof(NeoDatis.Odb.Test.Instantiationhelper.Car )); AssertEquals(1, cars.Count); NeoDatis.Odb.Test.Instantiationhelper.Car car = (NeoDatis.Odb.Test.Instantiationhelper.Car )cars.GetFirst(); AssertEquals(car.GetModel(), "Ranger"); AssertEquals(car.GetYear(), 2006); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Instantiationhelper.Car), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("model", "Ranger")); cars = odb.GetObjects(query); car = (NeoDatis.Odb.Test.Instantiationhelper.Car)cars.GetFirst(); AssertEquals(car.GetModel(), "Ranger"); }
/// <exception cref="System.Exception"></exception> 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.ICollection c = new System.Collections.ArrayList(); c.Add(o); o.GetMap().Add("c", c); odb.Store(o); odb.Close(); odb = Open("map-with-collections"); NeoDatis.Odb.Objects os = odb.GetObjects(typeof(NeoDatis.Odb.Test.Arraycollectionmap.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(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); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { if (!isLocal || !useSameVmOptimization) { // native must be serializable to be executed in cs mode return; } string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); bool[] bbs1 = new bool[2]; bbs1[0] = true; bbs1[1] = false; bool[] bbs2 = new bool[2]; bbs2[0] = true; bbs2[1] = false; NeoDatis.Odb.Test.VO.ClassWithArrayOfBoolean o = new NeoDatis.Odb.Test.VO.ClassWithArrayOfBoolean ("test", bbs1, bbs2); odb.Store(o); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery query = new _SimpleNativeQuery_55(); NeoDatis.Odb.Objects objects = odb.GetObjects(query); AssertEquals(1, objects.Count); NeoDatis.Odb.Test.VO.ClassWithArrayOfBoolean o2 = (NeoDatis.Odb.Test.VO.ClassWithArrayOfBoolean )objects.GetFirst(); AssertEquals("test", o2.GetName()); AssertEquals(true, o2.GetBools1()[0]); AssertEquals(false, o2.GetBools1()[1]); AssertEquals(true, o2.GetBools2()[0]); AssertEquals(false, o2.GetBools2()[1]); }
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="Java.IO.UnsupportedEncodingException"></exception> public virtual void Test1() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); Java.Util.Locale defaultLocale = Java.Util.Locale.GetDefault(); try { odb = Open(baseName); NeoDatis.Odb.OdbConfiguration.SetLatinDatabaseCharacterEncoding(); Java.Util.Locale brLocale = new Java.Util.Locale("pt", "BR"); Java.Util.Locale.SetDefault(brLocale); NeoDatis.Odb.Test.VO.Attribute.TestClass tc = new NeoDatis.Odb.Test.VO.Attribute.TestClass (); tc.SetBigDecimal1(new System.Decimal(5.3)); Println(tc.GetBigDecimal1().ToString()); odb.Store(tc); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Attribute.TestClass> objects = odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)); AssertEquals(1, objects.Count); AssertEquals(new System.Decimal(5.3), objects.GetFirst().GetBigDecimal1()); } finally { if (odb != null && !odb.IsClosed()) { odb.Close(); } NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding(null); Java.Util.Locale.SetDefault(defaultLocale); } }
/// <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 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 TestStringPersistence() { NeoDatis.Odb.ODB odb = null; try { odb = Open("date.neodatis"); NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass (); tc1.SetString1(string.Empty); odb.Store(tc1); odb.Close(); odb = Open("date.neodatis"); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass )); AssertEquals(1, l.Count); NeoDatis.Odb.Test.VO.Attribute.TestClass tc2 = (NeoDatis.Odb.Test.VO.Attribute.TestClass )l.GetFirst(); AssertEquals(string.Empty, tc2.GetString1()); AssertEquals(null, tc2.GetBigDecimal1()); AssertEquals(null, tc2.GetDouble1()); } finally { if (odb != null) { odb.Close(); } } }
/// <summary>Test update object list.</summary> /// <remarks> /// Test update object list. A list of Integer. 1000 updates, increasing /// number of elements /// </remarks> /// <exception cref="System.Exception"></exception> 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 Test1() { DeleteBase("t1u.neodatis"); NeoDatis.Odb.ODB odb = Open("t1u.neodatis"); Function login = new Function ("login"); Function logout = new Function ("logout"); odb.Store(login); Println("--------"); odb.Store(login); odb.Store(logout); // odb.commit(); odb.Close(); odb = Open("t1u.neodatis"); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true); Function f2 = (Function)l.GetFirst (); f2.SetName("login function"); odb.Store(f2); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("t1u.neodatis"); Function f = (Function)odb2 .GetObjects <Function>().GetFirst(); AssertEquals("login function", f.GetName()); odb2.Close(); DeleteBase("t1u.neodatis"); }
/// <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"); }
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 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(); }
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); }
/// <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 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 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 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); }