Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink')
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java95
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java51
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java34
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java61
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java74
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java51
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java70
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java65
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java65
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListTest.java178
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java171
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java107
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/GenerateORMTest.java34
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java121
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java79
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java77
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java72
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java72
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java85
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java236
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java113
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java48
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java38
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java170
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TestSuppressedJPATest.java65
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java66
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java62
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java71
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java78
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AbstractEclipseLinkTest.java59
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java28
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java111
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java250
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java140
-rwxr-xr-xeclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java91
35 files changed, 0 insertions, 3188 deletions
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java
deleted file mode 100755
index 4cd05f64e..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Publisher;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-/**
- * @author ebk2fe
- * @version 1.0 (April 28th, 2006)
- * <p>
- * This test case creates a publisher object and assignes two writers to the publisher. The objects are
- * committed to the data base. The publisher is fetched back from the data base.
- */
-public class AdHocTest extends LibraryJPATest {
-
- private Writer writer1;
- private String writer1Name;
- private Writer writer2;
- private String writer2Name;
- private Publisher publisher;
- private String publisherName;
-
- public AdHocTest(String name) {
- super(name);
- }
-
- public void testRemovePublisherWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyRemovePublisherWriter(checkCache);
- }
-
- // public void testRemovePublisherWriterNoCache() throws Exception {
- // boolean checkCache = false;
- // verifyRemovePublisherWriter(checkCache);
- // }
-
- private void verifyRemovePublisherWriter(boolean checkCache) {
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // dissassociate a writer from a publisher
- beginTransaction();
- Publisher dbPublisher = findPublisherWithName(em, publisherName);
- Writer dbWriter1 = findWriterWithName(em, writer1Name);
-
- dbPublisher.getWriters().remove(dbWriter1);
- dbWriter1.getPublishers().remove(dbPublisher);
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // verify dissassociation
- dbPublisher = findPublisherWithName(em, publisherName);
- dbWriter1 = findWriterWithName(em, writer1Name);
- Writer dbWriter2 = findWriterWithName(em, writer2Name);
-
- assertNotNull("publisher not found", dbPublisher);
- assertNotNull("writer1 not found", dbWriter1);
- assertNotNull("writer2 not found", dbWriter2);
- assertTrue("writer's publishers", dbWriter1.getPublishers().isEmpty());
- assertEquals("num publisher's writers", 1, dbPublisher.getWriters().size());
- assertEquals("publisher's writer", dbWriter2, dbPublisher.getWriters().get(0));
- }
-
- /**
- * The test fixture consists of a single publisher with two writers.
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- beginTransaction();
- publisher = createAnonymousPublisher(em);
- publisherName = publisher.getName();
- writer1 = createAnonymousWriter(em);
- writer1Name = writer1.getName();
- writer2 = createAnonymousWriter(em);
- writer2Name = writer2.getName();
- //
- publisher.getWriters().add(writer1);
- publisher.getWriters().add(writer2);
- commitTransaction();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java
deleted file mode 100755
index e61933449..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * 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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("ListTest for org.eclipse.emf.teneo.eclipselink.examples.library");
- // $JUnit-BEGIN$
- suite.addTestSuite(GenerateORMTest.class);
- suite.addTestSuite(EObjectTest.class);
- suite.addTestSuite(TypeWriterTypeTest.class);
- suite.addTestSuite(LibWriterEContainerTest.class);
- suite.addTestSuite(OneToOneTest.class);
- suite.addTestSuite(LibBookEContainerTest.class);
- suite.addTestSuite(WriterTypewriterTest.class);
- suite.addTestSuite(LibraryEnvironmentTest.class);
- suite.addTestSuite(ContainerTest.class);
- suite.addTestSuite(BookCoverTest.class);
- suite.addTestSuite(LibraryEContainerLibraryTest.class);
- // suite.addTestSuite(EMapTest.class);
- suite.addTestSuite(EListEMapTest.class);
- suite.addTestSuite(BasicTest.class);
- suite.addTestSuite(LibraryEContainerTest.class);
- suite.addTestSuite(BookTranslatorTest.class);
- suite.addTestSuite(LibraryXMIPersistenceTest.class);
- suite.addTestSuite(WriterAddressTest.class);
- suite.addTestSuite(EListTest.class);
- suite.addTestSuite(WriterPublisherTest.class);
- suite.addTestSuite(PublisherWriterTest.class);
- suite.addTestSuite(EContainerReferenceTest.class);
- suite.addTestSuite(BookStylesTest.class);
-
- suite.addTest(org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests.resource.AllTests.suite());
-
- // $JUnit-END$
- return suite;
- }
-
-} \ No newline at end of file
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java
deleted file mode 100755
index 3c597aa15..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.LibraryFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Style;
-
-public class BasicTest extends LibraryJPATest {
-
- public BasicTest(String name) {
- super(name);
- }
-
- public void testBasicMapping() throws Exception {
- Style style = LibraryFactory.eINSTANCE.createStyle();
- String expectedStyle = getAnonymousString();
- style.setName(expectedStyle);
- em.getTransaction().begin();
- em.persist(style);
- em.getTransaction().commit();
-
- Style actualStyle = (Style) em.createQuery("select s from Style s where s.name = :name").setParameter("name",
- expectedStyle).getSingleResult();
- assertEquals("name", expectedStyle, actualStyle.getName());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java
deleted file mode 100755
index cd669b952..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * 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);
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java
deleted file mode 100755
index 21c8e034c..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Style;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.BookStylesMapEntryImpl;
-
-public class BookStylesTest extends LibraryJPATest {
-
- public BookStylesTest(String name) {
- super(name);
- }
-
- public void testInsertBookWithStylesWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertBookStyles(checkCache);
- }
-
- public void testInsertBookWithStylesNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertBookStyles(checkCache);
- }
-
- private void verifyInsertBookStyles(boolean checkCache) {
-
- beginTransaction();
-
- Book book = createAnonymousBook(em);
- String bookTitle = book.getTitle();
- Style style1 = createAnonymousStyle(em);
- String style1Name = style1.getName();
- Style style2 = createAnonymousStyle(em);
- String style2Name = style2.getName();
- book.getStyles().put(style1Name, style1);
- book.getStyles().put(style2Name, style2);
- int eContFeatId = ((BookStylesMapEntryImpl) book.getStyles().get(0)).eContainerFeatureID();
-
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Book dbBook = findBookWithTitle(em, bookTitle);
- assertNotNull("dbBook not found", dbBook);
- assertEquals("dbBook nbr of styles", book.getStyles().size(), dbBook.getStyles().size());
-
- // check the containment setting for the BookStyleMapEntry
-
- BookStylesMapEntryImpl bookStyleMapEntry = (BookStylesMapEntryImpl) dbBook.getStyles().get(0);
- assertEquals("eContainer of the BookStylesMapEntryImpl", dbBook, bookStyleMapEntry.eContainer());
- assertEquals("eContainerFeatureId of the BookStylesMapEntryImpl", eContFeatId, ((BookStylesMapEntryImpl) dbBook
- .getStyles().get(0)).eContainerFeatureID());
-
- Style dbStyle1 = dbBook.getStyles().get(style1Name);
- Style dbStyle2 = dbBook.getStyles().get(style2Name);
-
- assertNotNull("First Style", dbStyle1);
- assertNotNull("Second Style", dbStyle2);
-
- // There is no containment relationshsip given for the Style objects
- assertNull("no containment of the style object", dbStyle1.eContainer());
- assertNull("no containment of the style object", dbStyle2.eContainer());
- }
-} \ No newline at end of file
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java
deleted file mode 100755
index 5a45bcadc..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Translator;
-
-public class BookTranslatorTest extends LibraryJPATest {
-
- public BookTranslatorTest(String name) {
- super(name);
- }
-
- public void testInsertBookWithTranslatorWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertBookTranslator(checkCache);
- }
-
- public void testInsertBookWithTranslatorNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertBookTranslator(checkCache);
- }
-
- private void verifyInsertBookTranslator(boolean checkCache) {
-
- beginTransaction();
- Book book = createAnonymousBookWithTranslator(em);
- String bookTitle = book.getTitle();
- Translator translator = book.getTranslator();
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Book dbBook = findBookWithTitle(em, bookTitle);
- assertNotNull("dbBook not found", dbBook);
- Translator dbTranslator = dbBook.getTranslator();
- assertNotNull("dbTranslator not found", dbTranslator);
- assertEquals("dbTranslator.location", translator.getLocation(), dbTranslator.getLocation());
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java
deleted file mode 100755
index 1d8aeb1e7..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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.common.util.EList;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.LibraryImpl;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.WriterImpl;
-
-public class ContainerTest extends LibraryJPATest {
-
- public ContainerTest(String name) {
- super(name);
- }
-
- public void testMoveBetweenContainersWithCache() throws Exception {
- boolean checkCache = true;
- verifyMoveBetweenContainers(checkCache);
- }
-
- public void testMoveBetweenContainersNoCache() throws Exception {
- boolean checkCache = false;
- verifyMoveBetweenContainers(checkCache);
- }
-
- private void verifyMoveBetweenContainers(boolean checkCache) {
- beginTransaction();
- WriterImpl writer = (WriterImpl) createAnonymousWriter(em);
- String writerName = writer.getName();
- LibraryImpl libraryOne = (LibraryImpl) createAnonymousLibrary(em);
- String libraryOneName = libraryOne.getName();
- libraryOne.getWriters().add(writer);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- writer = (WriterImpl) findWriterWithName(em, writerName);
- LibraryImpl libraryTwo = (LibraryImpl) createAnonymousLibrary(em);
- String libraryTwoName = libraryTwo.getName();
- libraryTwo.getWriters().add(writer);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Library dbLibraryOne = findLibraryWithName(em, libraryOneName);
- Library dbLibraryTwo = findLibraryWithName(em, libraryTwoName);
- Writer dbWriter = findWriterWithName(em, writerName);
- EList<Writer> dbLibOneWriters = dbLibraryOne.getWriters();
- EList<Writer> dbLibTwoWriters = dbLibraryTwo.getWriters();
- assertEquals("writer container", dbLibraryTwo, dbWriter.eContainer());
- assertEquals("new library number of books", 1, dbLibTwoWriters.size());
- assertTrue("original library has no books", dbLibOneWriters.isEmpty());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java
deleted file mode 100755
index 654b5fb21..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.EObject;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class EContainerReferenceTest extends LibraryJPATest {
-
- public EContainerReferenceTest(String name) {
- super(name);
- }
-
- public void testLibraryWriterRelationshipWithCache() throws Exception {
- boolean checkCache = true;
- verifyLibaryWriterRelationship(checkCache);
- }
-
- public void testLibraryWriterRelationshipNoCache() throws Exception {
- boolean checkCache = false;
- verifyLibaryWriterRelationship(checkCache);
- }
-
- /**
- * This test creates a Library with a contained Writer and determines whether the inverse eContainer relationship is
- * established from Writer to Library.
- *
- * @param checkCache
- * @throws Exception
- */
- private void verifyLibaryWriterRelationship(boolean checkCache) throws Exception {
- beginTransaction();
- Writer writer = createAnonymousWriter(em);
- String writerName = writer.getName();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getWriters().add(writer);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
- assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
- EObject actualWriterEContainer = actualWriter.eContainer();
- assertEquals("writer eContainer", actualLibrary, actualWriterEContainer);
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java
deleted file mode 100755
index 2262a60d8..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class EListEMapTest extends LibraryJPATest {
-
- public EListEMapTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndBooksAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- public void testInsertWriterAndBooksAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- private void verifyInsertWriterBookLibrary(boolean checkCache) {
- beginTransaction();
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- Book book = writer.getBooks().get(0);
- String bookTitle = book.getTitle();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getBooks().put(book.getTitle(), book);
- library.getWriters().add(writer);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- assertEquals("writer name", writerName, actualWriter.getName());
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- assertEquals("number of writer books", 1, actualWriter.getBooks().size());
- Book actualWriterBook = actualWriter.getBooks().get(0);
- assertEquals("book/writer book", actualBook, actualWriterBook);
- assertEquals("writer book", actualWriter.getBooks().get(0), actualBook);
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualLibraryBook = actualLibrary.getBooks().get(bookTitle);
- assertEquals("book/library book", actualBook, actualLibraryBook);
- Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
- assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListTest.java
deleted file mode 100755
index 89573c11b..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListTest.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * 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 java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-
-public class EListTest extends LibraryJPATest {
-
-
- public EListTest(String name) {
- super(name);
- }
-
-
- public void testInsertWriterAndBooksWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterBook(checkCache);
- }
-
- public void testInsertWriterAndBooksNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterBook(checkCache);
- }
-
- private void verifyInsertWriterBook(boolean checkCache) {
- beginTransaction();
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- Book book = writer.getBooks().get(0);
- String bookTitle = book.getTitle();
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- EList<Book> actualBooks = actualWriter.getBooks();
- assertEquals("number writer's books", 1, actualBooks.size());
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- assertEquals("writer book", actualBooks.get(0), actualBook);
- assertEquals("book author", actualWriter, actualBook.getAuthor());
- }
-
-
- public void testAddBookToWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyAddBookToWriter(checkCache);
- }
-
- public void testAddBookToWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyAddBookToWriter(checkCache);
- }
-
- private void verifyAddBookToWriter(boolean checkCache) {
- // setup fixture
- beginTransaction();
- Writer writer = createAnonymousWriter(em);
- Book firstBook = createAnonymousBookForWriter(em, writer);
- String writerName = writer.getName();
- commitTransaction();
-
- // exercise SUT
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- writer = findWriterWithName(em, writerName);
- Book secondBook = createAnonymousBookForWriter(em, writer);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- List<Book> actualBooks = actualWriter.getBooks();
- assertEquals("number of books",2, actualBooks.size());
- assertBookListContains(actualBooks, firstBook);
- assertBookListContains(actualBooks, secondBook);
- }
-
- public void testRemoveBookFromWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyRemoveBookFromWriter(checkCache);
- }
-
- public void testRemoveBookFromWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyRemoveBookFromWriter(checkCache);
- }
-
- private void verifyRemoveBookFromWriter(boolean checkCache) {
- beginTransaction();
- // fixture
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- commitTransaction();
- // exercise SUT
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- beginTransaction();
- writer = findWriterWithName(em, writerName);
- Book book = writer.getBooks().get(0);
- writer.getBooks().remove(book);
- em.remove(book);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- List<Book> actualBooks = actualWriter.getBooks();
- assertEquals("number of books", 0, actualBooks.size());
- }
-
-
- public void testInsertLibraryWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertLibraryWriter(checkCache);
- }
-
- public void testInsertLibraryWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertLibraryWriter(checkCache);
- }
-
- private void verifyInsertLibraryWriter(boolean checkCache) {
- beginTransaction();
- Library library = createAnonymousLibrary(em);
- Writer writer = createAnonymousWriter(em);
- String libraryName = library.getName();
- String writerName = writer.getName();
- library.getWriters().add(writer);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- Library actualLibrary = findLibraryWithName(em, libraryName);
- assertNotNull("library", actualLibrary);
- EList<Writer> actualLibraryWriters = actualLibrary.getWriters();
- assertEquals("library writers", 1, actualLibraryWriters.size());
- Writer actualLibraryWriter = actualLibraryWriters.get(0);
- assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
-
- EObject actualWriterEContainer = actualWriter.eContainer();
- assertEquals("library", actualLibrary, actualWriterEContainer);
- }
-
-
-
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java
deleted file mode 100755
index 978a045d8..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * 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 java.util.Map.Entry;
-
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class EMapTest extends LibraryJPATest {
-
- public EMapTest(String name) {
- super(name);
- }
-
- public void testInsertLibraryAndBooksWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertLibraryAndBooks(checkCache);
- }
-
- public void testInsertLibaryAndBooksNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertLibraryAndBooks(checkCache);
- }
-
- private void verifyInsertLibraryAndBooks(boolean checkCache) {
- beginTransaction();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- Book book = createAnonymousBook(em);
- String bookTitle = book.getTitle();
- library.getBooks().put(bookTitle, book);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Library actualLibrary = findLibraryWithName(em, libraryName);
- assertNotNull("library", actualLibrary);
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- EMap<String, Book> actualBooks = actualLibrary.getBooks();
- int numberActualBooks = actualBooks.size();
- assertEquals("number of book", 1, numberActualBooks);
- EObject actualLibraryBook = actualBooks.get(bookTitle);
- assertEquals("library book", actualBook, actualLibraryBook);
-
- EObject bookContainer = actualBook.eContainer();
- EObject libraryBookContainer = actualLibraryBook.eContainer();
- assertEquals("book container", bookContainer, libraryBookContainer);
-
- EObject bookEntryContainer = bookContainer.eContainer();
- EObject libraryBookEntryContainer = libraryBookContainer.eContainer();
- assertEquals("entry container", bookEntryContainer, libraryBookEntryContainer);
- assertEquals("entry container", actualLibrary, bookEntryContainer);
- assertEquals("entry container", actualLibrary, libraryBookEntryContainer);
- }
-
- public void testAddBookToLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyAddBookToLibrary(checkCache);
- }
-
- public void testAddBookToLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyAddBookToLibrary(checkCache);
- }
-
- private void verifyAddBookToLibrary(boolean checkCache) {
- beginTransaction();
- // setup fixture
- Library library = createAnonymousLibrary(em);
- Writer writer = createAnonymousWriter(em);
- Book bookOne = createAnonymousBookForWriter(em, writer);
- String bookOneTitle = bookOne.getTitle();
- library.getBooks().put(bookOneTitle, bookOne);
- library.getWriters().add(writer);
- String libraryName = library.getName();
- String writerName = writer.getName();
- commitTransaction();
- // exercise SUT
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- library = findLibraryWithName(em, libraryName);
- writer = findWriterWithName(em, writerName);
- Book bookTwo = createAnonymousBookForWriter(em, writer);
- String bookTwoTitle = bookTwo.getTitle();
- library.getBooks().put(bookTwoTitle, bookTwo);
- commitTransaction();
-
- // verify - cache
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualBookOne = findBookWithTitle(em, bookOneTitle);
- Book actualBookTwo = findBookWithTitle(em, bookTwoTitle);
- EMap<String, Book> libraryBooks = actualLibrary.getBooks();
- assertEquals("number of books", 2, libraryBooks.size());
- assertEquals("first library book", actualBookOne, libraryBooks.get(bookOneTitle));
- assertEquals("second library book", actualBookTwo, libraryBooks.get(bookTwoTitle));
- }
-
- public void testRemoveBookFromLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyRemoveBookFromLibrary(checkCache);
- }
-
- public void testRemoveBookFromLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyRemoveBookFromLibrary(checkCache);
- }
-
- private void verifyRemoveBookFromLibrary(boolean checkCache) {
- beginTransaction();
- // fixture
- Writer writer = createAnonymousWriter(em);
- Book bookOne = createAnonymousBookForWriter(em, writer);
- Book bookTwo = createAnonymousBookForWriter(em, writer);
- Library library = createAnonymousLibrary(em);
- library.getBooks().put(bookOne.getTitle(), bookOne);
- library.getBooks().put(bookTwo.getTitle(), bookTwo);
- String libraryName = library.getName();
- String bookOneTitle = bookOne.getTitle();
- String bookTwoTitle = bookTwo.getTitle();
- commitTransaction();
- // exercise SUT
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- beginTransaction();
- library = findLibraryWithName(em, libraryName);
- bookTwo = findBookWithTitle(em, bookTwoTitle);
- Book bookTwoFromLibrary = library.getBooks().removeKey(bookTwoTitle);
- assertEquals(bookTwo, bookTwoFromLibrary);
- // TODO: ResourceImpl will get callback to delete MapEntry
- EObject bookTwoEContainer = bookTwo.eContainer();
- if ((bookTwoEContainer != null) && (bookTwoEContainer instanceof Entry<?, ?>)) {
- em.remove(bookTwoEContainer);
- }
- em.remove(bookTwo);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualBookOne = findBookWithTitle(em, bookOneTitle);
- EMap<String, Book> actualBooks = actualLibrary.getBooks();
- assertEquals("number of books", 1, actualBooks.size());
- Book actualLibraryBook = actualBooks.get(bookOneTitle);
- assertEquals("book in library", actualBookOne, actualLibraryBook);
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java
deleted file mode 100755
index 16e2cc421..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.BookCategory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class EObjectTest extends LibraryJPATest {
-
- public EObjectTest(String name) {
- super(name);
- }
-
- public void testInsertWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriter(checkCache);
- }
-
- public void testInsertWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriter(checkCache);
- }
-
- private void verifyInsertWriter(boolean checkCache) {
- beginTransaction();
- Writer writer = createAnonymousWriter(em);
- String writerName = writer.getName();
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- rollbackTransaction();
- }
-
- public void testInsertBookWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertBook(checkCache);
- }
-
- public void testInsertBookNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertBook(checkCache);
- }
-
- private void verifyInsertBook(boolean checkCache) {
- beginTransaction();
- Book book = createAnonymousBook(em);
- String title = book.getTitle();
- BookCategory category = book.getCategory();
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- Book actualBook = findBookWithTitle(em, title);
- assertNotNull("book", actualBook);
- assertEquals("category", category, actualBook.getCategory());
- rollbackTransaction();
- }
-
- public void testInsertLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertLibrary(checkCache);
- }
-
- public void testInsertLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertLibrary(checkCache);
- }
-
- private void verifyInsertLibrary(boolean checkCache) {
- beginTransaction();
- Library library = createAnonymousLibrary(em);
- String name = library.getName();
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- beginTransaction();
- Library actualLibrary = findLibraryWithName(em, name);
- assertNotNull("library", actualLibrary);
- rollbackTransaction();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/GenerateORMTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/GenerateORMTest.java
deleted file mode 100755
index 06707c32f..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/GenerateORMTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Springsite (The Netherlands).
- * 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 Taal - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.suppressinterfaces.SuppressinterfacesPackage;
-import org.eclipse.emf.teneo.jpa.convert.ORMGenerator;
-
-/**
- * @author mtaal
- */
-public class GenerateORMTest extends TestCase {
-
- public void testGenerateORMLibrary() {
- final ORMGenerator ormGenerator = new ORMGenerator();
- System.err.println(ormGenerator.generateORM(new EPackage[] { LibraryPackage.eINSTANCE }));
- }
-
- public void testGenerateORMSuppressedInterfaces() {
- final ORMGenerator ormGenerator = new ORMGenerator();
- System.err.println(ormGenerator.generateORM(new EPackage[] { SuppressinterfacesPackage.eINSTANCE }));
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java
deleted file mode 100755
index e7e9e5b61..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * 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 java.util.Calendar;
-import java.util.HashMap;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.eclipse.persistence.config.PersistenceUnitProperties;
-import org.eclipse.persistence.jpa.osgi.PersistenceProvider;
-import org.eclipse.persistence.sessions.Session;
-import org.eclipse.persistence.sessions.factories.SessionManager;
-
-public abstract class JPATest extends ManagedTest {
- private static EntityManagerFactory factory;
-
- protected EntityManager em;
-
- public JPATest(String name) {
- super(name);
- }
-
- public EntityManagerFactory getEntityManagerFactory() {
- if (factory == null) {
- HashMap<String, Object> properties = new HashMap<String, Object>();
- ClassLoader classLoader = this.getClass().getClassLoader();
- properties.put(PersistenceUnitProperties.CLASSLOADER, classLoader);
- factory = new PersistenceProvider().createEntityManagerFactory(getPersistenceUnitName(), properties);
- }
- return factory;
- }
-
- protected String getPersistenceUnitName() {
- return "default";
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- em = getEntityManagerFactory().createEntityManager();
- cleanDatabase();
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (em != null) {
- try {
- em.close();
- } catch (RuntimeException e) {
- System.out.println("Exception closing EntityManager: " + e.getMessage());
- e.printStackTrace();
- // not supposed to fail in tearDown
- } finally {
- }
- }
- super.tearDown();
- }
-
- protected static long nextTitleInt = Calendar.getInstance().getTimeInMillis();
-
- /**
- * Subclasses should define to return all objects that should be deleted before a test is run.
- *
- * @param uow
- */
- protected abstract void cleanDatabase(EntityManager em);
-
- /**
- * Utility method used to generate Strings for "don't care" attribute values of test objects: DON'T HARD WIRE VALUES
- * IN TESTS
- *
- * @return String
- */
- protected String getAnonymousString() {
- return String.valueOf(nextTitleInt++);
- }
-
- /**
- * Called when all the tests in the current suite are have been run.
- */
- @Override
- protected void allTestsComplete() {
- factory.close();
- }
-
- protected void cleanDatabase() {
- em.getTransaction().begin();
- cleanDatabase(em);
- em.getTransaction().commit();
- }
-
- protected void beginTransaction() {
- em.getTransaction().begin();
- }
-
- protected void commitTransaction() {
- em.getTransaction().commit();
- }
-
- protected void rollbackTransaction() {
- em.getTransaction().rollback();
- }
-
- protected void reinitializeCachesAndEntityManager() {
- Session session = SessionManager.getManager().getSession(getPersistenceUnitName());
- session.getIdentityMapAccessor().initializeAllIdentityMaps();
- em.close();
- em = getEntityManagerFactory().createEntityManager();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java
deleted file mode 100755
index eb991a27c..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * 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.Library;
-
-public class LibBookEContainerTest extends LibraryJPATest {
-
- public LibBookEContainerTest(String name) {
- super(name);
- }
-
- public void testInsertBookAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertBookLibrary(checkCache);
- }
-
- public void testInsertBookAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertBookLibrary(checkCache);
- }
-
- /**
- * Create the library and a book within the library.<br>
- * Store the library to the data base.<br>
- * Fetch back the library from the data base.<br>
- * Identify the book object assigned to libray.<br>
- * Check whether the attribute eContainer is set at the book object.
- *
- * @param checkCache
- */
- private void verifyInsertBookLibrary(boolean checkCache) {
-
- beginTransaction();
- Book book = createAnonymousBook(em);
- String bookTitle = book.getTitle();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getBooks().put(book.getTitle(), book);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- // Check whether the book as been allocated at the data base.
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- assertNotNull("Field Actual/Book.eContainer not set", actualBook.eContainer());
- int containerFeatureID = ((InternalEObject) book).eContainerFeatureID();
- int actualContainerFeatureID = ((InternalEObject) actualBook).eContainerFeatureID();
- assertEquals("Containment Feature Id DB Book", containerFeatureID, actualContainerFeatureID);
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- assertNotNull("library missing", actualLibrary);
-
- Book actualLibraryBook = actualLibrary.getBooks().get(bookTitle);
- assertNotNull("book missing", actualLibraryBook);
- assertEquals("book title", bookTitle, actualLibraryBook.getTitle());
- assertEquals("Book Check", actualBook, actualLibraryBook);
-
- // verify whether the field eContainer is set
- assertNotNull("Field Library/Book.eContainer not set", actualLibraryBook.eContainer());
- assertEquals("Containment Relationship", actualLibrary, actualLibraryBook.eContainer().eContainer());
-
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java
deleted file mode 100755
index f41d17810..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class LibWriterEContainerTest extends LibraryJPATest {
-
- public LibWriterEContainerTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterLibrary(checkCache);
- }
-
- public void testInsertWriterAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterLibrary(checkCache);
- }
-
- /**
- * Create the library and a writer within the library.<br>
- * Store the library to the data base.<br>
- * Fetch back the library from the data base.<br>
- * Identify the writer object assigned to libray.<br>
- * Check whether the attribute eContainer is set at the writer object.
- *
- * @param checkCache
- */
- private void verifyInsertWriterLibrary(boolean checkCache) {
-
- beginTransaction();
-
- Writer writer = createAnonymousWriter(em);
- String writerName = writer.getName();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getWriters().add(writer);
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- assertEquals("writer name", writerName, actualWriter.getName());
- assertNotNull("Field Actual/Writer.eContainer not set", actualWriter.eContainer());
- int containerFeatureID = ((InternalEObject) writer).eContainerFeatureID();
- int actualContainerFeatureID = ((InternalEObject) actualWriter).eContainerFeatureID();
- assertEquals("Containment Feature Id DB Writer", containerFeatureID, actualContainerFeatureID);
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- assertNotNull("library missing", actualLibrary);
-
- Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
- assertNotNull("writer missing", actualLibraryWriter);
- assertEquals("writer name", writerName, actualLibraryWriter.getName());
- assertEquals("Writer Check", actualWriter, actualLibraryWriter);
-
- // verify whether the field eContainer is set
- assertNotNull("Field Library/Writer.eContainer not set", actualLibraryWriter.eContainer());
- assertEquals("Containment Relationship", actualLibrary, actualLibraryWriter.eContainer());
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java
deleted file mode 100755
index 8820b6fb3..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class LibraryEContainerLibraryTest extends LibraryJPATest {
-
- public LibraryEContainerLibraryTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndBooksAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- public void testInsertWriterAndBooksAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- /**
- * Create a library object model holding a library, writer and book object. Fetches back the library object from the
- * data base. Check whether the containment relationship is correctly set up at the field eContainer of the book and
- * writer objects.
- *
- * @param checkCache
- */
- private void verifyInsertWriterBookLibrary(boolean checkCache) {
-
- beginTransaction();
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- Book book = writer.getBooks().get(0);
- String bookTitle = book.getTitle();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getBooks().put(book.getTitle(), book);
- library.getWriters().add(writer);
-
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualLibraryBook = actualLibrary.getBooks().get(bookTitle);
- assertNotNull("book missing", actualLibraryBook);
-
- Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
- assertNotNull("writer missing", actualLibraryWriter);
- assertEquals("writer name", writerName, actualLibraryWriter.getName());
-
- // verify whether the field eContainer is set
- assertNotNull("Field Library/Book.eContainer not set", actualLibraryBook.eContainer());
- assertNotNull("Field Library/Writer.eContainer not set", actualLibraryWriter.eContainer());
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java
deleted file mode 100755
index 0ed327955..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class LibraryEContainerTest extends LibraryJPATest {
-
- public LibraryEContainerTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndBooksAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- public void testInsertWriterAndBooksAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- /**
- * The test case creates a library object model holding a library, writer and book object. The writer and book
- * objects are directly fetched back from the data base. Check whether the containment relationship is correctly set
- * up at the field eContainer of the book and writer objects.
- *
- * @param checkCache
- */
- private void verifyInsertWriterBookLibrary(boolean checkCache) {
-
- beginTransaction();
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- Book book = writer.getBooks().get(0);
- String bookTitle = book.getTitle();
- Library library = createAnonymousLibrary(em);
- library.getBooks().put(book.getTitle(), book);
- library.getWriters().add(writer);
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- assertEquals("writer name", writerName, actualWriter.getName());
-
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- assertEquals("number of writer books", 1, actualWriter.getBooks().size());
- Book actualWriterBook = actualWriter.getBooks().get(0);
- assertEquals("book/writer book", actualBook, actualWriterBook);
- assertEquals("writer book", actualWriter.getBooks().get(0), actualBook);
-
- // verify whether the field eContainer is set
- assertNotNull("Field Actual/Writer.eContainer not set", actualWriter.eContainer());
- assertNotNull("Field Actual/Book.eContainer not set", actualBook.eContainer());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java
deleted file mode 100755
index a2cfc84b5..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Address;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Publisher;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Style;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Translator;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class LibraryEnvironmentTest extends LibraryJPATest {
-
- public LibraryEnvironmentTest(String name) {
-
- super(name);
- }
-
- public void testLibraryEnvironmentWithCache() throws Exception {
-
- boolean checkCache = true;
- verifyLibraryEnvironment(checkCache);
- }
-
- public void testLibraryEnvironmentNoCache() throws Exception {
-
- boolean checkCache = false;
- verifyLibraryEnvironment(checkCache);
- }
-
- private void verifyLibraryEnvironment(boolean checkCache) {
-
- beginTransaction();
-
- // Create the Test Environment
-
- Library library = setupLibraryEnvironment(em);
-
- String libraryName = library.getName();
-
- // put the data to the data base
-
- commitTransaction();
-
- // set the cache usage
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- // fetch back the library
-
- Library dbLibrary = findLibraryWithName(em, libraryName);
-
- // verify
-
- assertNotNull("dbLibray not found", dbLibrary);
- assertEquals("dbLibrary.name", libraryName, dbLibrary.getName());
-
- Book dbBook = (Book) dbLibrary.getBooks().values().toArray()[0];
- Writer dbWriter = dbLibrary.getWriters().get(0);
-
- assertNotNull("dbBook not found", dbBook);
- assertNotNull("dbWriter not found", dbWriter);
-
- Translator dbTranslator = dbBook.getTranslator();
- Address dbAddress = dbWriter.getAddress();
- Publisher dbPublisher = dbWriter.getPublishers().get(0);
- Style dbStyle = (Style) dbBook.getStyles().values().toArray()[0];
-
- assertNotNull("dbTranslator not found", dbTranslator);
- assertNotNull("dbAddress not found", dbAddress);
- assertNotNull("dbPublisher not found", dbPublisher);
- assertNotNull("dbStyle not found", dbStyle);
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java
deleted file mode 100755
index 249472d4e..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * 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 java.util.List;
-
-import javax.persistence.EntityManager;
-
-import junit.framework.AssertionFailedError;
-
-import org.eclipse.emf.teneo.eclipselink.examples.library.Address;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.BookCategory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Cover;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Publisher;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Style;
-import org.eclipse.emf.teneo.eclipselink.examples.library.TWriterType;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Translator;
-import org.eclipse.emf.teneo.eclipselink.examples.library.TypeWriter;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.LibraryFactoryImpl;
-
-public abstract class LibraryJPATest extends JPATest {
-
- public LibraryJPATest(String name) {
- super(name);
- }
-
- @Override
- protected String getPersistenceUnitName() {
- return "library";
- }
-
- @Override
- protected void cleanDatabase(EntityManager em) {
- // delete does not cascade so order is important
- em.createQuery("delete from Publisher o").executeUpdate();
- em.createQuery("delete from StringToBookMapEntry o").executeUpdate();
- em.createQuery("delete from BookStylesMapEntry o").executeUpdate();
- em.createQuery("delete from Cover o").executeUpdate();
- em.createQuery("delete from Book o").executeUpdate();
- em.createQuery("delete from Translator o").executeUpdate();
- em.createQuery("delete from Writer o").executeUpdate();
- em.createQuery("delete from TypeWriter o").executeUpdate();
- em.createQuery("delete from Address o").executeUpdate();
- em.createQuery("delete from Library o").executeUpdate();
- em.createQuery("delete from Style o").executeUpdate();
- }
-
- protected static final LibraryFactory factory = LibraryFactoryImpl.eINSTANCE;
-
- protected static void assertBookListContains(List<Book> books, Book firstBook) {
- for (Book each : books) {
- try {
- assertBooksEqual(each, firstBook);
- return; // found
- } catch (AssertionFailedError e) {
- }
- }
- }
-
- protected static void assertBooksEqual(Book expectedBook, Book actualBook) {
- assertEquals("author", expectedBook.getAuthor(), actualBook.getAuthor());
- assertEquals("title", expectedBook.getTitle(), actualBook.getTitle());
- assertEquals("category", expectedBook.getCategory(), actualBook.getCategory());
- assertEquals("pages", expectedBook.getPages(), actualBook.getPages());
- }
-
- protected Book createAnonymousBookForWriter(EntityManager em, Writer writer) {
- Book book = createAnonymousBook(em);
- book.setAuthor(writer);
- writer.getBooks().add(book);
- return book;
- }
-
- protected Book createAnonymousBook(EntityManager em) {
- Book book = factory.createBook();
- em.persist(book);
- book.setCategory(BookCategory.BIOGRAPHY);
- book.setPages(100);
- book.setTitle(getAnonymousString());
- return book;
- }
-
- protected Book createAnonymousBookWithCover(EntityManager em) {
- Book book = createAnonymousBook(em);
- Cover cover = factory.createCover();
- cover.setColored(true);
- book.setCover(cover);
- return book;
- }
-
- protected Writer createAnonymousWriter(EntityManager em) {
- Writer writer = factory.createWriter();
-
- em.persist(writer);
- writer.setName(getAnonymousString());
- return writer;
- }
-
- protected Library createAnonymousLibrary(EntityManager em) {
- Library library = factory.createLibrary();
- em.persist(library);
- library.setName(getAnonymousString());
- return library;
- }
-
- protected Writer createAnonymousWriterWithOneBook(EntityManager em) {
- Writer writer = createAnonymousWriter(em);
- createAnonymousBookForWriter(em, writer);
- return writer;
- }
-
- protected Writer createAnonymousWriterWithAddress(EntityManager em) {
- Writer writer = createAnonymousWriter(em);
- createAnonymousAddressForWriter(em, writer);
- return writer;
- }
-
- protected Address createAnonymousAddressForWriter(EntityManager em, Writer writer) {
- Address address = factory.createAddress();
- address.setTown(getAnonymousString());
- em.persist(address);
- writer.setAddress(address);
- return address;
- }
-
- protected Publisher createAnonymousPublisher(EntityManager em) {
- Publisher publisher = factory.createPublisher();
- publisher.setName(getAnonymousString());
- em.persist(publisher);
- return publisher;
- }
-
- protected Book createAnonymousBookWithTranslator(EntityManager em) {
- Book book = createAnonymousBook(em);
- book.setTranslator(createAnonymousTranslator(em));
- return book;
- }
-
- protected Translator createAnonymousTranslator(EntityManager em) {
- Translator translator = factory.createTranslator();
- translator.setName(getAnonymousString());
- translator.setLocation("Stuttgart");
- em.persist(translator);
- return translator;
- }
-
- protected Book createAnonymousBookWithStyles(EntityManager em) {
- Book book = createAnonymousBook(em);
- Style style1 = createAnonymousStyle(em);
- Style style2 = createAnonymousStyle(em);
- book.getStyles().put(style1.getName(), style1);
- book.getStyles().put(style2.getName(), style2);
- return book;
- }
-
- protected Style createAnonymousStyle(EntityManager em) {
- Style style = factory.createStyle();
- style.setName(getAnonymousString());
- em.persist(style);
- return style;
- }
-
- protected TypeWriter createAnonymousTypewriter(EntityManager em) {
- TypeWriter twriter = factory.createTypeWriter();
- twriter.setMaker(getAnonymousString());
- twriter.setType(TWriterType.COMPUTER);
- em.persist(twriter);
- return twriter;
- }
-
- protected Writer createAnonymousWriterWithTypeWriter(EntityManager em) {
- Writer writer = createAnonymousWriter(em);
- TypeWriter twriter = createAnonymousTypewriter(em);
- writer.getTypewriters().add(twriter);
- return writer;
- }
-
- protected Library setupLibraryEnvironment(EntityManager em) {
-
- Library library = createAnonymousLibrary(em);
-
- Book book = createAnonymousBookWithStyles(em);
- library.getBooks().put(book.getTitle(), book);
-
- Translator translator = createAnonymousTranslator(em);
- book.setTranslator(translator);
-
- Writer writer = createAnonymousWriterWithAddress(em);
- library.getWriters().add(writer);
-
- Publisher publisher = createAnonymousPublisher(em);
- writer.getPublishers().add(publisher);
- publisher.getWriters().add(writer);
-
- return library;
- }
-
- protected Writer findWriterWithName(EntityManager em, String name) {
- return (Writer) em.createQuery("select o from Writer o where o.name = :name").setParameter("name", name)
- .getSingleResult();
- }
-
- protected Book findBookWithTitle(EntityManager em, String title) {
- return (Book) em.createQuery("select o from Book o where o.title = :title").setParameter("title", title)
- .getSingleResult();
- }
-
- protected Library findLibraryWithName(EntityManager em, String name) {
- return (Library) em.createQuery("select o from Library o where o.name = :name").setParameter("name", name)
- .getSingleResult();
- }
-
- protected Publisher findPublisherWithName(EntityManager em, String name) {
- return (Publisher) em.createQuery("select o from Publisher o where o.name = :name").setParameter("name", name)
- .getSingleResult();
- }
-
- protected TypeWriter findTypeWriterWithMaker(EntityManager em, String maker) {
-
- return (TypeWriter) em.createQuery("select o from TypeWriter o where o.maker = :maker").setParameter("maker",
- maker).getSingleResult();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java
deleted file mode 100755
index 9b50dae40..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * 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 java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class LibraryXMIPersistenceTest extends LibraryJPATest {
-
- public LibraryXMIPersistenceTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndBooksAndLibraryWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- public void testInsertWriterAndBooksAndLibraryNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterBookLibrary(checkCache);
- }
-
- /**
- * The test case creates a library object model holding a library, writer and book object. It generates a XMI file
- * using the build in persistency API of EMF. The first XMI file is generated directly after creation of the library
- * object model. A second XMI file is created based on the library object model which is read back from the data
- * base. Both files shall be identical.
- *
- * @param checkCache
- */
- private void verifyInsertWriterBookLibrary(boolean checkCache) throws Exception {
- beginTransaction();
- Writer writer = createAnonymousWriterWithOneBook(em);
- String writerName = writer.getName();
- Book book = writer.getBooks().get(0);
- String bookTitle = book.getTitle();
- Library library = createAnonymousLibrary(em);
- String libraryName = library.getName();
- library.getBooks().put(book.getTitle(), book);
- library.getWriters().add(writer);
-
- File tempFile = File.createTempFile("temp", "library.xmi");
- saveToXMIFile(library, tempFile);
-
- commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer actualWriter = findWriterWithName(em, writerName);
- assertNotNull("writer", actualWriter);
- assertEquals("writer name", writerName, actualWriter.getName());
-
- Book actualBook = findBookWithTitle(em, bookTitle);
- assertNotNull("book", actualBook);
- assertEquals("number of writer books", 1, actualWriter.getBooks().size());
- Book actualWriterBook = actualWriter.getBooks().get(0);
- assertEquals("book/writer book", actualBook, actualWriterBook);
- assertEquals("writer book", actualWriter.getBooks().get(0), actualBook);
-
- Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualLibraryBook = actualLibrary.getBooks().get(bookTitle);
- assertEquals("book/library book", actualBook, actualLibraryBook);
- Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
- assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
-
- // Start the writing to XMI
-
- saveToXMIFile(actualLibrary, tempFile);
-
- }
-
- /**
- * The private method saveToXMIFile allocates a resource set and stores the contents of the library object model to
- * a XMI file.
- *
- * @param library
- * The root object of the library object model
- * @param fileURI
- * The name of the file "file://C:/<file name>"
- * @throws IOException
- */
- private void saveToXMIFile(Library library, File aFile) throws IOException {
- new ResourceSetImpl();
- URI resURI = URI.createFileURI(aFile.getAbsolutePath());
- XMIResource xmiResource = new XMIResourceImpl(resURI);
-
- xmiResource.getContents().add(library);
-
- FileWriter fw = new FileWriter(aFile);
- xmiResource.save(fw, Collections.EMPTY_MAP);
- fw.close();
- }
-} \ No newline at end of file
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java
deleted file mode 100755
index 37e0d0d8f..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public abstract class ManagedTest extends TestCase {
- private static List<ManagedTest> runningTests = new ArrayList<ManagedTest>();
-
- public ManagedTest(String sTestName) {
- super(sTestName);
- registerTest();
- }
-
- private void registerTest() {
- runningTests.add(this);
- }
-
- private void unregisterTest() {
- runningTests.remove(this);
- if (runningTests.isEmpty()) {
- allTestsComplete();
- }
- }
-
- /**
- * Called when all the tests in the current suite are have been run.
- */
- protected abstract void allTestsComplete();
-
- @Override
- protected void tearDown() throws Exception {
- unregisterTest();
- super.tearDown();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java
deleted file mode 100755
index 461fc1d01..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Address;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class OneToOneTest extends LibraryJPATest {
-
- public OneToOneTest(String name) {
- super(name);
- }
-
- public void testWriteRead() throws Exception {
- em.getTransaction().begin();
- Writer writer = createAnonymousWriter(em);
- String writerName = writer.getName();
- Address address = createAnonymousAddressForWriter(em, writer);
- String addressTown = address.getTown();
- writer.setAddress(address);
- em.getTransaction().commit();
-
- Writer actualWriter = (Writer) em.createQuery("select o from Writer o where o.name = :name").setParameter(
- "name", writerName).getSingleResult();
- Address actualAddress = (Address) em.createQuery("select o from Address o where o.town = :town").setParameter(
- "town", addressTown).getSingleResult();
-
- assertEquals("writer address", actualWriter.getAddress(), actualAddress);
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java
deleted file mode 100755
index 474817284..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Publisher;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-/**
- * @author ebk2fe
- * @version 1.0 (April 28th, 2006)
- * <p>
- * This test case creates a publisher object and assignes two writers to the publisher. The objects are
- * committed to the data base. The publisher is fetched back from the data base.
- */
-public class PublisherWriterTest extends LibraryJPATest {
-
- private Writer writer1;
- private String writer1Name;
- private Writer writer2;
- private String writer2Name;
- private Publisher publisher;
- private String publisherName;
-
- public PublisherWriterTest(String name) {
- super(name);
- }
-
- public void testInsertPublisherWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertPublisherWriter(checkCache);
- }
-
- public void testInsertPublisherWriterNoCache() throws Exception {
- boolean checkCache = true;
- verifyInsertPublisherWriter(checkCache);
- }
-
- public void testRemovePublisherWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyRemovePublisherWriter(checkCache);
- }
-
- public void testRemovePublisherWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyRemovePublisherWriter(checkCache);
- }
-
- public void testMovePublisherWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyMovePublisherWriter(checkCache);
- }
-
- public void testMovePublisherWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyMovePublisherWriter(checkCache);
- }
-
- private void verifyMovePublisherWriter(boolean checkCache) {
-
- // move a writer to a new publisher
- beginTransaction();
- Publisher publisher2 = createAnonymousPublisher(em);
- String publisher2Name = publisher2.getName();
-
- Publisher dbPublisher1 = findPublisherWithName(em, publisherName);
- Writer dbWriter2 = findWriterWithName(em, writer2Name);
-
- dbPublisher1.getWriters().remove(dbWriter2);
- dbWriter2.getPublishers().remove(dbPublisher1);
- dbWriter2.getPublishers().add(publisher2);
- publisher2.getWriters().add(dbWriter2);
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- // verify dissassociation
- dbPublisher1 = findPublisherWithName(em, publisherName);
- Publisher dbPublisher2 = findPublisherWithName(em, publisher2Name);
- Writer dbWriter1 = findWriterWithName(em, writer1Name);
- dbWriter2 = findWriterWithName(em, writer2Name);
-
- assertNotNull("publisher1", dbPublisher1);
- assertNotNull("publisher2", dbPublisher2);
- assertNotNull("writer1", dbWriter1);
- assertNotNull("writer2", dbWriter2);
- assertEquals("writer1's publishers", 1, dbWriter1.getPublishers().size());
- assertEquals("writer2's publishers", 1, dbWriter2.getPublishers().size());
- assertEquals("publisher1's writers", 1, dbPublisher1.getWriters().size());
- assertEquals("publisher2's writers", 1, dbPublisher2.getWriters().size());
- assertEquals("publisher1's writer", dbWriter1, dbPublisher1.getWriters().get(0));
- assertEquals("publisher2's writer", dbWriter2, dbPublisher2.getWriters().get(0));
- assertEquals("writer1's publisher", dbPublisher1, dbWriter1.getPublishers().get(0));
- assertEquals("writer2's publisher", dbPublisher2, dbWriter2.getPublishers().get(0));
- }
-
- private void verifyRemovePublisherWriter(boolean checkCache) {
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // dissassociate a writer from a publisher
- beginTransaction();
- Publisher dbPublisher = findPublisherWithName(em, publisherName);
- Writer dbWriter1 = findWriterWithName(em, writer1Name);
-
- dbPublisher.getWriters().remove(dbWriter1);
- dbWriter1.getPublishers().remove(dbPublisher);
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // verify dissassociation
- dbPublisher = findPublisherWithName(em, publisherName);
- dbWriter1 = findWriterWithName(em, writer1Name);
- Writer dbWriter2 = findWriterWithName(em, writer2Name);
-
- assertNotNull("publisher not found", dbPublisher);
- assertNotNull("writer1 not found", dbWriter1);
- assertNotNull("writer2 not found", dbWriter2);
- assertTrue("writer's publishers", dbWriter1.getPublishers().isEmpty());
- assertEquals("num publisher's writers", 1, dbPublisher.getWriters().size());
- assertEquals("publisher's writer", dbWriter2, dbPublisher.getWriters().get(0));
- }
-
- private void verifyInsertPublisherWriter(boolean checkCache) {
- // the fixture setUp does the insert, now verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Publisher dbPublisher = findPublisherWithName(em, publisherName);
-
- assertNotNull("publisher not found", dbPublisher);
- assertEquals("publisher's writers", 2, dbPublisher.getWriters().size());
-
- Writer dbWriter = dbPublisher.getWriters().get(0);
- assertNotNull("writer not found", dbWriter);
- assertEquals("writer's publisher", dbPublisher, dbWriter.getPublishers().get(0));
- }
-
- /**
- * The test fixture consists of a single publisher with two writers.
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- beginTransaction();
- publisher = createAnonymousPublisher(em);
- publisherName = publisher.getName();
- writer1 = createAnonymousWriter(em);
- writer1Name = writer1.getName();
- writer2 = createAnonymousWriter(em);
- writer2Name = writer2.getName();
- //
- publisher.getWriters().add(writer1);
- publisher.getWriters().add(writer2);
- commitTransaction();
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TestSuppressedJPATest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TestSuppressedJPATest.java
deleted file mode 100755
index dd897d7bb..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TestSuppressedJPATest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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 java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.eclipse.emf.teneo.eclipselink.examples.suppressinterfaces.SuppressinterfacesFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.suppressinterfaces.Test;
-import org.eclipse.emf.teneo.eclipselink.examples.suppressinterfaces.TestEmbedded;
-
-public class TestSuppressedJPATest extends JPATest {
-
- public TestSuppressedJPATest() {
- super("Suppressed Interface Test");
- }
-
- @Override
- protected String getPersistenceUnitName() {
- return "library";
- }
-
- @Override
- protected void cleanDatabase(EntityManager em) {
- // delete does not cascade so order is important
- // em.createQuery("delete from Identifiable o").executeUpdate();
- }
-
- protected static final SuppressinterfacesFactory factory = SuppressinterfacesFactory.eINSTANCE;
-
- public void testPersistence() throws Exception {
-
- beginTransaction();
- createTest();
- commitTransaction();
-
- beginTransaction();
- final List<?> list = em.createQuery("select e from Identifiable e").getResultList();
- assertEquals(1, list.size());
- final Test test = (Test) list.get(0);
-
- assertTrue(test.getTestEmbedded() != null);
- assertEquals("name", test.getTestEmbedded().getNameEmbedded());
- commitTransaction();
- }
-
- protected Test createTest() {
- Test test = factory.createTest();
- test.setName("test");
- TestEmbedded testEmbedded = factory.createTestEmbedded();
- testEmbedded.setNameEmbedded("name");
- test.setTestEmbedded(testEmbedded);
- em.persist(test);
- return test;
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java
deleted file mode 100755
index af9d2b4b7..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.TWriterType;
-import org.eclipse.emf.teneo.eclipselink.examples.library.TypeWriter;
-
-/**
- * @author ebk2fe
- * @version 1.0 (April 28th, 2006)
- * <p>
- * This test case create a typewriter object which holds at the attribute type an EMF enumeration type. To
- * store the attribute EMF enumeration value at the data base the transformation mapping is used. Two java
- * classes have been implemented: <code>TypewriterTypeAttributeTransformer</code> and
- * <code>TypewriterTypeFieldTransformer</code>.<br>
- * The correct EMF value for the attribute has to be fetched back from the data base.
- */
-public class TypeWriterTypeTest extends LibraryJPATest {
-
- public TypeWriterTypeTest(String name) {
- super(name);
- }
-
- public void testInsertTypeWriterWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertTypeWriter(checkCache);
- }
-
- public void testInsertTypeWriterNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertTypeWriter(checkCache);
- }
-
- private void verifyInsertTypeWriter(boolean checkCache) {
-
- beginTransaction();
-
- TypeWriter twriter = createAnonymousTypewriter(em);
- String twriterMaker = twriter.getMaker();
- TWriterType twriterType = twriter.getType();
-
- // put the data to the data base
- commitTransaction();
-
- // verify
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // Check whether the writer as been allocated at the data base.
-
- TypeWriter dbTWriter = findTypeWriterWithMaker(em, twriterMaker);
-
- assertNotNull("dbTWriter not found", dbTWriter);
- assertEquals("dbTWriter.maker", twriterMaker, dbTWriter.getMaker());
- assertEquals("dbTWriter.type", twriterType, dbTWriter.getType());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java
deleted file mode 100755
index 2663008a0..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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.Address;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-public class WriterAddressTest extends LibraryJPATest {
-
- public WriterAddressTest(String name) {
- super(name);
- }
-
- public void testInsertWriterAndAddressWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterAddress(checkCache);
- }
-
- public void testInsertWriterAndAddressNoCache() throws Exception {
- boolean checkCache = false;
- verifyInsertWriterAddress(checkCache);
- }
-
- private void verifyInsertWriterAddress(boolean checkCache) {
-
- beginTransaction();
-
- Writer writer = createAnonymousWriterWithAddress(em);
- String writerName = writer.getName();
- Address address = writer.getAddress();
-
- // put the data to the data base
- commitTransaction();
-
- // verify
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
-
- // Check whether the writer as been allocated at the data base.
-
- Writer dbWriter = findWriterWithName(em, writerName);
- assertNotNull("dbWriter not found", dbWriter);
- Address dbAddress = dbWriter.getAddress();
-
- assertNotNull("dbAddress not found", dbAddress);
- assertNotNull("eContainer not set", dbAddress.eContainer());
- int containerFeatureID = ((InternalEObject) address).eContainerFeatureID();
- int dbContainerFeatureID = ((InternalEObject) dbAddress).eContainerFeatureID();
- assertEquals("Containment Feature Id DB Address", containerFeatureID, dbContainerFeatureID);
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java
deleted file mode 100755
index 959381bc8..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.Publisher;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-/**
- * @author ebk2fe
- * @version 1.0 (April 28th, 2006)
- * <p>
- * This test case creates a writer object and assignes two publishers to the writer. The objects are committed
- * to the data base. The writer is fetched back from the data base.
- */
-public class WriterPublisherTest extends LibraryJPATest {
-
- public WriterPublisherTest(String name) {
- super(name);
- }
-
- public void testInsertWriterPublisherWithCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterPublisher(checkCache);
- }
-
- public void testInsertWriterPublisherNoCache() throws Exception {
- boolean checkCache = true;
- verifyInsertWriterPublisher(checkCache);
- }
-
- private void verifyInsertWriterPublisher(boolean checkCache) {
-
- beginTransaction();
- Writer writer = createAnonymousWriter(em);
- String writerName = writer.getName();
- Publisher publisher1 = createAnonymousPublisher(em);
- Publisher publisher2 = createAnonymousPublisher(em);
-
- publisher1.getWriters().add(writer);
- publisher2.getWriters().add(writer);
-
- writer.getPublishers().add(publisher1);
- writer.getPublishers().add(publisher2);
-
- int nbrElements = writer.getPublishers().size();
-
- commitTransaction();
-
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- Writer dbWriter = findWriterWithName(em, writerName);
-
- assertNotNull("dbWriter not found", dbWriter);
- assertEquals("nbr list elements", nbrElements, dbWriter.getPublishers().size());
-
- Publisher dbPublisher = dbWriter.getPublishers().get(0);
-
- assertNotNull("dbPublisher not found", dbPublisher);
- assertEquals("reference to the writer", dbWriter, dbPublisher.getWriters().get(0));
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java
deleted file mode 100755
index 9fbeafda5..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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.teneo.eclipselink.examples.library.TWriterType;
-import org.eclipse.emf.teneo.eclipselink.examples.library.TypeWriter;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-
-/**
- * @author ebk2fe
- * @version 1.0.1 June 9th, 2006
- * <p>
- * This test case creates a writer object and assigns a typewriter to the writer. The object model uses a 1:n
- * association based on EList to store the reference from writer to the typewriter(s). The data base model
- * provides an associative table to cover the list of references. The or-mapping uses the many-to-many mapping
- * to implement the 1:n relationship. The benefit would be that no explicite backward reference is required at
- * the object model.
- */
-public class WriterTypewriterTest extends LibraryJPATest {
-
- public WriterTypewriterTest(String name) {
-
- super(name);
- }
-
- public void testInsertWriterWithTypeWriterWithCache() throws Exception {
-
- boolean checkCache = true;
- verifyInsertWriterWithTypeWriter(checkCache);
- }
-
- public void testInsertWriterWithTypeWriterNoCache() throws Exception {
-
- boolean checkCache = false;
- verifyInsertWriterWithTypeWriter(checkCache);
- }
-
- private void verifyInsertWriterWithTypeWriter(boolean checkCache) {
-
- beginTransaction();
-
- Writer writer = createAnonymousWriterWithTypeWriter(em);
- TypeWriter twriter = writer.getTypewriters().get(0);
- String twriterMaker = twriter.getMaker();
- TWriterType twriterType = twriter.getType();
- String writerName = writer.getName();
-
- // put the data to the data base
- commitTransaction();
-
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
- // Check whether the writer as been allocated at the data base.
-
- Writer dbWriter = findWriterWithName(em, writerName);
-
- assertNotNull("dbWriter not found", dbWriter);
- assertEquals("dbWriter.name", writerName, dbWriter.getName());
-
- TypeWriter dbTWriter = dbWriter.getTypewriters().get(0);
-
- assertNotNull("dbTWriter not found", dbTWriter);
- assertEquals("dbTWriter.maker", twriterMaker, dbTWriter.getMaker());
- assertEquals("dbTWriter.type", twriterType, dbTWriter.getType());
-
- }
-
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AbstractEclipseLinkTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AbstractEclipseLinkTest.java
deleted file mode 100755
index ff87acf50..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AbstractEclipseLinkTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import junit.framework.TestCase;
-
-import org.eclipse.persistence.config.PersistenceUnitProperties;
-import org.eclipse.persistence.jpa.osgi.PersistenceProvider;
-
-public abstract class AbstractEclipseLinkTest extends TestCase {
-
- public static final String TEST_PERSISTENCE_UNIT_NAME = "library";
-
- public static Map<String, Object> getTestPersistenceUnitProperties(ClassLoader classloader) {
-
- HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(PersistenceUnitProperties.CLASSLOADER, classloader);
- return options;
- }
-
- protected TestModelFactory testLibraryFactory = new TestModelFactory();
-
- @Override
- protected void tearDown() throws Exception {
-
- super.tearDown();
-
- // create entity manager factory for given persistence unit name
- Map<String, Object> properties = getTestPersistenceUnitProperties(this.getClass().getClassLoader());
- EntityManagerFactory entityManagerFactory = new PersistenceProvider().createEntityManagerFactory(
- TEST_PERSISTENCE_UNIT_NAME, properties);
-
- // create entity manager
- EntityManager entityManager = entityManagerFactory.createEntityManager();
-
- // destroy library model in database and memory
- testLibraryFactory.destroyLibraryModel(entityManager);
-
- // close entity manager
- entityManager.close();
-
- // close entity manager factory for given persistence unit name
- entityManagerFactory.close();
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java
deleted file mode 100755
index d667248bf..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
-
- TestSuite suite = new TestSuite("TestSuite for EclipseLinkResourceImpl");
- // $JUnit-BEGIN$
- suite.addTestSuite(EclipseLinkResourceTest.class);
- // disabled following tests as it requires an open workspace
- // suite.addTestSuite(EclipseLinkAndXMIResourceTest.class);
- // $JUnit-END$
- return suite;
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java
deleted file mode 100755
index d39d74b6c..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Address;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Translator;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkURIUtil;
-
-public class CreateSampleLibrariesWithEclipseLinkResourceTest extends TestCase {
-
- private URI uri;
- private Resource resource;
- private Library libraryEclipseCon, libraryIBM, libraryOracle;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // create and populate first library model instance
- libraryEclipseCon = LibraryFactory.eINSTANCE.createLibrary();
- libraryEclipseCon.setName("EclipseCon Library");
-
- Writer writer1 = LibraryFactory.eINSTANCE.createWriter();
- writer1.setName("The True Eclipse Expert");
- libraryEclipseCon.getWriters().add(writer1);
-
- Address address1 = LibraryFactory.eINSTANCE.createAddress();
- address1.setTown("Sin City");
- writer1.setAddress(address1);
-
- Book book1 = LibraryFactory.eINSTANCE.createBook();
- book1.setTitle("Eclipse Tips & Tricks");
- libraryEclipseCon.getBooks().put(book1.getTitle(), book1);
-
- Translator translator1 = LibraryFactory.eINSTANCE.createTranslator();
- translator1.setName("Mr. Babelfish");
- book1.setTranslator(translator1);
-
- Address address2 = LibraryFactory.eINSTANCE.createAddress();
- address2.setTown("Foo City");
- // TODO add this relationship to mapping
- translator1.setAddress(address2);
-
- // create and populate second library model instance
- libraryIBM = LibraryFactory.eINSTANCE.createLibrary();
- libraryIBM.setName("IBM Library");
-
- // create and populate third library model instance
- libraryOracle = LibraryFactory.eINSTANCE.createLibrary();
- libraryOracle.setName("ORACLE Library");
-
- // create EclipseLink URI for saving/loading all library models in/from
- // database
- String query = EclipseLinkURIUtil.createContentsInstancesOfQuery(LibraryPackage.eINSTANCE.getLibrary());
- uri = EclipseLinkURIUtil.createEclipseLinkURI(AbstractEclipseLinkTest.TEST_PERSISTENCE_UNIT_NAME, query);
-
- // save all library model instances in database
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getLoadOptions().putAll(
- AbstractEclipseLinkTest.getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
- resource = resourceSet.createResource(uri);
- resource.getContents().add(libraryEclipseCon);
- resource.getContents().add(libraryIBM);
- resource.getContents().add(libraryOracle);
- resource.save(Collections.EMPTY_MAP);
-
- // unload resource of library model instances
- resource.unload();
- }
-
- public void testEclipseLinkResourceContentPresent() throws IOException {
- // load second library model instance from database
- ResourceSet resourceSet2 = new ResourceSetImpl();
- resourceSet2.getLoadOptions().putAll(
- AbstractEclipseLinkTest.getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
- Resource resource2 = resourceSet2.getResource(uri, true);
-
- assertTrue(resource2 instanceof EclipseLinkResourceImpl);
- assertTrue(resource2.isLoaded());
-
- // analyse second library model instance
- List<EObject> contents2 = resource2.getContents();
- assertNotNull(contents2);
- assertEquals(3, contents2.size());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java
deleted file mode 100755
index ef0ec2bcd..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-import org.eclipse.emf.teneo.eclipselink.examples.library.forum.Forum;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.StringToBookMapEntryImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkURIUtil;
-
-public class EclipseLinkAndXMIResourceTest extends AbstractEclipseLinkTest {
-
- private IProject testProject;
- private URI libraryURI, forumURI;
- private Library library1;
- private Forum forum1;
- private Resource libraryResource1, libraryResource2, libraryResource3;
- private Resource forumResource1, forumResource2, forumResource3;
-
- @Override
- protected void setUp() throws Exception {
-
- super.setUp();
-
- // create test project in runtime workspace
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- testProject = workspace.getRoot().getProject("Test");
- IProjectDescription description = workspace.newProjectDescription("Test");
- testProject.create(description, null);
- testProject.open(null);
- }
-
- @Override
- protected void tearDown() throws Exception {
-
- // delete test project including its contents from runtime workspace
- try {
- testProject.delete(true, true, null);
- } catch (CoreException cex) {
- cex.printStackTrace();
- }
-
- super.tearDown();
- }
-
- public void testEclipseLinkAndXMIResource() throws IOException {
-
- // create library model instance
- library1 = testLibraryFactory.createLibraryModel();
-
- // create forum model instance
- forum1 = testLibraryFactory.createForumModel();
-
- saveLibraryModel1AndForumModel1();
- loadLibraryModel2FromForumModel2ViaIDBasedCrossDocumentReference();
- loadLibraryModel3FromForumModel3ViaIndexBasedCrossDocumentReference();
- deleteLibraryModel1();
- unloadAllLibraryAndForumModels();
- }
-
- private void saveLibraryModel1AndForumModel1() throws IOException {
-
- // create EclipseLink URI for saving/loading library model in/from database
- String query = EclipseLinkURIUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),
- LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
- libraryURI = EclipseLinkURIUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
-
- // save library model instance in database
- ResourceSet resourceSet1 = new ResourceSetImpl();
- resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
- libraryResource1 = resourceSet1.createResource(libraryURI);
-
- assertTrue(libraryResource1 instanceof EclipseLinkResourceImpl);
-
- libraryResource1.getContents().add(library1);
- libraryResource1.save(Collections.EMPTY_MAP);
-
- // create platform resource URI for saving/loading forum model in/from
- // XMI file
- String forumPathName = createForumModelPathName(testProject, forum1);
- forumURI = URI.createPlatformResourceURI(forumPathName, false);
-
- // save forum model instance in XMI resource
- forumResource1 = resourceSet1.createResource(forumURI);
-
- assertTrue(forumResource1 instanceof XMIResourceImpl);
-
- forumResource1.getContents().add(forum1);
- forumResource1.save(Collections.EMPTY_MAP);
- }
-
- private void loadLibraryModel2FromForumModel2ViaIDBasedCrossDocumentReference() {
-
- // load second forum model instance from XMI resource
- ResourceSet resourceSet2 = new ResourceSetImpl();
- resourceSet2.getLoadOptions().putAll(getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
- forumResource2 = resourceSet2.getResource(forumURI, true);
-
- assertTrue(forumResource2 instanceof XMIResourceImpl);
-
- // analyse second forum model instance
- List<EObject> forumContents2 = forumResource2.getContents();
- assertNotNull(forumContents2);
- assertEquals(1, forumContents2.size());
- EObject forum2 = forumContents2.get(0);
-
- EPackage forumPack = forum2.eClass().getEPackage();
- EClass forumCls = (EClass) forumPack.getEClassifier("Forum");
- EStructuralFeature nameFeat = forumCls.getEStructuralFeature("name");
- EStructuralFeature ratedAuthorsFeat = forumCls.getEStructuralFeature("ratedAuthors");
-
- assertNotNull(forum2.eGet(nameFeat));
- assertEquals(forum1.eGet(nameFeat), forum2.eGet(nameFeat));
- assertNotNull(forum2.eGet(ratedAuthorsFeat));
- assertEquals(((EList<?>) forum1.eGet(ratedAuthorsFeat)).size(), ((EList<?>) forum2.eGet(ratedAuthorsFeat))
- .size());
-
- // navigate from second forum to referenced rated author and thereby
- // lazily load second library model instance from database resource
- Writer writer2 = (Writer) ((EList<?>) forum2.eGet(ratedAuthorsFeat)).get(0);
-
- assertNotNull(writer2);
-
- libraryResource2 = writer2.eResource();
-
- assertTrue(libraryResource2 instanceof EclipseLinkResourceImpl);
- assertEquals(libraryResource2.getURI(), libraryURI);
-
- // analyse second library model instance
- assertTrue(writer2.eContainer() instanceof Library);
- Library library2 = (Library) writer2.eContainer();
-
- assertNotNull(library2.getName());
- assertEquals(library1.getName(), library2.getName());
- assertNotNull(library2.getWriters());
- assertEquals(library1.getWriters().size(), library2.getWriters().size());
- assertNotNull(library2.getBooks());
- assertEquals(library1.getBooks().size(), library2.getBooks().size());
- }
-
- private void loadLibraryModel3FromForumModel3ViaIndexBasedCrossDocumentReference() {
-
- // load third forum model instance from XMI resource
- ResourceSet resourceSet3 = new ResourceSetImpl();
- resourceSet3.getLoadOptions().putAll(getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
- forumResource3 = resourceSet3.getResource(forumURI, true);
-
- assertTrue(forumResource3 instanceof XMIResourceImpl);
-
- // analyse third forum model instance
- List<EObject> forumContents3 = forumResource3.getContents();
- assertNotNull(forumContents3);
- assertEquals(1, forumContents3.size());
- EObject forum3 = forumContents3.get(0);
-
- EPackage forumPack = forum3.eClass().getEPackage();
- EClass forumCls = (EClass) forumPack.getEClassifier("Forum");
- EStructuralFeature nameFeat = forumCls.getEStructuralFeature("name");
- EStructuralFeature featuredBooksFeat = forumCls.getEStructuralFeature("featuredBooks");
-
- assertNotNull(forum3.eGet(nameFeat));
- assertEquals(forum1.eGet(nameFeat), forum3.eGet(nameFeat));
- assertNotNull(forum3.eGet(featuredBooksFeat));
- assertEquals(((EList<?>) forum1.eGet(featuredBooksFeat)).size(), ((EList<?>) forum3.eGet(featuredBooksFeat))
- .size());
-
- // navigate from third forum to referenced featured book and thereby
- // lazily load third library model instance from database resource
- Book book3 = (Book) ((EList<?>) forum3.eGet(featuredBooksFeat)).get(0);
-
- assertNotNull(book3);
-
- libraryResource3 = book3.eResource();
-
- assertTrue(libraryResource3 instanceof EclipseLinkResourceImpl);
- assertEquals(libraryResource3.getURI(), libraryURI);
-
- // analyse third library model instance
- assertTrue(book3.eContainer() instanceof StringToBookMapEntryImpl);
- StringToBookMapEntryImpl bookEntry3 = (StringToBookMapEntryImpl) book3.eContainer();
- assertTrue(bookEntry3.eContainer() instanceof Library);
- Library library3 = (Library) bookEntry3.eContainer();
-
- assertNotNull(library3.getName());
- assertEquals(library1.getName(), library3.getName());
- assertNotNull(library3.getWriters());
- assertEquals(library1.getWriters().size(), library3.getWriters().size());
- assertNotNull(library3.getBooks());
- assertEquals(library1.getBooks().size(), library3.getBooks().size());
- }
-
- private void deleteLibraryModel1() throws IOException {
-
- // delete first library model instance in database
- libraryResource1.getContents().remove(library1);
- libraryResource1.save(Collections.EMPTY_MAP);
- }
-
- private void unloadAllLibraryAndForumModels() {
-
- // unload resources of first library and forum model instance
- libraryResource1.unload();
- forumResource1.unload();
-
- // unload resources of second library and forum model instance
- libraryResource2.unload();
- forumResource2.unload();
-
- // unload resources of third library and forum model instance
- libraryResource3.unload();
- forumResource3.unload();
- }
-
- private String createForumModelPathName(IProject project, Forum forum) {
-
- IPath result = project.getFullPath().append(forum.getName() + "." + forum.eClass().getEPackage().getName());
- return result.toString();
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java
deleted file mode 100755
index 86740bd38..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.library.impl.LibraryImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceFactoryImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkURIUtil;
-
-public class EclipseLinkResourceTest extends AbstractEclipseLinkTest {
-
- private URI uri;
- private Resource resource1, resource2;
- private Library library1;
-
- public void testEclipseLinkResource() throws IOException {
-
- // create library model instance
- library1 = testLibraryFactory.createLibraryModel();
-
- saveLibraryModel1();
- loadLibraryModel2();
- deleteLibraryModel1();
- reloadLibraryModel2();
- unloadAllLibraryModels();
- }
-
- private void saveLibraryModel1() throws IOException {
-
- // create EclipseLink URI for saving/loading library model in/from database
- String query = EclipseLinkURIUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),
- LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
- uri = EclipseLinkURIUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
-
- // save library model instance in database
- ResourceSet resourceSet1 = new ResourceSetImpl();
- resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
-
- resourceSet1.getResourceFactoryRegistry().getProtocolToFactoryMap().put("eclipselink",
- new EclipseLinkResourceFactoryImpl());
-
- resource1 = resourceSet1.createResource(uri);
-
- assertTrue(resource1 instanceof EclipseLinkResourceImpl);
- assertFalse(resource1.isLoaded());
-
- resource1.getContents().add(library1);
-
- assertTrue(resource1.isLoaded());
-
- resource1.save(Collections.EMPTY_MAP);
- }
-
- private void loadLibraryModel2() {
-
- // load second library model instance from database
- ResourceSet resourceSet2 = new ResourceSetImpl();
-
- resourceSet2.getResourceFactoryRegistry().getProtocolToFactoryMap().put("eclipselink",
- new EclipseLinkResourceFactoryImpl());
- resourceSet2.getLoadOptions().putAll(getTestPersistenceUnitProperties(this.getClass().getClassLoader()));
-
- resource2 = resourceSet2.getResource(uri, true);
-
- assertTrue(resource2 instanceof EclipseLinkResourceImpl);
- assertTrue(resource2.isLoaded());
-
- // analyse second library model instance
- List<EObject> contents2 = resource2.getContents();
- assertNotNull(contents2);
- assertEquals(1, contents2.size());
- assertTrue(contents2.get(0) instanceof LibraryImpl);
- Library library2 = (Library) contents2.get(0);
-
- assertNotNull(library2.getName());
- assertEquals(library1.getName(), library2.getName());
- assertNotNull(library2.getWriters());
- assertEquals(library1.getWriters().size(), library2.getWriters().size());
- assertEquals(resource2, (library2.getWriters().get(0)).eResource());
- assertNotNull(library2.getBooks());
- assertEquals(library1.getBooks().size(), library2.getBooks().size());
- assertEquals(resource2, (library2.getBooks().get("myBook")).eResource());
- }
-
- private void deleteLibraryModel1() throws IOException {
-
- // delete first library model instance in database
- resource1.getContents().remove(library1);
- resource1.save(Collections.EMPTY_MAP);
- }
-
- private void reloadLibraryModel2() throws IOException {
-
- // reload second library model instance from database
- resource2.unload();
-
- assertFalse(resource2.isLoaded());
-
- resource2.load(Collections.EMPTY_MAP);
-
- assertTrue(resource2.isLoaded());
-
- // analyse second library model instance
- List<EObject> contents2 = resource2.getContents();
- assertNotNull(contents2);
- assertEquals(0, contents2.size());
- }
-
- private void unloadAllLibraryModels() {
-
- // unload resource of first library model instance
- resource1.unload();
-
- assertFalse(resource1.isLoaded());
-
- // unload resource of second library model instance
- resource2.unload();
-
- assertFalse(resource2.isLoaded());
- }
-}
diff --git a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java b/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java
deleted file mode 100755
index b9d9c96c2..000000000
--- a/eclipselink/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * 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.resource;
-
-import javax.persistence.EntityManager;
-
-import org.eclipse.emf.teneo.eclipselink.examples.library.Book;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Library;
-import org.eclipse.emf.teneo.eclipselink.examples.library.LibraryFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
-import org.eclipse.emf.teneo.eclipselink.examples.library.forum.Forum;
-import org.eclipse.emf.teneo.eclipselink.examples.library.forum.ForumFactory;
-
-public class TestModelFactory {
-
- private Library library;
-
- private Writer writer;
-
- private Book book;
-
- public Library createLibraryModel() {
-
- if (library == null) {
- // create and populate library model instance
- library = LibraryFactory.eINSTANCE.createLibrary();
- library.setName("myLibrary");
- writer = LibraryFactory.eINSTANCE.createWriter();
- writer.setName("myWriter");
- library.getWriters().add(writer);
- book = LibraryFactory.eINSTANCE.createBook();
- book.setTitle("myBook");
- library.getBooks().put(book.getTitle(), book);
- }
-
- return library;
- }
-
- public Forum createForumModel() {
-
- // create and populate forum model instance
- Forum forum = ForumFactory.eINSTANCE.createForum();
- forum.setName("myForum");
- if (writer != null) {
- forum.getRatedAuthors().add(writer);
- }
- if (book != null) {
- forum.getFeaturedBooks().add(book);
- }
-
- return forum;
- }
-
- public void destroyLibraryModel(EntityManager entityManager) {
-
- if (library != null) {
- // begin transaction
- entityManager.getTransaction().begin();
-
- // delete library model from database; delete does not cascade so order is
- // important
- entityManager.createQuery("delete from Publisher o").executeUpdate();
- entityManager.createQuery("delete from StringToBookMapEntry o").executeUpdate();
- entityManager.createQuery("delete from BookStylesMapEntry o").executeUpdate();
- entityManager.createQuery("delete from Cover o").executeUpdate();
- entityManager.createQuery("delete from Book o").executeUpdate();
- entityManager.createQuery("delete from Translator o").executeUpdate();
- entityManager.createQuery("delete from Writer o").executeUpdate();
- entityManager.createQuery("delete from TypeWriter o").executeUpdate();
- entityManager.createQuery("delete from Address o").executeUpdate();
- entityManager.createQuery("delete from Library o").executeUpdate();
- entityManager.createQuery("delete from Style o").executeUpdate();
-
- // commit and end transaction
- entityManager.getTransaction().commit();
-
- // dispose library model
- library = null;
- writer = null;
- book = null;
- }
- }
-}

Back to the top