blob: 6bf2157d679327f56b5a2bbc41dda120b0ceb79c (
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
62
63
64
65
66
67
|
/*
* Copyright (c) 2015 Eike Stepper (Loehne, 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:
* Esteban Dugueperoux - 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.model6.MyEnum;
import org.eclipse.emf.cdo.tests.model6.MyEnumList;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import java.util.Collections;
/**
* Bug 467593 about NPE on {@link EList#hashCode()} call on object commit with a ref to the feature {@link EList} get before the commit.
*
* @author Esteban Dugueperoux
*/
public class Bugzilla_467593_Test extends AbstractCDOTest
{
private static final String RESOURCE_NAME = "test1.model1";
public void testEListHashCodeOnRefBeforeCommitWithCDOResource() throws Exception
{
CDOSession session1 = openSession();
CDOTransaction transaction1 = session1.openTransaction();
CDOResource resource1 = transaction1.createResource(getResourcePath(RESOURCE_NAME));
testEListHashCodeOnRefBeforeCommit(resource1);
}
public void testEListHashCodeOnRefBeforeCommitWithXMIResource() throws Exception
{
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("model6", new XMIResourceFactoryImpl());
URI localMainResourceURI = URI.createFileURI(createTempFile("main", ".model6").getCanonicalPath());
Resource resource1 = resourceSet.createResource(localMainResourceURI);
testEListHashCodeOnRefBeforeCommit(resource1);
}
private void testEListHashCodeOnRefBeforeCommit(Resource resource) throws Exception
{
MyEnumList myEnumList = getModel6Factory().createMyEnumList();
EList<MyEnum> myEnum = myEnumList.getMyEnum();
myEnum.hashCode();
resource.getContents().add(myEnumList);
myEnum.hashCode();
resource.save(Collections.emptyMap());
myEnum.hashCode();
}
}
|