/// <exception cref="System.Exception"></exception> public virtual void Test5() { try { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); System.Collections.IList list = new System.Collections.ArrayList(); for (int i = 0; i < 15; i++) { Function function = new Function ("function " + i); odb.Store(function); list.Add(function); } odb.Close(); NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(15); odb = Open(FileName); NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where .Or().Add(Where.Like("name", "%9")).Add(Where .Like("name", "%8"))); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(query, false); AssertEquals(2, l.Count); l.Next(); odb.Store(l.Next()); odb.Close(); odb = Open(FileName); AssertEquals(15, odb.Count(new CriteriaQuery())); odb.Close(); } finally { NeoDatis.Odb.OdbConfiguration.SetMaxNumberOfObjectInCache(300000); } }
public virtual void 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 Test1() { DeleteBase("null.neodatis"); NeoDatis.Odb.ODB odb = Open("null.neodatis"); NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli" , "oli@sdsadf", null); NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine" , "karine@sdsadf", null); NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null, null, null); odb.Store(user1); odb.Store(user2); odb.Store(user3); odb.Close(); odb = Open("null.neodatis"); NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(true); AssertEquals(3, l.Count); user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals("oli", user1.GetName()); AssertEquals("oli@sdsadf", user1.GetEmail()); AssertEquals(null, user1.GetProfile()); user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals("karine", user2.GetName()); AssertEquals("karine@sdsadf", user2.GetEmail()); AssertEquals(null, user2.GetProfile()); user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals(null, user3.GetName()); AssertEquals(null, user3.GetEmail()); AssertEquals(null, user3.GetProfile()); odb.Close(); DeleteBase("null.neodatis"); }
public virtual void Test3() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); int size = 500; for (int i = 0; i < size; i++) { odb.Store(new Class1("c1")); } for (int i = 0; i < size; i++) { odb.Store(new Class1("c2")); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(); // q.orderByAsc("name"); NeoDatis.Odb.Objects <Class1> objects = odb.GetObjects <Class1>(q); AssertEquals(size * 2, objects.Count); for (int i = 0; i < size; i++) { Class1 c1 = (Class1 )objects.Next(); AssertEquals("c1", c1.GetName()); } for (int i = 0; i < size; i++) { Class1 c1 = (Class1 )objects.Next(); AssertEquals("c2", c1.GetName()); } 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(); } } }
/// <exception cref="System.Exception"></exception> public virtual void TestCriteriaWithDate() { DeleteBase(BaseName); NeoDatis.Odb.ODB odb = Open(BaseName); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.VO.Attribute.TestClass tc = new NeoDatis.Odb.Test.VO.Attribute.TestClass (); tc.SetInt1(i); odb.Store(tc); } odb.Close(); odb = Open(BaseName); NeoDatis.Odb.Objects <TestClass> os = odb.GetObjects <TestClass>(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (Where .Ge("int1", 0))); AssertEquals(10, os.Count); int j = 0; while (os.HasNext()) { NeoDatis.Odb.Test.VO.Attribute.TestClass tc = (NeoDatis.Odb.Test.VO.Attribute.TestClass )os.Next(); AssertEquals(j, tc.GetInt1()); j++; } odb.Close(); }
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 <Profile> objects = odb.GetObjects <Profile>(); while (objects.HasNext()) { NeoDatis.Odb.Test.VO.Login.Profile profile = objects.Next(); System.Collections.Generic.IList <Function> functions = profile.GetFunctions(); for (int j = 0; j < functions.Count; j++) { odb.Delete(functions[j]); } odb.Delete(profile); } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestGetLimitedResult4() { string baseName = GetBaseName(); int size = 1000; NeoDatis.Odb.ODB odb = Open(baseName); for (int i = 0; i < size; i++) { if (i < size / 2) { odb.Store(new Function("function " + i)); } else { odb.Store(new Function("FUNCTION " + i)); } } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(Where.Like("name", "FUNCTION%")); NeoDatis.Odb.Objects <Function> os = odb.GetObjects <Function>(q, true, 10, 20); AssertEquals(10, os.Count); for (int i = size / 2 + 10; i < size / 2 + 20; i++) { Function f = (Function)os.Next (); AssertEquals("FUNCTION " + i, f.GetName()); } odb.Close(); DeleteBase(baseName); }
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); }
/// <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); }
/// <summary>Test the timeof lazy get</summary> /// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase(Filename); // println("Start inserting " + SIZE + " objects"); long startinsert = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.ODB odb = Open(Filename); for (int i = 0; i < Size; i++) { odb.Store(GetInstance()); } odb.Close(); long endinsert = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("End inserting " + SIZE + " objects - " + // (endinsert-startinsert) + " ms"); // println("totalObjects = "+ odb.count(User.class)); odb = Open(Filename); long start1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Objects lazyList = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), false); long end1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); long startget1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); while (lazyList.HasNext()) { // t1 = OdbTime.getCurrentTimeInMs(); lazyList.Next(); } // t2 = OdbTime.getCurrentTimeInMs(); // println(t2-t1); long endget1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); AssertEquals(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.User))), lazyList.Count); odb.Close(); long t01 = end1 - start1; long tget1 = endget1 - startget1; // long t2 = end2-start2; // long tget2 = endget2-startget2; // println("t1(lazy)="+t1 + " - " +tget1+ " t2(memory)="+t2 +" - " // + tget2); // println("t1(lazy)="+t1 + " - " +tget1); // assertTrue(t1<t2); // println(endinsert-startinsert); bool c = (isLocal ? 501 : 15000) > tget1; Println("Time for " + Size + " lazy gets : " + (tget1)); if (!c) { Println("Time for " + Size + " lazy gets : " + (tget1)); } DeleteBase(Filename); if (testPerformance && !c) { Fail("Time for " + Size + " lazy gets : " + (tget1)); } }
/// <exception cref="System.Exception"></exception> public virtual void 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 TestSelectUnCommitedObject3() { DeleteBase(BaseName); // Create instance NeoDatis.Odb.Test.VO.Sport.Sport sport = new NeoDatis.Odb.Test.VO.Sport.Sport("volley-ball" ); NeoDatis.Odb.ODB odb = null; try { // Open the database odb = Open(BaseName); // Store the object odb.Store(sport); } finally { if (odb != null) { // Close the database odb.Close(); } } try { // Open the database odb = Open(BaseName); // Let's insert a tennis player NeoDatis.Odb.Test.VO.Sport.Player agassi = new NeoDatis.Odb.Test.VO.Sport.Player( "André Agassi", new System.DateTime(), new NeoDatis.Odb.Test.VO.Sport.Sport("Tennis" )); odb.Store(agassi); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(Player), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("favoriteSport.name", "volley-ball")); NeoDatis.Odb.Objects <Player> players = odb.GetObjects <Player>(query); Println("\nStep 4 : Players of Voller-ball"); int i = 1; // display each object while (players.HasNext()) { Println((i++) + "\t: " + players.Next()); } } finally { if (odb != null) { // Close the database odb.Close(); } } DeleteBase(BaseName); }
public virtual void TestGetObects2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("Test")); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.Function> functions = odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Function)); NeoDatis.Odb.Test.VO.Login.Function f = functions.Next(); odb.Close(); AssertEquals(1, functions.Count); }
/// <exception cref="System.Exception"></exception> public virtual void TestInsertWithCommitsSimpleObject() { DeleteBase("commits"); NeoDatis.Odb.ODB odb = null; int size = isLocal ? 10000 : 3000; int commitInterval = 1; try { odb = Open("commits"); for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i)); if (i % commitInterval == 0) { odb.Commit(); } } } finally { // println("commiting "+i); odb.Close(); } odb = Open("commits"); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function )); int nbObjects = objects.Count; System.Collections.IDictionary map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap(); NeoDatis.Odb.Test.VO.Login.Function function = null; int j = 0; while (objects.HasNext()) { function = (NeoDatis.Odb.Test.VO.Login.Function)objects.Next(); int ii = (int)map[function]; if (ii != null) { Println(j + ":" + function.GetName() + " already exist at " + ii); } else { map.Add(function, j); } j++; } odb.Close(); DeleteBase("commits"); Println("Nb objects=" + nbObjects); AssertEquals(size, nbObjects); }
public virtual void Test1WithCommit3() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p.AddFunction(new Function("f1")); User user = new User("user name 0" , "user email 0", p); odb.Store(user); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p2.AddFunction(new Function("f2")); User user2 = new User("user name 0" , "user email 0", p2); odb.Store(user2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <User> objects = null; for (int k = 0; k < 2; k++) { System.Console.Out.WriteLine(":" + k); objects = odb.GetObjects <User>(); while (objects.HasNext()) { user = (User)objects.Next(); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); Println(user.GetProfile().GetName()); odb.Store(user); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects <User>(); AssertEquals(2, objects.Count); odb.Close(); }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.Exception"></exception> public virtual void RunJava() { NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Test.ODBTest test = new NeoDatis.Odb.Test.ODBTest(); try { test.DeleteBase("mydb7.neodatis"); // Open the database odb = test.Open("mydb7.neodatis"); long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); int nRecords = 100000; for (int i = 0; i < nRecords; i++) { NeoDatis.Odb.Test.Dotnet.AA ao = new NeoDatis.Odb.Test.Dotnet.AA(); ao.ccc = "csdcsdc"; ao.ww = i; odb.Store(ao); } long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Dotnet.AA)); query.OrderByAsc("ww"); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Objects object12 = odb.GetObjects(query, false); while (object12.HasNext()) { NeoDatis.Odb.Test.Dotnet.AA s = (NeoDatis.Odb.Test.Dotnet.AA)object12.Next(); int id = s.ww; } // println(id); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); test.Println("Time=" + (end - start) + " / " + (end - start0) + " / " + (end0 - start0 )); } finally { if (odb != null) { // Close the database odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void Test3() { string baseName = GetBaseName(); string baseName2 = "2" + baseName; NeoDatis.Odb.ODB odb = Open(baseName); int size = 1000; for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), false); int j = 0; while (objects.HasNext() && j < objects.Count - 1) { odb.Delete(objects.Next()); j++; } odb.Close(); odb = Open(baseName); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); if (isLocal) { odb = Open(baseName); odb.DefragmentTo(NeoDatis.Odb.Test.ODBTest.Directory + baseName2); odb.Close(); odb = Open(baseName2); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); } DeleteBase(baseName); DeleteBase(baseName2); }
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 Test1() { DeleteBase("sict"); NeoDatis.Odb.ODB odb = Open("sict"); NeoDatis.Odb.Test.Update.Nullobject.User user = Popula(odb); AT at = CreateAT(user); odb.Store(at); odb.Store(CreateSensor(user, at, 1)); odb.Store(CreateSensor(user, at, 2)); odb.Store(CreateSensor(user, at, 3)); odb.Store(CreateSensor(user, at, 4)); odb.Close(); odb = Open("sict"); NeoDatis.Odb.Objects <AT> ats = odb.GetObjects <AT>(); int nbAts = ats.Count; at = (AT)ats.GetFirst(); AT newAT = null; SensorAT newSensor = null; NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("at.name", at.GetName())); query.OrderByAsc("lane"); NeoDatis.Odb.Objects <SensorAT> sensors = odb.GetObjects <SensorAT>(query); Println("Duplicando AT " + at.GetName()); for (int i = 0; i < 10; i++) { newAT = DuplicateAT(at, nbAts + i + 1); odb.Store(newAT); sensors.Reset(); while (sensors.HasNext()) { newSensor = DuplicateSensor((SensorAT)sensors .Next(), newAT); odb.Store(newSensor); } } // println("AT " + newAT.getName()+" created"); odb.Close(); }
public virtual void Test1WithCommit4() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function1"); odb.Store(f1); Function f2 = new Function( "function2"); odb.Store(f2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); Function f = null; Println("got the object " + objects.Count); for (int k = 0; k < 2; k++) { objects.Reset(); while (objects.HasNext()) { f = (Function)objects.Next(); f.SetName(f.GetName() + "updated-"); odb.Store(f); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects <Function>(); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestSelectSimpleObjectODB() { long t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); bool inMemory = true; System.Console.Out.WriteLine("Retrieving " + TestSize + " objects"); // Reopen the database NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); // Gets the TEST_SIZE objects NeoDatis.Odb.Objects <SimpleObject> l = odb.GetObjects <SimpleObject>(inMemory); System.Console.Out.WriteLine(l.GetType().FullName); long t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Console.Out.WriteLine("l.size=" + l.Count); int i = 0; while (l.HasNext()) { object o = l.Next(); if (i % 10000 == 0) { NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("select " + i, true); } // System.out.println("Cache="+Dummy.getEngine(odb).getSession().getCache().toString()); i++; } long t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb.Close(); DisplayResult("ODB " + TestSize + " SimpleObject objects ", t3, t4, t5); System.Console.Out.WriteLine("buffer Ok=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Buffer.MultiBufferedIO .nbBufferOk + " / buffer not ok =" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Buffer.MultiBufferedIO .nbBufferNotOk); System.Console.Out.WriteLine("nb1=" + NeoDatis.Odb.Core.Layers.Layer3.Engine.FileSystemInterface .nbCall1 + " / nb2 =" + NeoDatis.Odb.Core.Layers.Layer3.Engine.FileSystemInterface .nbCall2); }
public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); odb.Store(new Class1("c1")); odb.Store(new Class1("c1")); odb.Store(new Class1("c2")); odb.Store(new Class1("c2")); odb.Store(new Class1("c3")); odb.Store(new Class1("c4")); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(); q.OrderByAsc("name"); NeoDatis.Odb.Objects <Class1> objects = odb.GetObjects <Class1>(q); AssertEquals(6, objects.Count); while (objects.HasNext()) { System.Console.Out.WriteLine(objects.Next()); } // println(objects); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestGetLimitedResult1() { string baseName = GetBaseName(); int size = 1000; NeoDatis.Odb.ODB odb = Open(baseName); for (int i = 0; i < size; i++) { odb.Store(new Function("function " + i)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery(); NeoDatis.Odb.Objects <Function> os = odb.GetObjects <Function>(q, true, 0, 1); AssertEquals(1, os.Count); for (int i = 0; i < os.Count; i++) { Function f = (Function)os.Next (); AssertEquals("function " + i, f.GetName()); } odb.Close(); DeleteBase(baseName); }
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(); }
public virtual void Test8() { int size1 = 1000; int size2 = 1000; if (!runAll) { return; } string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Objects os = null; for (int i = 0; i < size1; i++) { odb = Open(baseName); for (int j = 0; j < size2; j++) { NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function " + j); odb.Store(f); } odb.Close(); odb = Open(baseName); os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)); while (os.HasNext()) { NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)os.Next (); odb.Delete(f); } odb.Close(); if (i % 100 == 0) { Println(i + "/" + size1); } } odb = Open(baseName); os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)); AssertEquals(0, os.Count); odb.Close(); Println("step2"); for (int i = 0; i < size1; i++) { odb = Open(baseName); os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)); while (os.HasNext()) { NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)os.Next (); odb.Delete(f); } odb.Close(); odb = Open(baseName); for (int j = 0; j < size2; j++) { NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function " + j); odb.Store(f); } odb.Close(); if (i % 100 == 0) { Println(i + "/" + size1); } } odb = Open(baseName); os = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)); AssertEquals(size2, os.Count); odb.Close(); DeleteBase(baseName); }
public virtual void Test9Ordering() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = Open("get.neodatis"); SimpleNativeQuery query = new _SimpleNativeQuery_235(); query.OrderByDesc("name,email"); NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query, true); int i = l.Count - 1; AssertFalse(l.Count == 0); while (l.HasNext()) { NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); // println(user.getName() + " / " + user.getEmail()); AssertEquals("olivier " + i / 3, user.GetName()); AssertEquals("[email protected] " + ((i % 3) + 1), user.GetEmail()); i--; } odb.Close(); }
public virtual void Test6Ordering() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = Open("get.neodatis"); SimpleNativeQuery query = new _SimpleNativeQuery_158(); query.OrderByAsc("name"); NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(query, true); int i = 0; AssertFalse(l.Count == 0); while (l.HasNext()) { NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals("olivier " + i, user.GetName()); // println(user.getName()); i++; } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { DeleteBase("t2.neodatis"); NeoDatis.Odb.ODB odb = Open("t2.neodatis"); int nbUsers = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User)).Count; int nbProfiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile), true) .Count; 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"); System.Collections.IList list = new System.Collections.ArrayList(); list.Add(login); list.Add(logout); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator", list); NeoDatis.Odb.Test.VO.Login.User olivier = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile); NeoDatis.Odb.Test.VO.Login.User aisa = new NeoDatis.Odb.Test.VO.Login.User("Aísa Galvão Smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Store(aisa); odb.Commit(); NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), true); NeoDatis.Odb.Objects profiles = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Profile ), true); NeoDatis.Odb.Objects functions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); odb.Close(); // println("Users:"+users); Println("Profiles:" + profiles); Println("Functions:" + functions); odb = Open("t2.neodatis"); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), true); odb.Close(); AssertEquals(nbUsers + 2, users.Count); NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst (); AssertEquals(olivier.ToString(), user2.ToString()); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); NeoDatis.Odb.ODB odb2 = Open("t2.neodatis"); l = odb2.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function), true); NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function )l.GetFirst(); function.SetName("login function"); odb2.Store(function); odb2.Close(); NeoDatis.Odb.ODB odb3 = Open("t2.neodatis"); NeoDatis.Odb.Objects l2 = odb3.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User) , true); int i = 0; while (l2.HasNext() && i < System.Math.Min(2, l2.Count)) { NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l2.Next(); AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0] ); i++; } odb3.Close(); DeleteBase("t2.neodatis"); }
public virtual void Test2() { DeleteBase("t2.neodatis"); NeoDatis.Odb.ODB odb = Open("t2.neodatis"); int nbUsers = odb.GetObjects <User>().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 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(aisa); 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(); // println("Users:"+users); Println("Profiles:" + profiles); Println("Functions:" + functions); odb = Open("t2.neodatis"); NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(true); odb.Close(); AssertEquals(nbUsers + 2, users.Count); User user2 = (User)users.GetFirst (); AssertEquals(olivier.ToString(), user2.ToString()); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); NeoDatis.Odb.ODB odb2 = Open("t2.neodatis"); Objects <Function> l2 = odb2.GetObjects <Function>(true); Function function = l2.GetFirst(); function.SetName("login function"); odb2.Store(function); odb2.Close(); NeoDatis.Odb.ODB odb3 = Open("t2.neodatis"); NeoDatis.Odb.Objects <User> l3 = odb3.GetObjects <User>(true); int i = 0; while (l3.HasNext() && i < System.Math.Min(2, l3.Count)) { User user = (User)l3.Next(); AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0] ); i++; } odb3.Close(); DeleteBase("t2.neodatis"); }