blob: d53350b0f9a3e9a0c71a51e29adfffcb16a99cc3 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/***************************************************************************
* Copyright (c) 2004 - 2009 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
**************************************************************************/
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.Category;
import org.eclipse.emf.cdo.tests.model1.Product1;
import org.eclipse.emf.cdo.tests.model1.VAT;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
/**
* @author Eike Stepper
*/
public class EnumTest extends AbstractCDOTest
{
public void testTransient() throws Exception
{
{
Product1 product = getModel1Factory().createProduct1();
product.setName("Normal Product");
product.setVat(VAT.VAT7);
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(product);
transaction.commit();
session.close();
}
{
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource("/my/resource");
Product1 product = (Product1)resource.getContents().get(0);
assertEquals(VAT.VAT7, product.getVat());
product.setVat(VAT.VAT15);
transaction.commit();
session.close();
}
{
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource("/my/resource");
Product1 product = (Product1)resource.getContents().get(0);
assertEquals(VAT.VAT15, product.getVat());
session.close();
}
}
public void testAttached() throws Exception
{
{
Category category = getModel1Factory().createCategory();
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(category);
Product1 product = getModel1Factory().createProduct1();
product.setName("Normal Product");
product.setVat(VAT.VAT7);
category.getProducts().add(product);
transaction.commit();
session.close();
}
{
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource("/my/resource");
Category category = (Category)resource.getContents().get(0);
Product1 product = category.getProducts().get(0);
assertEquals(VAT.VAT7, product.getVat());
product.setVat(VAT.VAT15);
transaction.commit();
session.close();
}
{
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource("/my/resource");
Category category = (Category)resource.getContents().get(0);
Product1 product = category.getProducts().get(0);
assertEquals(VAT.VAT15, product.getVat());
session.close();
}
}
}
|