Package org.conserve.objects

Examples of org.conserve.objects.SimpleObject


  @Test
  public void testAddObject() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a test object
    SimpleObject so = new SimpleObject();
    so.setAge(1000L);
    so.setCount(3);
    so.setName("foo bar");
    so.setScale(0.67);
    persist.saveObject(so);
    LessSimpleObject lso = new LessSimpleObject();
    lso.setAge(1000000L);
    lso.setCount(123456);
    lso.setKey((short) 99);
View Full Code Here


  @Test
  public void testGetObjectFromInterface() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a test object
    SimpleObject so = new SimpleObject();
    so.setAge(1000L);
    so.setCount(3);
    so.setName("foo bar");
    so.setScale(0.67);
    persist.saveObject(so);
    LessSimpleObject lso = new LessSimpleObject();
    lso.setAge(1000000L);
    lso.setCount(123456);
    lso.setKey((short) 99);
View Full Code Here

  public void testGetObjectFromClass() throws Exception
  {

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a test object
    SimpleObject so = new SimpleObject();
    so.setAge(1000L);
    so.setCount(3);
    so.setName("foo bar");
    so.setScale(0.67);
    persist.saveObject(so);
    LessSimpleObject lso = new LessSimpleObject();
    lso.setAge(1000000L);
    lso.setCount(123456);
    lso.setKey((short) 99);
    lso.setName("j random");
    lso.setScale(-9.0);
    persist.saveObject(lso);
    // insert the same object again
    persist.saveObject(lso);
    persist.close();

    persist = new PersistenceManager(driver, database, login, password);
    // try getting all the objects
    SimpleObject pattern = new SimpleObject();
    pattern.setCount(3);
    List<SimpleObject> obs = persist.getObjects(SimpleObject.class, new GreaterOrEqual(pattern));
    assertEquals(2, obs.size());
    pattern.setCount(4);
    obs = persist.getObjects(SimpleObject.class, new GreaterOrEqual(pattern));
    assertEquals(1, obs.size());
    pattern.setCount(3);
    List<LessSimpleObject> obs2 = persist.getObjects(LessSimpleObject.class, new GreaterOrEqual(pattern));
    assertEquals(1, obs2.size());

    // assert that two objects are equal if they are the result of the same
    // search
View Full Code Here

  public void testDeleteObject() throws Exception
  {

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a test object
    SimpleObject so = new SimpleObject();
    so.setAge(1000L);
    so.setCount(3);
    so.setName("foo bar");
    so.setScale(0.67);
    persist.saveObject(so);
    LessSimpleObject lso = new LessSimpleObject();
    lso.setAge(1000000L);
    lso.setCount(123456);
    lso.setKey((short) 99);
    lso.setName("j random");
    lso.setScale(-9.0);
    persist.saveObject(lso);
    // insert the same object again
    persist.saveObject(lso);
    persist.close();

    persist = new PersistenceManager(driver, database, login, password);
    // try deleting one object
    List<Object> allObjects = persist.getObjectsMatching(new Object());
    assertEquals(2, allObjects.size());
    // delete one LessSimpleObject
    SimpleObject pattern = new LessSimpleObject();
    persist.deleteObjects(LessSimpleObject.class, new GreaterOrEqual(pattern));
    allObjects = persist.getObjectsMatching(new Object());
    assertEquals(1, allObjects.size());
    // delete all objects
    persist.deleteObjects(new Object());
View Full Code Here

    ComplexObject[] coArray = new ComplexObject[3];
    for (int x = 0; x < coArray.length; x++)
    {
      ComplexObject co = new ComplexObject();
      co.setData(new double[] { x, x * 2, x * 3 });
      SimpleObject so = new SimpleObject();
      so.setAge((long) x);
      co.setObject(so);
      coArray[x] = co;
    }
    cao.setData(coArray);
    persist.saveObject(cao);
View Full Code Here

    ComplexObject[] coArray = new ComplexObject[3];
    for (int x = 0; x < coArray.length - 1; x++)
    {
      ComplexObject co = new ComplexObject();
      co.setData(new double[] { x, x * 2, x * 3 });
      SimpleObject so = new SimpleObject();
      so.setAge((long) x);
      co.setObject(so);
      coArray[x] = co;
    }
    // one of the complex objects in the array has an outside reference
    coArray[2] = co1;
View Full Code Here

  @Test
  public void testUpdateSimple() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    // create a simple object
    SimpleObject object = new SimpleObject();
    object.setAge(500L);
    // save it
    persist.saveObject(object);
    // make sure only one object exists
    List<SimpleObject> allObjects = persist.getObjectsMatching(new SimpleObject());
    assertEquals(1, allObjects.size());
    // change the object
    object.setAge(1000L);
    // save the object again
    persist.saveObject(object);
    // make sure there's still only one object
    allObjects = persist.getObjectsMatching(new SimpleObject());
    assertEquals(1, allObjects.size());
    // re-open the database connection
    persist.close();
    persist = new PersistenceManager(driver, database, login, password);
    // make sure the object has been changed
    allObjects = persist.getObjectsMatching(new SimpleObject());
    assertEquals(1, allObjects.size());
    SimpleObject first = allObjects.get(0);
    assertTrue(first.getAge().equals(1000L));

    // add another object
    SimpleObject nuObject = new SimpleObject();
    nuObject.setAge(1L);
    persist.saveObject(nuObject);

    // update the new object
    nuObject.setAge(2L);

    // make sure only one object has been modified
    allObjects = persist.getObjectsMatching(new SimpleObject());
    assertEquals(2, allObjects.size());
    first = allObjects.get(0);
    SimpleObject second = allObjects.get(1);
    assertTrue((first.getAge() == 2L && second.getAge() == 1000L)
        || (first.getAge() == 1000L && second.getAge() == 2L));

    persist.close();

  }
View Full Code Here

   */
  @Test
  public void testGetClasses() throws Exception
  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    persist.saveObject(new SimpleObject());
    List<Class<?>> classList = persist.getClasses();
    for (Class<?> c : classList)
    {
      System.out.println(ObjectTools.getSystemicName(c));
    }
View Full Code Here

  public void testRefresh() throws Exception
  {
    PersistenceManager persistOne = new PersistenceManager(driver, database, login, password);
    PersistenceManager persistTwo = new PersistenceManager(driver, database, login, password);
    // create a simple object
    SimpleObject so = new SimpleObject();
    so.setName("foo bar");

    // save the object
    persistOne.saveObject(so);

    // load the object from another instance
    List<SimpleObject> simpleObjects = persistTwo.getObjects(SimpleObject.class, new All());
    SimpleObject copy = simpleObjects.get(0);

    // alter the original object
    so.setName("altered");
    // save the altered object
    persistOne.saveObject(so);
    // update the copy
    SimpleObject copy2 = persistTwo.refresh(copy);
    // make sure the change has propagated
    assertEquals(so.getName(), copy.getName());
    assertEquals(copy.getName(), copy2.getName());
    assertEquals(copy, copy2);
  }
View Full Code Here

  @Test
  public void testRenameTable() throws Exception
  {
    String name = "foo";
    int value = 42;
    Object otherObject = new SimpleObject();
    Object redundantObject = new SimplestObject();
    PersistenceManager pm = new PersistenceManager(driver, database, login, password);
    // drop all tables
    pm.dropTable(Object.class);
View Full Code Here

TOP

Related Classes of org.conserve.objects.SimpleObject

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.