Exemple #1
0
  public void testLoadTruck() throws Exception {
    Database database = _category.getDatabase();

    database.begin();
    Truck truck = (Truck) database.load(Truck.class, new Integer(5));
    database.commit();

    assertNotNull(truck);
    assertEquals(5, truck.getId());

    database.close();
  }
Exemple #2
0
  public void testCreateAndLoadCar() throws Exception {
    Database database = _category.getDatabase();

    database.begin();
    Order order = new Order();
    order.setId(11);
    order.setName("order 11");
    database.create(order);
    database.commit();

    database.begin();
    ProductDetail detail = new ProductDetail();
    detail.setId(11);
    detail.setCategory("category 11");
    detail.setLocation("location 11");
    database.create(detail);
    database.commit();

    database.begin();
    Truck truck = new Truck();
    truck.setId(11);
    truck.setName("truck 11");
    truck.setKw(112);
    truck.setMake("Fiat");
    truck.setMaxWeight(3750);
    truck.setDetail((ProductDetail) database.load(ProductDetail.class, new Integer(11)));
    database.create(truck);
    Collection orders = new LinkedList();
    orders.add(database.load(Order.class, new Integer(11)));
    truck.setOrders(orders);
    database.commit();

    database.begin();
    Object object = database.load(Car.class, new Integer(11));
    assertNotNull(object);
    assertEquals("ctf.jdo.tc9x.Truck", object.getClass().getName());
    Truck loadedTruck = (Truck) object;
    database.commit();

    assertNotNull(loadedTruck);
    assertEquals(11, loadedTruck.getId());

    database.begin();
    database.remove(database.load(Car.class, new Integer(11)));
    database.remove(database.load(ProductDetail.class, new Integer(11)));
    database.remove(database.load(Order.class, new Integer(11)));
    database.commit();

    database.close();
  }
Exemple #3
0
  public void testLoadCar() throws Exception {
    Database database = _category.getDatabase();

    database.begin();
    Object object = database.load(Car.class, new Integer(5));
    assertNotNull(object);
    assertEquals("ctf.jdo.tc9x.Truck", object.getClass().getName());
    Truck truck = (Truck) object;
    database.commit();

    assertNotNull(truck);
    assertEquals(5, truck.getId());

    database.close();
  }