Package org.conserve.objects

Examples of org.conserve.objects.SimplestObject


  @Test
  public void testAddSimplestObject() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a test object
    SimplestObject so = new SimplestObject();
    so.setFoo(0.67);
    persist.saveObject(so);
    persist.close();
  }
View Full Code Here


    ComplexObject co = new ComplexObject(new double[] { 1.1, 2.2, 3.3 });
    LessSimpleObject so = new LessSimpleObject();
    so.setScale(0.67);
    co.setObject(so);
    SimplestObject sto = new SimplestObject();
    sto.setFoo(9999.6);
    co.setSimplestObject(sto);
    persist.saveObject(co);
    ComplexObject co2 = new ComplexObject(co.getData());
    co2.setObject(so);
    co2.setSimplestObject(sto);
View Full Code Here

    SimplestObject[][][] array = new SimplestObject[1][1][1];
    for (int x = 0; x < array.length; x++)
    {
      for (int y = 0; y < array[x].length; y++)
      {
        array[x][y][0] = new SimplestObject();
      }
    }
    co.setObject(array);
    persist.saveObject(co);
    ComplexObject co2 = new ComplexObject();
View Full Code Here

   */
  @Test
  public void testInnerMatching() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    SimplestObject so = new SimplestObject();
    so.setFoo(1.0);
    ComplexObject co = new ComplexObject();
    co.setObject(so);
    persist.saveObject(co);
    // close the persistence object
    persist.close();

    // re-open the persistence object
    persist = new PersistenceManager(driver, database, login, password);
    // create a SimplestObject so that no results will match
    so = new SimplestObject();
    so.setFoo(2.0);
    // make sure this matches no results
    ComplexObject search = new ComplexObject();
    search.setObject(so);
    List<ComplexObject> none = persist.getObjectsMatching(search);
    assertEquals(0, none.size());
    // change the search so that one object is returned
    so.setFoo(1.0);
    List<ComplexObject> one = persist.getObjectsMatching(search);
    assertEquals(1, one.size());

    persist.close();

View Full Code Here

  @Test
  public void testComplexArrayMatching() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a complex object with an Integer array as object
    SimplestObject[] array = new SimplestObject[] { new SimplestObject(), new SimplestObject(),
        new SimplestObject() };
    for (int x = 0; x < array.length; x++)
    {
      array[x].setFoo((double) (x + 1));
    }
    ComplexObject co = new ComplexObject();
    co.setObject(array);
    persist.saveObject(co);
    // close the persistence object
    persist.close();

    // re-open the persistence object
    persist = new PersistenceManager(driver, database, login, password);
    // create an integer array where all entries but one is null
    SimplestObject[] searchArray = new SimplestObject[3];
    searchArray[2] = new SimplestObject();
    searchArray[2].setFoo(2.0);
    // make sure this matches no results
    ComplexObject search = new ComplexObject();
    search.setObject(searchArray);
    List<ComplexObject> none = persist.getObjectsMatching(search);
    assertEquals(0, none.size());
    // change the search so that one object is returned
    searchArray[1] = new SimplestObject();
    searchArray[1].setFoo(2.0);
    searchArray[2].setFoo(3.0);
    List<ComplexObject> one = persist.getObjectsMatching(search);
    assertEquals(1, one.size());
View Full Code Here

  public void testArrayOfArraysMatching() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a complex object with an Integer array as object
    SimplestObject[][] array = new SimplestObject[][] { {},
        { new SimplestObject(), new SimplestObject(), new SimplestObject() }, {} };
    for (int x = 0; x < array[1].length; x++)
    {
      array[1][x].setFoo((double) (x + 1));
    }
    ComplexObject co = new ComplexObject();
    co.setObject(array);
    persist.saveObject(co);
    // close the persistence object
    persist.close();

    // re-open the persistence object
    persist = new PersistenceManager(driver, database, login, password);
    // create an integer array where all entries but one is null
    SimplestObject[][] searchArray = new SimplestObject[3][3];
    searchArray[1][2] = new SimplestObject();
    searchArray[1][2].setFoo(2.0);
    // make sure this matches no results
    ComplexObject search = new ComplexObject();
    search.setObject(searchArray);
    List<ComplexObject> none = persist.getObjectsMatching(search);
    assertEquals(0, none.size());
    // change the search so that one object is returned
    searchArray[1][1] = new SimplestObject();
    searchArray[1][1].setFoo(2.0);
    searchArray[1][2].setFoo(3.0);
    List<ComplexObject> one = persist.getObjectsMatching(search);
    assertEquals(1, one.size());
View Full Code Here

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    ConnectionWrapper cw = persist.getConnectionWrapper();
    // add a large number of entries
    for (int x = 0; x < 200; x++)
    {
      SimplestObject so = new SimplestObject();
      so.setFoo((double) x);
      persist.saveObject(cw, so);
    }
    cw.commitAndDiscard();
    // make sure the right number of objects are returned
    long count = persist.getCount(new SimplestObject());
    assertEquals(200L, count);
    // select half of the objects
    SimplestObject selectObject = new SimplestObject();
    selectObject.setFoo(99.0);
    Greater g = new Greater(selectObject);
    count = persist.getCount(SimplestObject.class, g);
    assertEquals(100L, count);
    persist.close();
  }
View Full Code Here

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    ConnectionWrapper cw = persist.getConnectionWrapper();
    // add a large number of entries
    for (int x = 0; x < 200; x++)
    {
      SimplestObject so = new SimplestObject();
      so.setFoo((double) x);
      persist.saveObject(cw, so);
    }
    cw.commitAndDiscard();
    // make sure all entries have been added
    List<SimplestObject> list = persist.getObjectsMatching(new SimplestObject());
    assertEquals(200, list.size());
    // select using sorting
    SimplestObject orderObject = new SimplestObject();
    orderObject.setFoo(0.0);
    list = persist.getObjects(SimplestObject.class, new Descending(orderObject));
    assertEquals(200, list.size());
    assertEquals((Double) 199.0, list.get(0).getFoo());
    list = persist.getObjects(SimplestObject.class, new Ascending(orderObject));
    assertEquals(200, list.size());
View Full Code Here

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    ConnectionWrapper cw = persist.getConnectionWrapper();
    // add a large number of entries
    for (int x = 0; x < 200; x++)
    {
      SimplestObject so = new SimplestObject();
      so.setFoo((double) x);
      ComplexObject co = new ComplexObject();
      co.setSimplestObject(so);
      persist.saveObject(cw, co);
    }
    cw.commitAndDiscard();
    // make sure all entries have been added
    List<ComplexObject> list = persist.getObjectsMatching(new ComplexObject());
    assertEquals(200, list.size());
    // select using sorting
    SimplestObject simpleObject = new SimplestObject();
    simpleObject.setFoo(0.0);
    ComplexObject orderObject = new ComplexObject();
    orderObject.setSimplestObject(simpleObject);

    list = persist.getObjects(ComplexObject.class, new Descending(orderObject));
    assertEquals(200, list.size());
View Full Code Here

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    ConnectionWrapper cw = persist.getConnectionWrapper();
    // add a large number of entries
    for (int x = 0; x < 200; x++)
    {
      SimplestObject so = new SimplestObject();
      so.setFoo((double) x);
      persist.saveObject(cw, so);
    }
    cw.commitAndDiscard();
    // make sure all entries have been added
    List<SimplestObject> list = persist.getObjectsMatching(new SimplestObject());
    assertEquals(200, list.size());
    // select using sorting
    SimplestObject orderObject = new SimplestObject();
    orderObject.setFoo(0.0);
    list = persist.getObjects(SimplestObject.class, new Order(20, 10, new Ascending(orderObject)));
    assertEquals(20, list.size());
    assertEquals((Double) 10.0, list.get(0).getFoo());
    list = persist.getObjects(SimplestObject.class, new Order(45, new Ascending(orderObject)));
    assertEquals(45, list.size());
View Full Code Here

TOP

Related Classes of org.conserve.objects.SimplestObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.