blob: 1bc30ae094da598db521dafaf5435c82a627d5ca (
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
68
69
70
71
72
73
74
75
76
|
/*
* Copyright (c) 2010-2013 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:
* Martin Fluegge - initial API and implementation
*/
package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
/**
* @author Martin Fluegge
*/
public class DynamicPackageTest extends AbstractCDOTest
{
public void testDynamicMaps() throws Exception
{
EPackage dynamicMapEPackge = createPackage();
EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
EObject mapContainer = dynamicMapEFactoryInstance.create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
resource.getContents().add(mapContainer);
transaction.commit();
if (!isConfig(LEGACY))
{
assertEquals(true, mapContainer instanceof DynamicCDOObjectImpl);
}
else
{
assertEquals(true, mapContainer instanceof DynamicEObjectImpl);
}
}
private EPackage createPackage()
{
EStructuralFeature name = EcoreFactory.eINSTANCE.createEAttribute();
name.setName("name");
name.setEType(EcorePackage.eINSTANCE.getEString());
EClass mapContainerEClass = EcoreFactory.eINSTANCE.createEClass();
mapContainerEClass.setName("MapContainer");
mapContainerEClass.getEStructuralFeatures().add(name);
EPackage dynamicMapEPackage = createUniquePackage();
dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
if (!isConfig(LEGACY))
{
CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
}
return dynamicMapEPackage;
}
}
|