blob: cd669b952f63532eddb3d46b3fd03d8ce52340ba (
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
|
/*******************************************************************************
* Copyright (c) 2008 Oracle and Geensys.
* 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:
* Oracle and Geensys - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
import org.eclipse.emf.teneo.eclipselink.examples.library.Cover;
public class BookCoverTest extends LibraryJPATest {
public BookCoverTest(String name) {
super(name);
}
public void testInsertWriterAndCoverWithCache() throws Exception {
boolean checkCache = true;
verifyInsertWriterAddress(checkCache);
}
public void testInsertWriterAndCoverNoCache() throws Exception {
boolean checkCache = false;
verifyInsertWriterAddress(checkCache);
}
private void verifyInsertWriterAddress(boolean checkCache) {
beginTransaction();
Book book = createAnonymousBookWithCover(em);
String bookTitle = book.getTitle();
Cover cover = book.getCover();
// put the data to the data base
commitTransaction();
// verify
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
// Check whether the Book as been allocated at the data base.
Book dbBook = findBookWithTitle(em, bookTitle);
assertNotNull("Book not found", dbBook);
Cover dbCover = dbBook.getCover();
assertNotNull("dbCover not found", dbCover);
assertNotNull("eContainer not set", dbCover.eContainer());
int containerFeatureID = ((InternalEObject) cover).eContainerFeatureID();
int dbContainerFeatureID = ((InternalEObject) dbCover).eContainerFeatureID();
assertEquals("Containment Feature Id DB Cover", containerFeatureID, dbContainerFeatureID);
}
}
|