Ejemplo n.º 1
0
  public void populate(DatabaseSession session) {
    Employee instance;
    PopulationManager manager = PopulationManager.getDefaultManager();

    instance = Employee.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "example1");
    manager.registerObject(instance.computer, "example1");
    manager.registerObject(instance.shipments.firstElement(), "example1");
    manager.registerObject(
        ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example1");

    instance = Employee.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "example2");
    manager.registerObject(instance.computer, "example2");
    manager.registerObject(instance.shipments.firstElement(), "example2");
    manager.registerObject(
        ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example2");

    instance = Employee.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "example3");
    manager.registerObject(instance.computer, "example3");
    manager.registerObject(instance.shipments.firstElement(), "example3");
    manager.registerObject(
        ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example3");
  }
  public static TestSuite getReadObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("InterfaceWithoutTablesReadObjectTestSuite");
    suite.setDescription(
        "This suite test the reading of each object in the interface model (without tables).");

    PopulationManager manager = PopulationManager.getDefaultManager();

    suite.addTest(new ReadObjectTest(manager.getObject(Actor.class, "example4")));
    suite.addTest(new ReadObjectTest(manager.getObject(Documentary.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Film.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Employee.class, "example2")));
    suite.addTest(new ReadObjectTest(manager.getObject(CourseDeveloper.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Email.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(PersonnelManager.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Phone.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(ProductDeveloper.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(ProductManager.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Receptionist.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Secretary.class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(Employee.class, "example4")));
    suite.addTest(new ReadObjectTest(manager.getObject(Employee.class, "example1")));

    suite.addTest(getReadInterfaceObjectTest());

    return suite;
  }
  public TestSuite getCustomIndirectContainerTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("CustomIndirectContainerTestSuite");
    suite.setDescription("This suite tests custom IndirectContainers.");

    PopulationManager manager = PopulationManager.getDefaultManager();

    suite.addTest(new ReadObjectTest(manager.getObject(Dog.class, "Bart")));
    suite.addTest(new UpdateDogTest());
    suite.addTest(new NullCollectionTest());
    return suite;
  }
  public static ReadObjectTest getReadInterfaceObjectTest() {
    TestSuite suite = new TestSuite();
    PopulationManager manager = PopulationManager.getDefaultManager();
    Contact contact = ((Employee) manager.getObject(Employee.class, "example1")).getContact();

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression expression = builder.get("id").equal(contact.getEmp().getId());

    ReadObjectQuery query = new ReadObjectQuery();
    query.setReferenceClass(ContactHolder.class);
    query.setSelectionCriteria(expression);

    ReadObjectTest test = new ReadObjectTest(contact.getEmp());
    test.setQuery(query);

    return test;
  }
  public static TestSuite getUpdateObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("InterfaceWithoutTablesUpdateObjectTestSuite");
    suite.setDescription(
        "This suite tests the updating of each object in the interface model (without tables).");

    PopulationManager manager = PopulationManager.getDefaultManager();

    suite.addTest(new WriteObjectTest(manager.getObject(Employee.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(Employee.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(CourseDeveloper.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(CourseDeveloper.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(Email.class, "example1")));
    suite.addTest(new UnitOfWorkBasicUpdateObjectTest(manager.getObject(Email.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(PersonnelManager.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(PersonnelManager.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(Phone.class, "example1")));
    suite.addTest(new UnitOfWorkBasicUpdateObjectTest(manager.getObject(Phone.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(ProductDeveloper.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(ProductDeveloper.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(ProductManager.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(ProductManager.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(Receptionist.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(Receptionist.class, "example1")));
    suite.addTest(new WriteObjectTest(manager.getObject(Secretary.class, "example1")));
    suite.addTest(
        new UnitOfWorkBasicUpdateObjectTest(manager.getObject(Secretary.class, "example1")));
    suite.addTest(new UpdateObjectTest());
    suite.addTest(new VariableOneToOneNonPrivatelyOwnedTest());

    return suite;
  }
  public void populate(DatabaseSession session) {
    PopulationManager manager = PopulationManager.getDefaultManager();

    Cat cat = Cat.example1();
    session.writeObject(cat);
    manager.registerObject(cat, "catExample1");

    Dog dog = Dog.example1();
    session.writeObject(dog);
    manager.registerObject(dog, "dogExample1");

    cat = Cat.example2();
    session.writeObject(cat);
    manager.registerObject(cat, "catExample2");

    dog = Dog.example2();
    session.writeObject(dog);
    manager.registerObject(dog, "dogExample2");

    cat = Cat.example3();
    session.writeObject(cat);
    manager.registerObject(cat, "catExample3");

    dog = Dog.example3();
    session.writeObject(dog);
    manager.registerObject(dog, "dogExample3");

    Company company = Company.example1();
    session.writeObject(company);
    manager.registerObject(company, "example1");

    manager.registerObject(((Vector) company.getVehicles().getValue()).firstElement(), "example1");

    company = Company.example2();
    session.writeObject(company);
    manager.registerObject(company, "example2");

    company = Company.example3();
    session.writeObject(company);
    manager.registerObject(company, "example3");

    Person person = Person.example1();
    session.writeObject(person);
    manager.registerObject(person, "example1");

    // populate the data for duplicate field testing
    session.writeObject(A_King2.exp1());
    session.writeObject(A_King2.exp2());
    session.writeObject(A_1_King2.exp3());
    session.writeObject(A_2_King2.exp4());
    session.writeObject(A_2_1_King2.exp5());

    UnitOfWork unitOfWork = session.acquireUnitOfWork();
    person = Person.example2();
    unitOfWork.registerObject(person);
    unitOfWork.commit();
    manager.registerObject(person, "example2");
    manager.registerObject(person.bestFriend, "example5");
    manager.registerObject(person.representitive, "example4");

    person = Person.example3();
    session.writeObject(person);
    manager.registerObject(person, "example3");

    Computer computer = Computer.example1();
    session.writeObject(computer);
    manager.registerObject(computer, "example1");

    computer = Computer.example2();
    session.writeObject(computer);
    manager.registerObject(computer, "example2");

    computer = Computer.example3();
    session.writeObject(computer);
    manager.registerObject(computer, "example3");

    computer = Computer.example4();
    session.writeObject(computer);
    manager.registerObject(computer, "example4");

    computer = Computer.example5();
    session.writeObject(computer);
    manager.registerObject(computer, "example5");

    JavaProgrammer JP = JavaProgrammer.example1();
    session.writeObject(JP);
    manager.registerObject(JP, "example1");

    JP = JavaProgrammer.example2();
    session.writeObject(JP);
    manager.registerObject(JP, "example2");

    // Added to test bug 3019934.
    unitOfWork = session.acquireUnitOfWork();
    Alligator alligator = new Alligator();
    alligator.setFavoriteSwamp("Florida");
    alligator.setLatestVictim(JavaProgrammer.steve());
    unitOfWork.registerObject(alligator);
    manager.registerObject(alligator, "example1");
    unitOfWork.commit();

    // Added to test bug 6111278

    unitOfWork = session.acquireUnitOfWork();
    Entomologist bugguy = new Entomologist();
    bugguy.setId((int) System.currentTimeMillis());
    bugguy.setName("Gary");
    bugguy = (Entomologist) unitOfWork.registerObject(bugguy);
    Insect insect = new GrassHopper();
    insect.setIn_numberOfLegs(4);
    insect.setEntomologist(bugguy);
    bugguy.getInsectCollection().add(insect);
    unitOfWork.commit();
  }
Ejemplo n.º 7
0
 public CacheMissTest() {
   setDescription("Test cache miss for non-primary key query.");
   originalObject = PopulationManager.getDefaultManager().getObject(Employee.class, "0001");
 }
  public void populate(DatabaseSession session) {
    Object instance;
    PopulationManager manager = PopulationManager.getDefaultManager();

    instance = LockInCache.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache example1");

    instance = LockInCache.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache example2");

    instance = LockInCache.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache example3");

    instance = LockInObject.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Object example1");

    instance = LockInObject.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Object example2");

    instance = LockInObject.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Object example3");

    instance = TimestampInCache.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache TS example1");

    instance = TimestampInCache.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache TS example2");

    instance = TimestampInCache.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Cache TS example3");

    instance = TimestampInObject.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Object TS example1");

    instance = TimestampInObject.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Object TS example2");

    instance = TimestampInObject.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Object TS example3");

    instance = ChangedRow.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "ChangedRow example1");

    instance = ChangedRow.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "ChangedRow example2");

    instance = ChangedRow.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "ChangedRow example3");

    instance = TimestampInAggregateObject.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Aggregate Object TS example1");

    instance = TimestampInAggregateObject.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Aggregate Object TS example2");

    instance = TimestampInAggregateObject.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Aggregate Object TS example3");

    instance = LockInAggregateObject.example1();
    session.writeObject(instance);
    manager.registerObject(instance, "Lock Object TS example1");

    instance = LockInAggregateObject.example2();
    session.writeObject(instance);
    manager.registerObject(instance, "Lock Object TS example2");

    instance = LockInAggregateObject.example3();
    session.writeObject(instance);
    manager.registerObject(instance, "Lock Object TS example3");

    UnitOfWork uow = session.acquireUnitOfWork();
    instance = uow.registerObject(RockBand.example1());
    manager.registerObject(instance, "RockBand example1");
    instance = uow.registerObject(RockBand.example2());
    manager.registerObject(instance, "RockBand example2");
    uow.commit();
  }