Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6fe9097cfd4c89e6cfa631fcfe933a08e638e6d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Caspar De Groot - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.bugzilla;

import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Product1;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;

/**
 * @author Caspar De Groot
 */
public class Bugzilla_342130_Test extends AbstractCDOTest
{
  public void test() throws CommitException
  {
    CDOSession session = openSession();
    CDOTransaction tx = session.openTransaction();
    CDOResource resource = tx.createResource(getResourcePath("test"));

    Model1Factory factory = getModel1Factory();
    Category cat = factory.createCategory();

    // List length must be 1 to reproduce problem
    Product1 product1 = factory.createProduct1();
    product1.setName("product1");
    cat.getProducts().add(product1);
    resource.getContents().add(cat);
    tx.commit();

    // Add 0 (makes list length 2)
    Product1 product2 = factory.createProduct1();
    product2.setName("product2");
    cat.getProducts().add(0, product2);

    // Set 1 (leaves list length 2)
    Product1 product3 = factory.createProduct1();
    product3.setName("product3");
    cat.getProducts().set(1, product3);

    // Remove 0 (makes list length 1)
    cat.getProducts().remove(0);

    tx.commit();

    tx.close();
    session.close();
  }
}

Back to the top