diff options
author | Eike Stepper | 2011-12-13 17:15:51 +0000 |
---|---|---|
committer | Eike Stepper | 2011-12-13 17:15:51 +0000 |
commit | 5454148920474eb316ab2026814b5e36f3d191d2 (patch) | |
tree | 04854016fe20c0351b0fb62e212237f4a009123a /plugins | |
parent | df26a6d92729d723c661d3a626dd2103569194c7 (diff) | |
download | cdo-5454148920474eb316ab2026814b5e36f3d191d2.tar.gz cdo-5454148920474eb316ab2026814b5e36f3d191d2.tar.xz cdo-5454148920474eb316ab2026814b5e36f3d191d2.zip |
Fix DeleteRandomTest
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java index 919312645b..f27cb7f928 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java @@ -16,6 +16,8 @@ import org.eclipse.emf.cdo.tests.model1.Category; import org.eclipse.emf.cdo.tests.model1.Company; import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTest; import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.CommitException; import java.util.Random; @@ -28,17 +30,11 @@ public class DeleteRandomTest extends PerformanceTest private static final int AMOUNT_ELEMENTS = 1000; - private CDOSession session; - private Random random = new Random(); - @Override - protected void doSetUp() throws Exception + private Company initModel() throws CommitException { - super.doSetUp(); - - session = openSession(); - + CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource(getResourcePath(RES_NAME)); @@ -53,30 +49,22 @@ public class DeleteRandomTest extends PerformanceTest resource.getContents().add(company); transaction.commit(); - transaction.close(); + + return company; } public void test() throws Exception { - for (int currentSize = AMOUNT_ELEMENTS; currentSize > AMOUNT_ELEMENTS / 2; currentSize--) - { - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.getResource(getResourcePath(RES_NAME)); - Company company = (Company)resource.getContents().get(0); + Company company = initModel(); + CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView(); + for (int i = 0; i < AMOUNT_ELEMENTS / 2; i++) + { + int currentSize = AMOUNT_ELEMENTS - i; int indexToRemove = random.nextInt(currentSize); + company.getCategories().remove(indexToRemove); transaction.commit(); - transaction.close(); } } - - @Override - protected void doTearDown() throws Exception - { - session.close(); - - super.doTearDown(); - } - } |