/// <exception cref="System.Exception"></exception> public virtual void TestWithoutUserAndPasswordWithAccentsFromPropertyFile() { // Configuration.setDatabaseCharacterEncoding("UTF-8"); string baseName = GetBaseName(); DeleteBase(baseName); // The test-accent property file is in the test directory //Java.Util.ResourceBundle r = Java.Util.ResourceBundle.GetBundle("test-accent"); //string user = r.GetString("user"); ///string password = r.GetString("password"); Println(password); NeoDatis.Odb.ODB odb = Open(baseName, user, password); odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("t1")); odb.Close(); try { odb = Open(baseName, "\u00E7\u00E3o", "ol\u00E1 chico"); } catch (NeoDatis.Odb.ODBAuthenticationRuntimeException) { odb.Rollback(); Fail("User/Password with accents"); } odb.Close(); DeleteBase(baseName); }
/// <summary>test in place update with rollback.</summary> /// <remarks> /// test in place update with rollback. Bug detected by Olivier 22/02/2008. /// In place updates for connected object were done out of transaction, /// avoiding rollback (ObejctWriter.manageInPlaceUpdate() /// </remarks> public virtual void Test10() { NeoDatis.Odb.ODB odb = null; try { odb = Open("inplcae-transaction"); NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function1" )); odb.Close(); odb = Open("inplcae-transaction"); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb. GetObjectFromId(oid); f.SetName("function2"); odb.Store(f); odb.Rollback(); odb.Close(); odb = Open("inplcae-transaction"); f = (NeoDatis.Odb.Test.VO.Login.Function)odb.GetObjectFromId(oid); odb.Close(); AssertEquals("function1", f.GetName()); } catch (System.Exception) { } }
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 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 T1estK1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); odb.Store(GetInstance("f2")); NeoDatis.Odb.OID oid = odb.Store(GetInstance("f3")); odb.Commit(); object o = odb.GetObjectFromId(oid); odb.Delete(o); odb.Rollback(); }
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"); } }
public virtual void TestArrayOfDate() { NeoDatis.Odb.ODB odb = null; int size = 50; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); System.DateTime[] array = new System.DateTime[size]; System.DateTime now = new System.DateTime(); for (int i = 0; i < size; i++) { array[i] = new System.DateTime(now.Millisecond + i); } ObjectWithNativeArrayOfDate owna = new ObjectWithNativeArrayOfDate ("t1", array); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfDate> l = odb.GetObjects <ObjectWithNativeArrayOfDate>(); ObjectWithNativeArrayOfDate owna2 = l.GetFirst(); AssertEquals(owna.GetName(), owna2.GetName()); for (int i = 0; i < size; i++) { AssertEquals(owna.GetNumbers()[i], owna2.GetNumbers()[i]); } odb.Close(); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void TestArray4() { NeoDatis.Odb.ODB odb = null; int size = 50; try { 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(); AssertEquals(owna.GetName(), owna2.GetName()); for (int i = 0; i < size; i++) { AssertEquals(owna.GetNumbers()[i], owna2.GetNumbers()[i]); } odb.Close(); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void TestArray2() { NeoDatis.Odb.ODB odb = null; int size = 50; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); int[] intArray = new int[size]; for (int i = 0; i < size; i++) { intArray[i] = i; } ObjectWithNativeArrayOfInt owna = new ObjectWithNativeArrayOfInt ("t1", intArray); odb.Store(owna); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <ObjectWithNativeArrayOfInt> l = odb.GetObjects <ObjectWithNativeArrayOfInt>(); ObjectWithNativeArrayOfInt owna2 = l.GetFirst(); AssertEquals(owna.GetName(), owna2.GetName()); for (int i = 0; i < size; i++) { AssertEquals(owna.GetNumbers()[i], owna2.GetNumbers()[i]); } odb.Close(); odb = null; } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void Test3RollbackOneStore() { 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"); odb.Store(new Function("f3")); odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void T1estM1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); int size = 1; NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size]; for (int i = 0; i < size; i++) { oids[i] = odb.Store(GetInstance("f" + i)); } for (int i = 0; i < size; i++) { odb.DeleteObjectWithId(oids[i]); } odb.Rollback(); }
public virtual void TestArray1() { NeoDatis.Odb.ODB odb = null; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); decimal nb = odb.Count(new CriteriaQuery(typeof( PlayerWithArray))); PlayerWithArray player = new PlayerWithArray ("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects <PlayerWithArray> l = odb.GetObjects <PlayerWithArray>(true); AssertEquals(nb + 1, l.Count); // gets first player PlayerWithArray player2 = l.GetFirst(); AssertEquals(player.ToString(), player2.ToString()); } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } Console.WriteLine(e); throw e; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void Test4RollbackXXXStores() { 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"); 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(); }
/// <exception cref="System.Exception"></exception> public virtual void Test4() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(10); try { System.Collections.IList list = new System.Collections.ArrayList(); for (int i = 0; i < 15; i++) { Function function = new Function ("function " + i); try { odb.Store(function); } catch (System.Exception e) { odb.Rollback(); odb.Close(); AssertTrue(e.Message.IndexOf("Cache is full!") != -1); return; } list.Add(function); } odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true); l.Next(); 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 Test5RollbackDelete() { 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()) { odb.Delete(objects.Next()); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestCollectionWithContain() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); try { odb = Open(baseName); 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(); odb = Open(baseName); NeoDatis.Odb.Objects <PlayerWithList> l = odb.GetObjects <PlayerWithList>(new CriteriaQuery(Where.Contain("games", "tennis"))); AssertEquals(nb + 1, l.Count); } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void TestArrayQuery() { NeoDatis.Odb.ODB odb = null; try { DeleteBase("array1.neodatis"); odb = Open("array1.neodatis"); decimal nb = odb.Count(new CriteriaQuery(typeof( PlayerWithArray))); PlayerWithArray player = new PlayerWithArray ("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); odb = Open("array1.neodatis"); NeoDatis.Odb.Objects<PlayerWithArray> l = odb.GetObjects < PlayerWithArray>(new CriteriaQuery(Where.Contain("games", "tennis"))); AssertEquals(nb + 1, l.Count); } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } DeleteBase("array1.neodatis"); } }
public virtual void Test7Update() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("1function")); odb.Store(new Function("2function")); odb.Store(new Function("3function")); 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); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void T1estL1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); odb.Store(GetInstance("f2")); NeoDatis.Odb.OID oid = odb.Store(GetInstance("f3")); odb.Commit(); object o = odb.GetObjectFromId(oid); if (simpleObject) { NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)o; f.SetName("flksjdfjs;dfsljflsjflksjfksjfklsdjfksjfkalsjfklsdjflskd"); odb.Store(f); } else { NeoDatis.Odb.Test.VO.Login.User f = (NeoDatis.Odb.Test.VO.Login.User)o; f.SetName("flksjdfjs;dfsljflsjflksjfksjfklsdjfksjfkalsjfklsdjflskd"); odb.Store(f); } odb.Rollback(); }
/// <exception cref="System.Exception"></exception> public virtual void TestWithoutUserAndPasswordWithAccents() { // Configuration.setDatabaseCharacterEncoding("UTF-8"); string baseName = GetBaseName(); DeleteBase(baseName); string user = "******"; string password = "******"; NeoDatis.Odb.ODB odb = Open(baseName, user, password); odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("t1")); odb.Close(); try { odb = Open(baseName, user, password); } catch (NeoDatis.Odb.ODBAuthenticationRuntimeException) { odb.Rollback(); Fail("User/Password with accents"); } odb.Close(); DeleteBase(baseName); }
public virtual void Test2() { 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"); odb.Store(new Function("f3")); odb.Rollback(); // odb.close(); try { AssertEquals(3, odb.GetObjects <Function>().Count ); } catch (NeoDatis.Odb.ODBRuntimeException e) { string s = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false); AssertFalse(s.IndexOf("ODB session has been rollbacked") == -1); } odb.Close(); }