public virtual void TestInsert() { DeleteBase(NewbieOdb); odb = Open(NewbieOdb); Driver marcelo = new Driver ("marcelo"); Car car = new Car("car1", 4, "ranger", marcelo); Car car1 = new Car("car2" , 2, "porche"); Car car2 = new Car("car3" , 2, "fusca"); Car car3 = new Car("car4" , 4, "opala"); Car car4 = new Car("car5" , 4, "vectra", marcelo); try { // open is called on NewbieTest // insert 5 car's odb.Store(car); odb.Store(car1); odb.Store(car2); odb.Store(car3); odb.Store(car4); // find for all car objects NeoDatis.Odb.Objects<Car> cars = odb.GetObjects<Car>(); AssertEquals("The objects weren't added correctly", 5, cars.Count); // find for a specific car object CriteriaQuery query = new CriteriaQuery(typeof(Car), Where.Equal("name", "car1")); cars = odb.GetObjects<Car>(query); AssertEquals("The objects couldn't be found correctly", 1, cars.Count); // find for a specific composition query = new CriteriaQuery(typeof(Car), Where.Equal("driver.name", "marcelo")); cars = odb.GetObjects<Car>(query); AssertEquals("The objects couldn't be found correctly", 2, cars.Count); odb.Commit(); odb.Close(); DeleteBase(NewbieOdb); } catch (System.Exception e) { Console.WriteLine(e); } }
public virtual void TestUpdate() { try { DeleteBase(NewbieOdb); odb = Open(NewbieOdb); Driver marcelo = new Driver("marcelo"); Car car = new Car("car1", 4, "ranger", marcelo); odb.Store(car); CriteriaQuery query = new CriteriaQuery(Where.Equal("driver.name", "marcelo")); Car newCar = (Car)odb.GetObjects<Car>(query).GetFirst(); newCar.SetDriver(new Driver("dani")); odb.Store(newCar); odb.Commit(); query = new CriteriaQuery(Where.Equal("driver.name", "dani")); AssertEquals(1, odb.GetObjects<Car>(query).Count); odb.Close(); DeleteBase(NewbieOdb); } catch (System.Exception e) { throw e; } }
public virtual void Test8() { string baseName = GetBaseName(); Println(baseName); NeoDatis.Odb.ODB odb = null; System.DateTime utilDate = new System.DateTime(); System.DateTime sqlDate = new System.DateTime(utilDate.Millisecond + 10000); System.DateTime timestamp = new System.DateTime(utilDate.Millisecond + 20000); try { odb = Open(baseName); ObjectWithDates o = new ObjectWithDates ("object1", utilDate, sqlDate, timestamp); odb.Store(o); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <ObjectWithDates> dates = odb. GetObjects <ObjectWithDates>(); ObjectWithDates o2 = dates.GetFirst(); Println(o2.GetName()); Println(o2.GetJavaUtilDate()); Println(o2.GetJavaSqlDte()); Println(o2.GetTimestamp()); AssertEquals("object1", o2.GetName()); AssertEquals(utilDate, o2.GetJavaUtilDate()); AssertEquals(sqlDate, o2.GetJavaSqlDte()); AssertEquals(timestamp, o2.GetTimestamp()); } finally { if (odb != null) { odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void BuildBase() { bool inMemory = true; // Deletes the database file NeoDatis.Tool.IOUtil.DeleteFile(OdbFileName); long t1 = 0; long t2 = 0; long t3 = 0; long t4 = 0; long t5 = 0; long t6 = 0; long t7 = 0; long t77 = 0; long t8 = 0; NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Test.Performance.SimpleObject so = null; // Insert TEST_SIZE objects System.Console.Out.WriteLine("Inserting " + TestSize + " objects"); t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); for (int i = 0; i < TestSize; i++) { object o = GetSimpleObjectInstance(i); odb.Store(o); if (i % 10000 == 0) { // System.out.println("i="+i); NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory(string.Empty + i, true); } } // System.out.println("Cache="+Dummy.getEngine(odb).getSession().getCache().toString()); t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // Closes the database odb.Close(); }
public virtual void TestList4Update2() { DeleteBase("list4.neodatis"); NeoDatis.Odb.ODB odb = Open("list4.neodatis"); long nb = odb.Count(new CriteriaQuery(typeof( MyObject))); MyList l1 = new MyList (); l1.Add("object1"); l1.Add("object2"); MyObject myObject = new MyObject("o1", l1); odb.Store(myObject); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list4.neodatis"); NeoDatis.Odb.Objects <MyObject> l = odb2.GetObjects <MyObject>(true); MyObject mo = (MyObject )l.GetFirst(); mo.GetList().Add("object3"); mo.GetList().Add("object4"); odb2.Store(mo); odb2.Close(); odb2 = Open("list4.neodatis"); l = odb2.GetObjects <MyObject>(true); AssertEquals(nb + 1, l.Count); MyObject mo2 = l.GetFirst(); AssertEquals(4, mo2.GetList().Count); AssertEquals("object1", mo2.GetList()[0]); AssertEquals("object2", mo2.GetList()[1]); AssertEquals("object3", mo2.GetList()[2]); AssertEquals("object4", mo2.GetList()[3]); odb2.Close(); DeleteBase("list4.neodatis"); }
public virtual void Test1() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = null; DeleteBase("trigger.neodatis"); NeoDatis.Odb.Test.Trigger.MyTrigger myTrigger = new NeoDatis.Odb.Test.Trigger.MyTrigger (); try { odb = Open("trigger.neodatis"); odb.AddInsertTrigger(typeof(User), myTrigger); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Profile profile = new Profile ("profile1", f1); User user = new User("oli", "*****@*****.**", profile); odb.Store(user); } finally { if (odb != null) { odb.Close(); } } odb = Open("trigger.neodatis"); odb.Close(); DeleteBase("trigger.neodatis"); AssertEquals(1, myTrigger.nbInsertsBefore); AssertEquals(1, myTrigger.nbInsertsAfter); }
public virtual void Test6() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); Function f = new Function("function1" ); odb.Store(f); NeoDatis.Odb.OID id = odb.GetObjectId(f); odb.Commit(); try { odb.Delete(f); odb.GetObjectFromId(id); Fail("The object has been deleted, the id should have been marked as deleted"); } catch (NeoDatis.Odb.ODBRuntimeException) { odb.Close(); DeleteBase("t-delete1.neodatis"); } }
/// <exception cref="System.Exception"></exception> public virtual void TestCompositeCollection1() { DeleteBase("t31.neodatis"); NeoDatis.Odb.ODB odb = Open("t31.neodatis"); 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("t31.neodatis"); NeoDatis.Odb.Objects users = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User ), true); odb.Close(); // assertEquals(nbUsers+2,users.size()); NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.User)users.GetFirst (); AssertEquals(user.ToString(), user2.ToString()); DeleteBase("t31.neodatis"); }
/// <exception cref="System.Exception"></exception> 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 "); } NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function (b.ToString()); NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile ("operator 1", login); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile1); odb.Store(user); 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(); // assertEquals(nbUsers+2,users.size()); NeoDatis.Odb.Test.VO.Login.User user2 = (NeoDatis.Odb.Test.VO.Login.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 Test15() { Println("-------------------"); // LogUtil.logOn(ObjectWriter.LOG_ID, true); // LogUtil.logOn(ObjectReader.LOG_ID, true); NeoDatis.Odb.ODB odb = Open("cyclic.neodatis"); NeoDatis.Odb.Objects <Country2> l = odb.GetObjects < Country2(true); Country2 country = l.GetFirst(); City city = country.GetCapital(); city.SetName("rio de janeiro"); country.SetCapital(city); odb.Store(country); odb.Close(); odb = Open("cyclic.neodatis"); l = odb.GetObjects <Country2>(true); country = l.GetFirst(); AssertEquals("rio de janeiro", country.GetCapital().GetName()); l = odb.GetObjects <City>(new CriteriaQuery(Where.Equal("name", "rio de janeiro"))); AssertEquals(1, l.Count); l = odb.GetObjects <City>(new CriteriaQuery()); AssertEquals(1, l.Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Step20() { // Create instance NeoDatis.Odb.Test.Tutorial.Sport sport = new NeoDatis.Odb.Test.Tutorial.Sport("volley-ball" ); NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.ODBServer server = null; try { // Creates the server on port 8000 server = OpenServer(8000); // Tells the server to manage base 'base1' that points to the file // tutorial2.odb server.AddBase("base1", OdbName); // Then starts the server to run in background server.StartServer(true); // Open the databse client on the localhost on port 8000 and specify // which database instance odb = OpenClient("localhost", 8000, "base1"); // Store the object odb.Store(sport); } finally { if (odb != null) { // First close the client odb.Close(); } if (server != null) { // Then close the database server server.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void Test3() { // LogUtil.objectReaderOn(true); 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); NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.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 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(size + 2, mmo.GetMap().Count); AssertEquals(mmo, ((System.Collections.ICollection)mmo.GetMap()["a"]).GetEnumerator ().Current); AssertEquals("function1", mmo.GetMap()["c"].ToString()); }
/// <exception cref="System.Exception"></exception> public virtual void TestDate1() { NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Test.Query.Criteria.MyDates myDates = new NeoDatis.Odb.Test.Query.Criteria.MyDates (); System.DateTime d1 = new System.DateTime(); Java.Lang.Thread.Sleep(100); System.DateTime d2 = new System.DateTime(); Java.Lang.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("criteria.neodatis"); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Query.Criteria.MyDates), NeoDatis.Odb.Core.Query.Criteria.Where .And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Le("date1", d2)).Add(NeoDatis.Odb.Core.Query.Criteria.Where .Ge("date2", d2)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i", 5))); NeoDatis.Odb.Objects objects = odb.GetObjects(query); AssertEquals(1, objects.Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestList1WithNull() { 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(null); odb.Store(player); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list1.neodatis"); NeoDatis.Odb.Objects <PlayerWithList> l = odb2.GetObjects <PlayerWithList>(true); AssertEquals(nb + 1, l.Count); // gets last player PlayerWithList player2 = (PlayerWithList)l.GetFirst(); AssertEquals(player.GetGame(2), player2.GetGame(2)); odb2.Close(); DeleteBase("list1.neodatis"); }
/// <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 Test6() { DeleteBase("valuesA2"); NeoDatis.Odb.ODB odb = Open("valuesA2"); int size = isLocal ? 100000 : 1000; for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass (); tc1.SetInt1(i); odb.Store(tc1); } odb.Close(); odb = Open("valuesA2"); NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("int1", 2)).Count("nb objects")); Println(values); NeoDatis.Odb.ObjectValues ov = values.NextValues(); odb.Close(); AssertEquals(1, ov.GetByAlias("nb objects")); AssertEquals(1, values.Count); }
/// <summary> /// Opens a connection C1, then create the index in another connection C2 and /// then stores the object in connection C1 /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestCreateIndexInOtherConnectionNoClose() { if (isLocal || !testNewFeature) { return; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb1 = Open(baseName); NeoDatis.Odb.ODB odb2 = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = odb2.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); odb2.Commit(); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); odb1.Store(io); } odb1.Close(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i1", 1)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> iis = odb.GetObjects (q); odb.Close(); odb2.Close(); AssertEquals(1, iis.Count); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
/// <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); }
/// <summary>Test update object list.</summary> /// <remarks> /// Test update object list. A list of Integer. 1000 updates of an object /// increasing list nb elements that is the middle of the list /// </remarks> /// <exception cref="System.Exception"></exception> public virtual void TestList4Update4Middle2() { DeleteBase("list5.neodatis"); NeoDatis.Odb.ODB odb = Open("list5.neodatis"); ObjectWithListOfInteger o = new ObjectWithListOfInteger ("test1"); o.GetListOfIntegers().Add(System.Convert.ToInt32("101")); odb.Store(o); o = new ObjectWithListOfInteger("test2"); o.GetListOfIntegers().Add(System.Convert.ToInt32("102")); odb.Store(o); o = new ObjectWithListOfInteger("test3"); o.GetListOfIntegers().Add(System.Convert.ToInt32("103")); 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>(new CriteriaQuery(Where.Equal("name", "test2"))); ObjectWithListOfInteger o2 = 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>(new CriteriaQuery(Where.Equal("name", "test2"))); AssertEquals(1, l.Count); ObjectWithListOfInteger o3 = l.GetFirst(); AssertEquals(1 + size, o3.GetListOfIntegers().Count); odb3.Close(); DeleteBase("list5.neodatis"); }
public virtual void Test2() { 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); Println(objects); odb.Close(); }
public virtual void Test18() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Function f3 = new Function( "function2"); NeoDatis.Odb.OID oid1 = odb.Store(f1); NeoDatis.Odb.OID oid2 = odb.Store(f2); NeoDatis.Odb.OID oid3 = odb.Store(f3); AssertEquals(3, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); odb.DeleteObjectWithId(oid2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); // odb.store(f1); odb.Store(new Function("f11")); odb.Store(new Function("f12")); odb.Store(new Function("f13")); // odb.store(f3); AssertEquals(5, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); AssertEquals(5, odb.GetObjects <Function>().Count ); odb.Close(); DeleteBase(baseName); }
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 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"); }
/// <exception cref="System.Exception"></exception> public static void CreateFunctionProfile(NeoDatis.Odb.ODB odb, NeoDatis.Odb.Test.Update.Nullobject.Profile admin, NeoDatis.Odb.Test.Update.Nullobject.Profile oper) { NeoDatis.Odb.Test.Update.Nullobject.Functions function = new NeoDatis.Odb.Test.Update.Nullobject.Functions (); function.SetDescription("Inclus√£o de usu√£rio"); function.SetName("incluiUsuario"); function.SetNameUrl("usuario.do/criar"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de Usu√£rio"); function.SetName("editaUsuario"); function.SetNameUrl("usuario.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Usu√£rio"); function.SetName("excluiUsuario"); function.SetNameUrl("usuario.do/excluir"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de Usu√£rios"); function.SetName("listaUsuario"); function.SetNameUrl("usuario.do/visualizar"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do usu√£rio"); function.SetName("usuario"); function.SetNameUrl("consultaUsuario.do/editar"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do usu√£rio"); function.SetName("usuario"); function.SetNameUrl("consultaUsuario.do/excluir"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do usu√£rio"); function.SetName("usuario"); function.SetNameUrl("consultaUsuario.do/visualizar"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller da senha"); function.SetName("alteraSenha"); function.SetNameUrl("alteraSenha.do/editar"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller da senha"); function.SetName("alteraSenha"); function.SetNameUrl("alteraSenha.do"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Altera√£√£o de Senha de outros"); function.SetName("alteraSenhaOutros"); function.SetNameUrl("alteraSenhaOutros.do/editar"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Altera√£√£o de Senha de outros"); function.SetName("alteraSenhaOutros"); function.SetNameUrl("alteraSenhaOutros.do"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("P√£gina Principal"); function.SetName("main"); function.SetNameUrl("main.jsp"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("P√£gina Sobre"); function.SetName("main_sobre"); function.SetNameUrl("main_sobre.jsp"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de PMV"); function.SetName("incluiPmv"); function.SetNameUrl("pmv.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de PMV"); function.SetName("editaPmv"); function.SetNameUrl("pmv.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Pmv"); function.SetName("excluiPmv"); function.SetNameUrl("pmv.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de PMV"); function.SetName("listaPmv"); function.SetNameUrl("pmv.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do PMV"); function.SetName("PMV"); function.SetNameUrl("searchPmv.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do PMV"); function.SetName("PMV"); function.SetNameUrl("searchPmv.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do PMV"); function.SetName("PMV"); function.SetNameUrl("searchPmv.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de Fornecedor"); function.SetName("incluiFornecedor"); function.SetNameUrl("constructor.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de Fornecedor"); function.SetName("editaFornecedor"); function.SetNameUrl("constructor.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Fornecedor"); function.SetName("excluiFornecedor"); function.SetNameUrl("constructor.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de Fornecedor"); function.SetName("listaFornecedor"); function.SetNameUrl("constructor.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Fornecedor"); function.SetName("Fornecedor"); function.SetNameUrl("searchConstructor.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Fornecedor"); function.SetName("Fornecedor"); function.SetNameUrl("searchConstructor.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Fornecedor"); function.SetName("Fornecedor"); function.SetNameUrl("searchConstructor.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de AT"); function.SetName("incluiAT"); function.SetNameUrl("at.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de AT"); function.SetName("editaAT"); function.SetNameUrl("at.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de AT"); function.SetName("excluiAT"); function.SetNameUrl("at.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de AT"); function.SetName("listaAT"); function.SetNameUrl("at.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do AT"); function.SetName("AT"); function.SetNameUrl("searchAt.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do AT"); function.SetName("AT"); function.SetNameUrl("searchAt.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do AT"); function.SetName("AT"); function.SetNameUrl("searchAt.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de Sensor AT"); function.SetName("incluiSensorAT"); function.SetNameUrl("sensorAt.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de Sensor AT"); function.SetName("editaSensorAT"); function.SetNameUrl("sensorAt.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Sensor AT"); function.SetName("excluiSensorAT"); function.SetNameUrl("sensorAt.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de Sensor AT"); function.SetName("listaSensorAT"); function.SetNameUrl("sensorAt.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor AT"); function.SetName("SensorAT"); function.SetNameUrl("searchSensorAt.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor AT"); function.SetName("SensorAT"); function.SetNameUrl("searchSensorAt.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor AT"); function.SetName("SensorAT"); function.SetNameUrl("searchSensorAt.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de Meteo"); function.SetName("incluiMeteo"); function.SetNameUrl("meteo.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de Meteo"); function.SetName("editaMeteo"); function.SetNameUrl("meteo.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Meteo"); function.SetName("excluiMeteo"); function.SetNameUrl("meteo.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de Meteo"); function.SetName("listaMeteo"); function.SetNameUrl("meteo.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Meteo"); function.SetName("Meteo"); function.SetNameUrl("searchMeteo.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Meteo"); function.SetName("Meteo"); function.SetNameUrl("searchMeteo.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Meteo"); function.SetName("Meteo"); function.SetNameUrl("searchMeteo.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Inclus√£o de Sensor Meteo"); function.SetName("incluiSensorMeteo"); function.SetNameUrl("sensorMeteo.do/create"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Edi√£√£o de Sensor Meteo"); function.SetName("editaSensorMeteo"); function.SetNameUrl("sensorMeteo.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Exclus√£o de Sensor Meteo"); function.SetName("excluiSensorMeteo"); function.SetNameUrl("sensorMeteo.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Consulta de Sensor Meteo"); function.SetName("listaSensorMeteo"); function.SetNameUrl("sensorMeteo.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor Meteo"); function.SetName("SensorMeteo"); function.SetNameUrl("searchSensorMeteo.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor Meteo"); function.SetName("SensorMeteo"); function.SetNameUrl("searchSensorMeteo.do/delete"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Sensor Meteo"); function.SetName("SensorMeteo"); function.SetNameUrl("searchSensorMeteo.do/view"); function.AddProfile(admin); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do PmvMessage"); function.SetName("sendPmvMessage"); function.SetNameUrl("sendMessagePmv.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do ActiveConf"); function.SetName("activeConf"); function.SetNameUrl("activeConf.do/edit"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Monitor"); function.SetName("monitor"); function.SetNameUrl("monitor.do/view"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller do Monitor"); function.SetName("monitor"); function.SetNameUrl("monitor.do/view"); function.AddProfile(oper); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller da Consulta Mensage"); function.SetName("searchMessagePMV"); function.SetNameUrl("searchMessagePmv.do/view"); function.AddProfile(admin); odb.Store(function); function = new NeoDatis.Odb.Test.Update.Nullobject.Functions(); function.SetDescription("Controller da Consulta Mensage"); function.SetName("searchMessagePMV"); function.SetNameUrl("searchMessagePmv.do/view"); function.AddProfile(oper); odb.Store(function); }
public virtual void Test1() { string file = "testeul.neodatis"; DeleteBase(file); NeoDatis.Odb.Test.List.Update.DadosUsuario dadosUsuario = new NeoDatis.Odb.Test.List.Update.DadosUsuario (); dadosUsuario.SetNome("Olivier"); dadosUsuario.SetLogin("olivier"); dadosUsuario.SetEmail("*****@*****.**"); dadosUsuario.SetOid("oid"); System.Collections.IList l = new System.Collections.ArrayList(); l.Add(new NeoDatis.Odb.Test.List.Update.Publicacao("p1", "Texto 1")); dadosUsuario.SetPublicados(l); NeoDatis.Odb.ODB odb = null; try { odb = Open(file); odb.Store(dadosUsuario); } finally { if (odb != null) { odb.Close(); } } try { odb = Open(file); NeoDatis.Odb.Objects <DadosUsuario> l2 = odb.GetObjects <DadosUsuario>(); Println(l2); NeoDatis.Odb.Test.List.Update.DadosUsuario du = (NeoDatis.Odb.Test.List.Update.DadosUsuario )l2.GetFirst(); du.GetPublicados().Add(new NeoDatis.Odb.Test.List.Update.Publicacao("p2", "Texto2" )); odb.Store(du); } finally { if (odb != null) { odb.Close(); } } try { odb = Open(file); NeoDatis.Odb.Objects <DadosUsuario> l2 = odb.GetObjects <DadosUsuario>(); Println(l2); NeoDatis.Odb.Test.List.Update.DadosUsuario du = (NeoDatis.Odb.Test.List.Update.DadosUsuario )l2.GetFirst(); Println(du.GetPublicados()); AssertEquals(2, du.GetPublicados().Count); } finally { if (odb != null) { odb.Close(); } } }
// deleteBase("t-simple-instance.neodatis"); /// <exception cref="System.Exception"></exception> public virtual void TestSimpleInstanceRetrievingWithNQ() { if (!isLocal || !useSameVmOptimization) { return; } DeleteBase("t-simple-instance.neodatis"); NeoDatis.Odb.ODB odb = Open("t-simple-instance.neodatis"); TestClass tc1 = new TestClass (); tc1.SetBigDecimal1(new System.Decimal(1.123456)); tc1.SetBoolean1(true); tc1.SetChar1('d'); tc1.SetDouble1(154.78998989); tc1.SetInt1(78964); tc1.SetString1("Ola chico como vc est\u00E1 ???"); tc1.SetDate1(new System.DateTime()); tc1.SetBoolean2(false); TestClass tc2 = new TestClass (); tc2.SetBigDecimal1(new System.Decimal(1.1234565454)); tc2.SetBoolean1(false); tc2.SetChar1('c'); tc2.SetDouble1(78454.8779); tc2.SetInt1(1254); tc2.SetString1("Ola chico como ca va ???"); tc2.SetDate1(new System.DateTime()); tc2.SetBoolean2(true); odb.Store(tc1); odb.Store(tc2); odb.Close(); odb = Open("t-simple-instance.neodatis"); NeoDatis.Odb.Core.Query.IQuery q = new _SimpleNativeQuery_146(); NeoDatis.Odb.Objects <TestClass> l = odb.GetObjects <TestClass>(q); TestClass tc12 = l.GetFirst(); // println("#### " + l.size() + " : " + l); AssertEquals(tc1.GetBigDecimal1(), tc12.GetBigDecimal1()); AssertEquals(tc1.GetString1(), tc12.GetString1()); AssertEquals(tc1.GetChar1(), tc12.GetChar1()); AssertEquals(tc1.GetDouble1(), tc12.GetDouble1()); AssertEquals(tc1.GetInt1(), tc12.GetInt1()); AssertEquals(tc1.IsBoolean1(), tc12.IsBoolean1()); AssertEquals(false, tc12.GetBoolean2()); if (l.Count < 3) { AssertEquals(tc1.GetDate1(), tc12.GetDate1()); } l.Next(); TestClass tc22 = (TestClass)l.Next(); AssertEquals(tc2.GetBigDecimal1(), tc22.GetBigDecimal1()); AssertEquals(tc2.GetString1(), tc22.GetString1()); AssertEquals(tc2.GetChar1(), tc22.GetChar1()); AssertEquals(tc2.GetDouble1(), tc22.GetDouble1()); AssertEquals(tc2.GetInt1(), tc22.GetInt1()); AssertEquals(tc2.IsBoolean1(), tc22.IsBoolean1()); AssertEquals(true, tc2.GetBoolean2()); if (l.Count < 3) { AssertEquals(tc2.GetDate1(), tc22.GetDate1()); } odb.Close(); DeleteBase("t-simple-instance.neodatis"); }
// just to avoid junit warning /// <exception cref="System.Exception"></exception> public virtual void T1estA1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); }
/// <exception cref="System.Exception"></exception> public virtual void T1estB1() { NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); odb.Commit(); }
public virtual void TestSelectUnCommitedObject4() { 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(); } } // Create instance NeoDatis.Odb.Test.VO.Sport.Sport volleyball = new NeoDatis.Odb.Test.VO.Sport.Sport ("volley-ball"); // Create 4 players NeoDatis.Odb.Test.VO.Sport.Player player1 = new NeoDatis.Odb.Test.VO.Sport.Player ("olivier", new System.DateTime(), volleyball); NeoDatis.Odb.Test.VO.Sport.Player player2 = new NeoDatis.Odb.Test.VO.Sport.Player ("pierre", new System.DateTime(), volleyball); NeoDatis.Odb.Test.VO.Sport.Player player3 = new NeoDatis.Odb.Test.VO.Sport.Player ("elohim", new System.DateTime(), volleyball); NeoDatis.Odb.Test.VO.Sport.Player player4 = new NeoDatis.Odb.Test.VO.Sport.Player ("minh", new System.DateTime(), volleyball); // Create two teams NeoDatis.Odb.Test.VO.Sport.Team team1 = new NeoDatis.Odb.Test.VO.Sport.Team("Paris" ); NeoDatis.Odb.Test.VO.Sport.Team team2 = new NeoDatis.Odb.Test.VO.Sport.Team("Montpellier" ); // Set players for team1 team1.AddPlayer(player1); team1.AddPlayer(player2); // Set players for team2 team2.AddPlayer(player3); team2.AddPlayer(player4); // Then create a volley ball game for the two teams NeoDatis.Odb.Test.VO.Sport.Game game = new NeoDatis.Odb.Test.VO.Sport.Game(new System.DateTime (), volleyball, team1, team2); odb = null; try { // Open the database odb = Open(BaseName); // Store the object odb.Store(game); } finally { if (odb != null) { // Close the database odb.Close(); } } try { // Open the database odb = Open(BaseName); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Sport.Player), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "olivier")); NeoDatis.Odb.Objects <Player> players = odb.GetObjects <Player>(query); Println("\nStep 3 : Players with name olivier"); int i = 1; // display each object while (players.HasNext()) { Println((i++) + "\t: " + players.Next()); } } 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" )); NeoDatis.Odb.OID oid = odb.Store(agassi); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Sport.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 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 Test2() { string file = "testeul.neodatis"; DeleteBase(file); NeoDatis.Odb.Test.List.Update.DadosUsuario dadosUsuario = new NeoDatis.Odb.Test.List.Update.DadosUsuario (); dadosUsuario.SetNome("Olivier"); dadosUsuario.SetLogin("olivier"); dadosUsuario.SetEmail("*****@*****.**"); dadosUsuario.SetOid("oid"); System.Collections.IList l = new System.Collections.ArrayList(); l.Add(new NeoDatis.Odb.Test.List.Update.Publicacao("p0", "Texto0")); dadosUsuario.SetPublicados(l); NeoDatis.Odb.ODB odb = null; try { odb = Open(file); odb.Store(dadosUsuario); } finally { if (odb != null) { odb.Close(); } } int size = 100; for (int i = 0; i < size; i++) { try { odb = Open(file); NeoDatis.Odb.Objects <DadosUsuario> l2 = odb.GetObjects <DadosUsuario>(); // println(l2); NeoDatis.Odb.Test.List.Update.DadosUsuario du = (NeoDatis.Odb.Test.List.Update.DadosUsuario )l2.GetFirst(); du.GetPublicados().Add(new NeoDatis.Odb.Test.List.Update.Publicacao("p" + (i + 1) , "Texto" + (i + 1))); odb.Store(du); } finally { if (odb != null) { odb.Close(); } } } try { odb = Open(file); NeoDatis.Odb.Objects <DadosUsuario> l2 = odb.GetObjects <DadosUsuario>(); Println(l2); NeoDatis.Odb.Test.List.Update.DadosUsuario du = (NeoDatis.Odb.Test.List.Update.DadosUsuario )l2.GetFirst(); Println(du.GetPublicados()); AssertEquals(size + 1, du.GetPublicados().Count); for (int i = 0; i < size + 1; i++) { NeoDatis.Odb.Test.List.Update.Publicacao p = (NeoDatis.Odb.Test.List.Update.Publicacao )du.GetPublicados()[i]; AssertEquals("Texto" + (i), p.GetTexto()); AssertEquals("p" + (i), p.GetName()); } } finally { if (odb != null) { odb.Close(); } } }