Examples of SimpleObject


Examples of org.conserve.objects.SimpleObject

  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

Examples of org.conserve.objects.SimpleObject

    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

Examples of org.conserve.objects.SimpleObject

    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

Examples of org.conserve.objects.SimpleObject

  @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

Examples of org.conserve.objects.SimpleObject

   */
  @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

Examples of org.conserve.objects.SimpleObject

  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

Examples of org.conserve.objects.SimpleObject

  @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

Examples of org.conserve.objects.SimpleObject

  @Test
  public void testRenameColumn() 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

Examples of org.conserve.objects.SimpleObject

  @Test
  public void testAddRemoveColumns() 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

Examples of org.conserve.objects.SimpleObject

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

    // create original objects
    OriginalObject oo = new OriginalObject();
    oo.setName(name);
    oo.setValue(value);
    oo.setOtherObject(otherObject);
    oo.setRedundantObject(redundantObject);
    pm.saveObject(oo);
    pm.close();

    // change object to long
    pm = new PersistenceManager(driver, database, login, password);
    pm.changeName(OriginalObject.class, ObjectToLong.class);
    pm.close();
    pm = new PersistenceManager(driver, database, login, password);
    pm.updateSchema(ObjectToLong.class);
    pm.close();
    //check that objects exist/not exist
    pm = new PersistenceManager(driver, database, login, password);
    List<ObjectToLong>res = pm.getObjects(ObjectToLong.class, new All());
    assertEquals(1,res.size());
    ObjectToLong tmp = res.get(0);
    assertTrue(tmp.getName().equals(name));
    assertNull(tmp.getOtherObject());
    tmp.setOtherObject(42L);
    pm.saveObject(tmp);
    //check that the dependent object has been dropped
    List<SimpleObject>dependents = pm.getObjects(SimpleObject.class, new All());
    assertEquals(0,dependents.size());
    pm.close();
    // change long to object
    pm = new PersistenceManager(driver, database, login, password);
    pm.changeName(ObjectToLong.class, OriginalObject.class);
    pm.close();
    pm = new PersistenceManager(driver, database, login, password);
    pm.updateSchema(OriginalObject.class);
    pm.close();
    pm = new PersistenceManager(driver, database, login, password);
    List<OriginalObject>res1 = pm.getObjects(OriginalObject.class, new All());
    assertEquals(1,res1.size());
    OriginalObject tmp1 = res1.get(0);
    assertNull(tmp1.getOtherObject());
    tmp1.setOtherObject(new SimpleObject());
    pm.saveObject(tmp1);
    pm.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.