示例#1
0
  @Test
  public void deepTest() {
    customer1 = customerFactoryInstance.createCustomerType();
    customer2 = customerFactoryInstance.createCustomerType();
    address1 = customerFactoryInstance.createUSAddr();
    address2 = customerFactoryInstance.createUSAddr();

    // differ on a String value
    assertTrue(EcoreUtil.equals(customer1, customer2));
    address1.setTown("New Orleans");
    address2.setTown("Chicago");
    customer1.setAddress(address1);
    customer2.setAddress(address2);
    assertTrue(!EcoreUtil.equals(customer1, customer2));
    address1.setTown(address2.getTown());
    assertTrue(EcoreUtil.equals(customer1, customer2));

    // differ on a Date value
    address1.setTown(address2.getTown());
    assertTrue(EcoreUtil.equals(customer1, customer2));
    long now = System.currentTimeMillis();
    XMLCalendar date1 = new XMLCalendar(new Date(now), XMLCalendar.DATETIME);
    XMLCalendar date2 = new XMLCalendar(new Date(now + 3600000), XMLCalendar.DATETIME);
    credit1.setExpireDate(date1);
    credit2.setExpireDate(date2);
    customer1.setCreditCard(credit1);
    customer2.setCreditCard(credit2);
    assertTrue(!EcoreUtil.equals(customer1, customer2));
    credit1.setExpireDate(credit2.getExpireDate());
    assertTrue(EcoreUtil.equals(customer2, customer1));

    // credit1 and credit2 don't have the same container but are areEqual anyway.
    address1.setTown("Montreal");
    assertTrue(EcoreUtil.equals(credit1, credit2));
  }
示例#2
0
  /*
   * @see TestCase#setUp()
   */
  @Before
  public void setUp() throws Exception {
    if (employeePackage == null) {
      employeePackage = getEmployeePackage();
    }

    supplierFactoryInstance = SupplierFactory.eINSTANCE;
    po1 = supplierFactoryInstance.createPurchaseOrder();
    po2 = supplierFactoryInstance.createPurchaseOrder();
    supplier1 = supplierFactoryInstance.createSupplier();
    supplier2 = supplierFactoryInstance.createSupplier();

    customerFactoryInstance = CustomerFactory.eINSTANCE;
    customer1 = customerFactoryInstance.createCustomerType();
    customer2 = customerFactoryInstance.createCustomerType();
    address1 = customerFactoryInstance.createUSAddr();
    address2 = customerFactoryInstance.createUSAddr();
    credit1 = customerFactoryInstance.createCreditInfo();
    credit2 = customerFactoryInstance.createCreditInfo();
  }