Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 27d3f799647325c57c6bb28a06206ac3395949bb (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
/*
 * Copyright (c) 2018 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:
 *    Eike Stepper - 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.config.IRepositoryConfig;
import org.eclipse.emf.cdo.transaction.CDOTransaction;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * Bug 539332 - Repository can't initialize dynamic packages.
 *
 * @author Eike Stepper
 */
public class Bugzilla_539332_Test extends AbstractCDOTest
{
  @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
  public void testRestartWithDynamicPackage() throws Exception
  {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("res"));

    EClass eClass = createDynamicEClass();
    EObject eObject = EcoreUtil.create(eClass);

    resource.getContents().add(eObject);
    transaction.commit();

    restartRepository();
  }

  private EClass createDynamicEClass()
  {
    EPackage ePackage = createUniquePackage();

    EClass result = EcoreFactory.eINSTANCE.createEClass();
    result.setName("Dynamic");
    ePackage.getEClassifiers().add(result);
    return result;
  }
}

Back to the top