public void testUpdateEO() {
// Create Company1 in OSC1
String companyName = "Company" + ERXRandomGUID.newGid();
EOEditingContext editingContext_osc1 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
Company company_osc1 = Company.createCompany(editingContext_osc1, companyName);
editingContext_osc1.saveChanges();
sleep();
// Fetch Company1 in OSC2
EOEditingContext editingContext_osc2 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
Company company_osc2 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName);
assertNotNull(company_osc2);
for (int i = 0; i < 10; i++) {
// Change Company1's name in OSC1
String companyName_1 = "Company" + ERXRandomGUID.newGid() + "_osc1";
company_osc1.setName(companyName_1);
editingContext_osc1.saveChanges();
sleep();
assertEquals(companyName_1, company_osc2.name());
assertEquals(companyName_1, company_osc1.name());
// Fetch Company1 by name in OSC1
Company company_osc1_with_companyName1 = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName_1);
assertEquals(company_osc1, company_osc1_with_companyName1);
// Fetch Company1 by name in OSC2
Company company_osc2_with_companyName1 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName_1);
assertEquals(company_osc2, company_osc2_with_companyName1);
// Change Company1's name in OSC2
String companyName_2 = "Company" + ERXRandomGUID.newGid() + "_osc2";
company_osc2.setName(companyName_2);
editingContext_osc2.saveChanges();
sleep();
assertEquals(companyName_2, company_osc1.name());
assertEquals(companyName_2, company_osc2.name());
// Fetch Company1 by name in OSC1
Company company_osc1_with_companyName2 = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName_2);
assertEquals(company_osc1, company_osc1_with_companyName2);
// Fetch Company1 by name in OSC2
Company company_osc2_with_companyName2 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName_2);
assertEquals(company_osc2, company_osc2_with_companyName2);
}
}