Skip to main content
summaryrefslogtreecommitdiffstats
blob: f4190c7998eefd8b7943856d794c6e5ad3814671 (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
/*
 * Copyright (c) 2004 - 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:
 *    Eike Stepper - initial API and implementation
 *    Martin Fluegge - recreation of the test case
 */
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.tests.model1.Customer;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;

/**
 * @author Eike Stepper
 */
public class LegacyTest extends AbstractCDOTest
{
  public void testLegacyModeEnabled() throws Exception
  {
    Customer customer = getModel1Factory().createCustomer();
    customer.setName("Martin Fluegge");
    customer.setStreet("ABC Street 7");
    customer.setCity("Berlin");

    CDOSession session = openSession();
    CDOUtil.setLegacyModeDefault(false);
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    try
    {
      resource.getContents().add(customer);
      transaction.commit();

      if (isConfig(LEGACY))
      {
        fail("LegacyModeNotEnabledException expected");
      }
    }
    catch (LegacyModeNotEnabledException ex)
    {
      if (!isConfig(LEGACY))
      {
        fail("Native mode should not throw an exception here (" + ex.getMessage() + ")");
      }
    }
  }
}

Back to the top