public void testSimpleTestWithCommit() throws Exception { TimeTaker t = start("testBasicCommitPerformance"); CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource(getResourcePath("/test1")); getModel1Factory().createCustomer(); for (int i = 0; i < 500; i++) { Customer customer = getModel1Factory().createCustomer(); customer.setCity("Barovia"); customer.setName("Strahd von Zarovich"); customer.setStreet("Necromancer Road 5"); for (int c = 0; c < 5; c++) { SalesOrder salesOrder = getModel1Factory().createSalesOrder(); salesOrder.setCustomer(customer); salesOrder.setId(c); resource.getContents().add(salesOrder); } resource.getContents().add(customer); } transaction.commit(); finish(t); msg(t.getTiming()); }
public void testLoadAnStoreDataPerformance() throws Exception { TimeTaker t = start("testLoadAnStoreDataPerformance"); { CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource(getResourcePath("/test1")); getModel1Factory().createCustomer(); for (int i = 0; i < 500; i++) { Customer customer = getModel1Factory().createCustomer(); customer.setCity("Barovia"); customer.setName("Strahd von Zarovich"); customer.setStreet("Necromancer Road 5"); for (int c = 0; c < 5; c++) { SalesOrder salesOrder = getModel1Factory().createSalesOrder(); salesOrder.setCustomer(customer); salesOrder.setId(c); resource.getContents().add(salesOrder); } resource.getContents().add(customer); } transaction.commit(); session.close(); } { CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.getResource(getResourcePath("/test1")); int i = 0; for (EObject o : resource.getContents()) { if (o instanceof Customer) { Customer customer = (Customer) o; customer.setCity("Dargaard"); customer.setName("Lord Soth"); customer.setStreet("Death Knight Alley 7"); for (SalesOrder salesOrder : customer.getSalesOrders()) { salesOrder.setId(salesOrder.getId() + 1); } i++; } } assertEquals(500, i); transaction.commit(); session.close(); } finish(t); msg(t.getTiming()); }
public void testBugzilla_266982() throws Exception { final Customer customer = getModel1Factory().createCustomer(); final boolean done[] = new boolean[1]; final Exception exception[] = new Exception[1]; done[0] = false; customer.setName("customer"); CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource(getResourcePath("/test1")); resource.getContents().add(customer); transaction.commit(); Runnable changeObjects = new Runnable() { public void run() { try { CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); Customer customerToLoad = (Customer) CDOUtil.getEObject( transaction.getObject(CDOUtil.getCDOObject(customer).cdoID())); while (!done[0]) { // Could fail if the attach is not thread safe customerToLoad.getName(); } transaction.close(); session.close(); } catch (Exception ex) { exception[0] = ex; } } }; new Thread(changeObjects).start(); for (int i = 0; i < 500 && exception[0] == null; i++) { customer.setName("Ottawa" + i); transaction.commit(); } done[0] = true; if (exception[0] != null) { exception[0].printStackTrace(); fail(exception[0].getMessage()); } session.close(); }
public void testSimpleTestNoCommit() throws Exception { TimeTaker t = start("testSimpleTestNoCommit"); getModel1Factory().createCustomer(); for (int i = 0; i < 50000; i++) { Customer customer = getModel1Factory().createCustomer(); customer.setCity("Barovia"); customer.setName("Strahd von Zarovich"); customer.setStreet("Necromancer Road 5"); for (int c = 0; c < 50; c++) { SalesOrder salesOrder = getModel1Factory().createSalesOrder(); salesOrder.setCustomer(customer); salesOrder.setId(c); } } finish(t); msg(t.getTiming()); }
public void testAddRemove() throws Exception { TimeTaker t = start("testAddRemove"); CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource(getResourcePath("/test1")); for (int i = 0; i < 100; i++) { Customer customer = getModel1Factory().createCustomer(); customer.setName("Azalin Rex"); customer.setCity("Darkon"); resource.getContents().add(customer); transaction.commit(); resource.getContents().remove(resource.getContents().size() - 1); transaction.commit(); resource.getContents().add(customer); transaction.commit(); } finish(t); msg(t.getTiming()); }