Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseberle2009-01-21 22:29:17 +0000
committerseberle2009-01-21 22:29:17 +0000
commit8b23343993ee9275400e24a369519fff2a46b13c (patch)
tree92491cfc1207b6a9ce87b73afbee132b6583eda1 /tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests
parent7a42e6f340eace96e29ca4c9c3b278a4f7d1da48 (diff)
downloadorg.eclipse.emf.teneo-8b23343993ee9275400e24a369519fff2a46b13c.tar.gz
org.eclipse.emf.teneo-8b23343993ee9275400e24a369519fff2a46b13c.tar.xz
org.eclipse.emf.teneo-8b23343993ee9275400e24a369519fff2a46b13c.zip
added project-specific formatting options based on Eclipse built-in formatting template and save actions for automatic import organization and reformatting
Diffstat (limited to 'tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests')
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.core.prefs16
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java34
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java7
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java8
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java13
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java26
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java8
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java11
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java15
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java9
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java12
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java15
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java32
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java13
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java13
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java12
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java16
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java91
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java394
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java57
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java22
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java14
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java56
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java15
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java15
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java18
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java12
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java16
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/BasicEclipseLinkTest.java45
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java112
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java419
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java145
-rw-r--r--tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java135
34 files changed, 937 insertions, 945 deletions
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.core.prefs
index a1c92dd00..9fbf28d1e 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Sun Nov 02 00:14:53 CET 2008
+#Wed Jan 21 22:56:47 CET 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -53,8 +53,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
@@ -65,7 +65,7 @@ org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
-org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.line_length=120
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
@@ -80,7 +80,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
-org.eclipse.jdt.core.formatter.indentation.size=2
+org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
@@ -256,13 +256,13 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=160
+org.eclipse.jdt.core.formatter.lineSplit=120
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.jdt.core.formatter.tabulation.char=space
-org.eclipse.jdt.core.formatter.tabulation.size=2
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.ui.prefs
index 74116b037..5b2edb475 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,6 +1,58 @@
-#Sun Nov 02 00:13:12 CET 2008
+#Wed Jan 21 22:44:02 CET 2009
eclipse.preferences.version=1
-formatter_profile=_Teneo EclipseLink
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Teneo
formatter_settings_version=11
internal.default.compliance=default
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=true
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java
index 6ce452f72..4cd05f64e 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AdHocTest.java
@@ -14,13 +14,11 @@ 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.
+ * <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 {
@@ -37,36 +35,36 @@ public class AdHocTest extends LibraryJPATest {
public void testRemovePublisherWriterWithCache() throws Exception {
boolean checkCache = true;
- verifyRemovePublisherWriter(checkCache);
+ verifyRemovePublisherWriter(checkCache);
}
-
-// public void testRemovePublisherWriterNoCache() throws Exception {
-// boolean checkCache = false;
-// 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);
@@ -76,8 +74,7 @@ public class AdHocTest extends LibraryJPATest {
}
/**
- * The test fixture consists of a single publisher
- * with two writers.
+ * The test fixture consists of a single publisher with two writers.
*/
@Override
protected void setUp() throws Exception {
@@ -95,5 +92,4 @@ public class AdHocTest extends LibraryJPATest {
commitTransaction();
}
-
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java
index 165794618..ea9c975a2 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/AllTests.java
@@ -16,9 +16,8 @@ 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$
+ TestSuite suite = new TestSuite("ListTest for org.eclipse.emf.teneo.eclipselink.examples.library");
+ // $JUnit-BEGIN$
suite.addTestSuite(EObjectTest.class);
suite.addTestSuite(TypeWriterTypeTest.class);
suite.addTestSuite(LibWriterEContainerTest.class);
@@ -41,7 +40,7 @@ public class AllTests {
suite.addTestSuite(PublisherWriterTest.class);
suite.addTestSuite(EContainerReferenceTest.class);
suite.addTestSuite(BookStylesTest.class);
- //$JUnit-END$
+ // $JUnit-END$
return suite;
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java
index d61daa4ac..3c597aa15 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BasicTest.java
@@ -26,11 +26,9 @@ public class BasicTest extends LibraryJPATest {
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();
+
+ 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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java
index 7b432b560..cd669b952 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookCoverTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -32,7 +31,7 @@ public class BookCoverTest extends LibraryJPATest {
}
private void verifyInsertWriterAddress(boolean checkCache) {
-
+
beginTransaction();
Book book = createAnonymousBookWithCover(em);
@@ -41,22 +40,22 @@ public class BookCoverTest extends LibraryJPATest {
// 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();
+ int containerFeatureID = ((InternalEObject) cover).eContainerFeatureID();
+ int dbContainerFeatureID = ((InternalEObject) dbCover).eContainerFeatureID();
assertEquals("Containment Feature Id DB Cover", containerFeatureID, dbContainerFeatureID);
}
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java
index c16d2d020..21c8e034c 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookStylesTest.java
@@ -33,19 +33,19 @@ public class BookStylesTest extends LibraryJPATest {
private void verifyInsertBookStyles(boolean checkCache) {
beginTransaction();
-
+
Book book = createAnonymousBook(em);
- String bookTitle = book.getTitle();
+ 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();
-
+ int eContFeatId = ((BookStylesMapEntryImpl) book.getStyles().get(0)).eContainerFeatureID();
+
commitTransaction();
-
+
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
@@ -53,20 +53,20 @@ public class BookStylesTest extends LibraryJPATest {
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);
+
+ 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());
-
+ 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());
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java
index 9e9e7837f..5a45bcadc 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/BookTranslatorTest.java
@@ -30,22 +30,22 @@ public class BookTranslatorTest extends LibraryJPATest {
}
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);
+ 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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java
index 5ca118f57..1d8aeb1e7 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ContainerTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -24,12 +23,12 @@ public class ContainerTest extends LibraryJPATest {
}
public void testMoveBetweenContainersWithCache() throws Exception {
- boolean checkCache = true;
+ boolean checkCache = true;
verifyMoveBetweenContainers(checkCache);
}
public void testMoveBetweenContainersNoCache() throws Exception {
- boolean checkCache = false;
+ boolean checkCache = false;
verifyMoveBetweenContainers(checkCache);
}
@@ -53,14 +52,14 @@ public class ContainerTest extends LibraryJPATest {
String libraryTwoName = libraryTwo.getName();
libraryTwo.getWriters().add(writer);
commitTransaction();
-
+
// verify
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
- Library dbLibraryOne = findLibraryWithName(em, libraryOneName);
- Library dbLibraryTwo = findLibraryWithName(em, libraryTwoName);
+ 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();
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java
index e1aeef9ef..654b5fb21 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EContainerReferenceTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -32,11 +31,11 @@ public class EContainerReferenceTest extends LibraryJPATest {
}
/**
- * This test creates a Library with a contained Writer and determines whether
- * the inverse eContainer relationship is established from Writer to Library.
+ * 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
+ * @throws Exception
*/
private void verifyLibaryWriterRelationship(boolean checkCache) throws Exception {
beginTransaction();
@@ -51,16 +50,14 @@ public class EContainerReferenceTest extends LibraryJPATest {
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);
+ Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
+ assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
EObject actualWriterEContainer = actualWriter.eContainer();
assertEquals("writer eContainer", actualLibrary, actualWriterEContainer);
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java
index 48c5f5b9f..2262a60d8 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EListEMapTest.java
@@ -10,16 +10,12 @@
*******************************************************************************/
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);
}
@@ -49,7 +45,7 @@ public class EListEMapTest extends LibraryJPATest {
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
-
+
Writer actualWriter = findWriterWithName(em, writerName);
assertNotNull("writer", actualWriter);
assertEquals("writer name", writerName, actualWriter.getName());
@@ -66,5 +62,4 @@ public class EListEMapTest extends LibraryJPATest {
assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
}
-
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java
index 18f6decb6..960c15f69 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EMapTest.java
@@ -62,11 +62,9 @@ public class EMapTest extends LibraryJPATest {
EObject bookEntryContainer = bookContainer.eContainer();
EObject libraryBookEntryContainer = libraryBookContainer.eContainer();
- assertEquals("entry container", bookEntryContainer,
- libraryBookEntryContainer);
+ assertEquals("entry container", bookEntryContainer, libraryBookEntryContainer);
assertEquals("entry container", actualLibrary, bookEntryContainer);
- assertEquals("entry container", actualLibrary,
- libraryBookEntryContainer);
+ assertEquals("entry container", actualLibrary, libraryBookEntryContainer);
}
public void testAddBookToLibraryWithCache() throws Exception {
@@ -114,10 +112,8 @@ public class EMapTest extends LibraryJPATest {
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));
+ assertEquals("first library book", actualBookOne, libraryBooks.get(bookOneTitle));
+ assertEquals("second library book", actualBookTwo, libraryBooks.get(bookTwoTitle));
}
public void testRemoveBookFromLibraryWithCache() throws Exception {
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java
index a40584bdf..16e2cc421 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/EObjectTest.java
@@ -16,7 +16,7 @@ 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);
}
@@ -36,18 +36,18 @@ public class EObjectTest extends LibraryJPATest {
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);
@@ -64,12 +64,12 @@ public class EObjectTest extends LibraryJPATest {
String title = book.getTitle();
BookCategory category = book.getCategory();
commitTransaction();
-
+
// verify
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
-
+
beginTransaction();
Book actualBook = findBookWithTitle(em, title);
assertNotNull("book", actualBook);
@@ -97,12 +97,11 @@ public class EObjectTest extends LibraryJPATest {
if (!checkCache) {
reinitializeCachesAndEntityManager();
}
-
+
beginTransaction();
Library actualLibrary = findLibraryWithName(em, name);
assertNotNull("library", actualLibrary);
rollbackTransaction();
}
-
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java
index e39f33be1..e7e9e5b61 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/JPATest.java
@@ -23,13 +23,13 @@ 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>();
@@ -45,20 +45,19 @@ public abstract class JPATest extends ManagedTest {
}
@Override
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception {
super.setUp();
em = getEntityManagerFactory().createEntityManager();
cleanDatabase();
- }
+ }
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception {
if (em != null) {
try {
em.close();
} catch (RuntimeException e) {
- System.out.println("Exception closing EntityManager: "
- + e.getMessage());
+ System.out.println("Exception closing EntityManager: " + e.getMessage());
e.printStackTrace();
// not supposed to fail in tearDown
} finally {
@@ -66,20 +65,19 @@ public abstract class JPATest extends ManagedTest {
}
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.
+ * 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
+ * Utility method used to generate Strings for "don't care" attribute values of test objects: DON'T HARD WIRE VALUES
+ * IN TESTS
*
* @return String
*/
@@ -87,12 +85,11 @@ public abstract class JPATest extends ManagedTest {
return String.valueOf(nextTitleInt++);
}
- /**
- * Called when all the tests in the current suite are have
- * been run.
+ /**
+ * Called when all the tests in the current suite are have been run.
*/
@Override
- protected void allTestsComplete() {
+ protected void allTestsComplete() {
factory.close();
}
@@ -113,6 +110,7 @@ public abstract class JPATest extends ManagedTest {
protected void rollbackTransaction() {
em.getTransaction().rollback();
}
+
protected void reinitializeCachesAndEntityManager() {
Session session = SessionManager.getManager().getSession(getPersistenceUnitName());
session.getIdentityMapAccessor().initializeAllIdentityMaps();
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java
index 240c265cb..eb991a27c 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibBookEContainerTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -35,13 +34,13 @@ public class LibBookEContainerTest extends LibraryJPATest {
* 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>
+ * 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();
@@ -49,18 +48,18 @@ public class LibBookEContainerTest extends LibraryJPATest {
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();
+ int containerFeatureID = ((InternalEObject) book).eContainerFeatureID();
+ int actualContainerFeatureID = ((InternalEObject) actualBook).eContainerFeatureID();
assertEquals("Containment Feature Id DB Book", containerFeatureID, actualContainerFeatureID);
Library actualLibrary = findLibraryWithName(em, libraryName);
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java
index 452baf9b2..f41d17810 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibWriterEContainerTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -35,13 +34,13 @@ public class LibWriterEContainerTest extends LibraryJPATest {
* 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>
+ * 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);
@@ -58,10 +57,10 @@ public class LibWriterEContainerTest extends LibraryJPATest {
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();
+ 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);
@@ -69,7 +68,7 @@ public class LibWriterEContainerTest extends LibraryJPATest {
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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java
index f1998ac90..8820b6fb3 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerLibraryTest.java
@@ -31,16 +31,14 @@ public class LibraryEContainerLibraryTest extends LibraryJPATest {
}
/**
- * 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.
+ * 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();
@@ -65,7 +63,7 @@ public class LibraryEContainerLibraryTest extends LibraryJPATest {
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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java
index 324972ff0..0ed327955 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEContainerTest.java
@@ -31,16 +31,14 @@ public class LibraryEContainerTest extends LibraryJPATest {
}
/**
- * 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.
+ * 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();
@@ -62,12 +60,10 @@ public class LibraryEContainerTest extends LibraryJPATest {
Book actualBook = findBookWithTitle(em, bookTitle);
assertNotNull("book", actualBook);
- assertEquals("number of writer books", 1, actualWriter.getBooks()
- .size());
+ 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);
+ assertEquals("writer book", actualWriter.getBooks().get(0), actualBook);
// verify whether the field eContainer is set
assertNotNull("Field Actual/Writer.eContainer not set", actualWriter.eContainer());
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java
index d01123e31..a2cfc84b5 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryEnvironmentTest.java
@@ -18,69 +18,68 @@ 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) {
+ 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);
+ }
- super(name);
- }
+ private void verifyLibraryEnvironment(boolean checkCache) {
- public void testLibraryEnvironmentWithCache() throws Exception {
+ beginTransaction();
- boolean checkCache = true;
- verifyLibraryEnvironment(checkCache);
- }
+ // Create the Test Environment
- public void testLibraryEnvironmentNoCache() throws Exception {
+ Library library = setupLibraryEnvironment(em);
- boolean checkCache = false;
- verifyLibraryEnvironment(checkCache);
- }
+ String libraryName = library.getName();
- private void verifyLibraryEnvironment(boolean checkCache) {
+ // put the data to the data base
- beginTransaction();
+ commitTransaction();
- // Create the Test Environment
-
- Library library = setupLibraryEnvironment(em);
-
- String libraryName = library.getName();
+ // set the cache usage
- // put the data to the data base
+ if (!checkCache) {
+ reinitializeCachesAndEntityManager();
+ }
- commitTransaction();
+ // fetch back the library
- // set the cache usage
+ Library dbLibrary = findLibraryWithName(em, libraryName);
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
+ // verify
- // fetch back the library
-
- Library dbLibrary = findLibraryWithName(em, libraryName);
+ assertNotNull("dbLibray not found", dbLibrary);
+ assertEquals("dbLibrary.name", libraryName, dbLibrary.getName());
- // 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);
- Book dbBook = (Book) dbLibrary.getBooks().values().toArray()[0];
- Writer dbWriter = dbLibrary.getWriters().get(0);
-
- assertNotNull("dbBook not found", dbBook);
- assertNotNull("dbWriter not found", dbWriter);
+ 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];
+ 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);
- }
+ assertNotNull("dbTranslator not found", dbTranslator);
+ assertNotNull("dbAddress not found", dbAddress);
+ assertNotNull("dbPublisher not found", dbPublisher);
+ assertNotNull("dbStyle not found", dbStyle);
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java
index ba97bb026..a027a3987 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryJPATest.java
@@ -32,200 +32,204 @@ import org.eclipse.emf.teneo.eclipselink.examples.library.impl.LibraryFactoryImp
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 StringToBookMapEntryImpl o").executeUpdate();
- em.createQuery("delete from BookStylesMapEntryImpl 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.MYSTERY);
- 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();
- }
+ 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 StringToBookMapEntryImpl o").executeUpdate();
+ em.createQuery("delete from BookStylesMapEntryImpl 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.MYSTERY);
+ 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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java
index fbf6c24fa..01d5a575e 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/LibraryXMIPersistenceTest.java
@@ -38,14 +38,11 @@ public class LibraryXMIPersistenceTest extends LibraryJPATest {
}
/**
- * 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.
- *
+ * 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 {
@@ -59,53 +56,47 @@ public class LibraryXMIPersistenceTest extends LibraryJPATest {
library.getBooks().put(book.getTitle(), book);
library.getWriters().add(writer);
- saveToXMIFile(library,
- "file://c:/temp/LibraryXMIPersistenceTestBefore.library");
+ saveToXMIFile(library, "file://c:/temp/LibraryXMIPersistenceTestBefore.library");
commitTransaction();
- // verify
- if (!checkCache) {
- reinitializeCachesAndEntityManager();
- }
+ // 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());
+ 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);
+ assertEquals("writer book", actualWriter.getBooks().get(0), actualBook);
Library actualLibrary = findLibraryWithName(em, libraryName);
- Book actualLibraryBook = actualLibrary.getBooks().get(
- bookTitle);
+ Book actualLibraryBook = actualLibrary.getBooks().get(bookTitle);
assertEquals("book/library book", actualBook, actualLibraryBook);
- Writer actualLibraryWriter = actualLibrary.getWriters()
- .get(0);
- assertEquals("writer/library writer", actualWriter,
- actualLibraryWriter);
+ Writer actualLibraryWriter = actualLibrary.getWriters().get(0);
+ assertEquals("writer/library writer", actualWriter, actualLibraryWriter);
// Start the writing to XMI
- saveToXMIFile(actualLibrary,
- "file://c:/temp/LibraryXMIPersistenceTestAfter.library");
+ saveToXMIFile(actualLibrary, "file://c:/temp/LibraryXMIPersistenceTestAfter.library");
}
/**
- * 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>"
+ * 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, String fileURI)
- throws IOException {
+ private void saveToXMIFile(Library library, String fileURI) throws IOException {
ResourceSet resourceSet = new ResourceSetImpl();
URI resURI = URI.createURI(fileURI);
Resource res = resourceSet.createResource(resURI);
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java
index 1cf1a5a1c..37e0d0d8f 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/ManagedTest.java
@@ -18,10 +18,10 @@ 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();
- }
+ public ManagedTest(String sTestName) {
+ super(sTestName);
+ registerTest();
+ }
private void registerTest() {
runningTests.add(this);
@@ -34,17 +34,15 @@ public abstract class ManagedTest extends TestCase {
}
}
- /**
- * Called when all the tests in the current suite are have
- * been run.
+ /**
+ * 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();
- }
-
+ protected void tearDown() throws Exception {
+ unregisterTest();
+ super.tearDown();
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java
index 7985adb2e..461fc1d01 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/OneToOneTest.java
@@ -27,15 +27,11 @@ public class OneToOneTest extends LibraryJPATest {
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();
+
+ 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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java
index ddccaf314..474817284 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/PublisherWriterTest.java
@@ -14,13 +14,11 @@ 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.
+ * <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 {
@@ -47,22 +45,22 @@ public class PublisherWriterTest extends LibraryJPATest {
public void testRemovePublisherWriterWithCache() throws Exception {
boolean checkCache = true;
- verifyRemovePublisherWriter(checkCache);
+ verifyRemovePublisherWriter(checkCache);
}
-
+
public void testRemovePublisherWriterNoCache() throws Exception {
boolean checkCache = false;
- verifyRemovePublisherWriter(checkCache);
+ verifyRemovePublisherWriter(checkCache);
}
public void testMovePublisherWriterWithCache() throws Exception {
boolean checkCache = true;
- verifyMovePublisherWriter(checkCache);
+ verifyMovePublisherWriter(checkCache);
}
-
+
public void testMovePublisherWriterNoCache() throws Exception {
boolean checkCache = false;
- verifyMovePublisherWriter(checkCache);
+ verifyMovePublisherWriter(checkCache);
}
private void verifyMovePublisherWriter(boolean checkCache) {
@@ -71,26 +69,26 @@ public class PublisherWriterTest extends LibraryJPATest {
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);
+ 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);
@@ -102,31 +100,31 @@ public class PublisherWriterTest extends LibraryJPATest {
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));
+ 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);
@@ -143,18 +141,15 @@ public class PublisherWriterTest extends LibraryJPATest {
Publisher dbPublisher = findPublisherWithName(em, publisherName);
assertNotNull("publisher not found", dbPublisher);
- assertEquals("publisher's writers", 2, dbPublisher
- .getWriters().size());
+ 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));
+ assertEquals("writer's publisher", dbPublisher, dbWriter.getPublishers().get(0));
}
-
+
/**
- * The test fixture consists of a single publisher
- * with two writers.
+ * The test fixture consists of a single publisher with two writers.
*/
@Override
protected void setUp() throws Exception {
@@ -172,5 +167,4 @@ public class PublisherWriterTest extends LibraryJPATest {
commitTransaction();
}
-
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java
index 10b901485..af9d2b4b7 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/TypeWriterTypeTest.java
@@ -16,15 +16,12 @@ 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.
- *
+ * <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 {
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java
index 0b44e1261..2663008a0 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterAddressTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
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;
@@ -32,32 +31,32 @@ public class WriterAddressTest extends LibraryJPATest {
}
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();
+ int containerFeatureID = ((InternalEObject) address).eContainerFeatureID();
+ int dbContainerFeatureID = ((InternalEObject) dbAddress).eContainerFeatureID();
assertEquals("Containment Feature Id DB Address", containerFeatureID, dbContainerFeatureID);
}
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java
index 5bb4e17e9..959381bc8 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterPublisherTest.java
@@ -14,13 +14,11 @@ 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.
+ * <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 {
@@ -45,13 +43,13 @@ public class WriterPublisherTest extends LibraryJPATest {
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();
@@ -60,10 +58,10 @@ public class WriterPublisherTest extends LibraryJPATest {
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);
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java
index bdf551c8e..9fbeafda5 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/WriterTypewriterTest.java
@@ -18,13 +18,11 @@ 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.
+ * 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 {
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java
index 16f513fd4..ce16f684e 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/AllTests.java
@@ -15,13 +15,13 @@ import junit.framework.TestSuite;
public class AllTests {
- public static Test suite() {
+ public static Test suite() {
- TestSuite suite = new TestSuite("TestSuite for EclipseLinkResourceImpl");
- //$JUnit-BEGIN$
- suite.addTestSuite(EclipseLinkResourceTest.class);
- suite.addTestSuite(EclipseLinkAndXMIResourceTest.class);
- //$JUnit-END$
- return suite;
- }
+ TestSuite suite = new TestSuite("TestSuite for EclipseLinkResourceImpl");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(EclipseLinkResourceTest.class);
+ suite.addTestSuite(EclipseLinkAndXMIResourceTest.class);
+ // $JUnit-END$
+ return suite;
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/BasicEclipseLinkTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/BasicEclipseLinkTest.java
index 0b71a6f09..6d5aa4163 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/BasicEclipseLinkTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/BasicEclipseLinkTest.java
@@ -23,36 +23,37 @@ import org.eclipse.persistence.jpa.osgi.PersistenceProvider;
public class BasicEclipseLinkTest extends TestCase {
- protected static final String TEST_PERSISTENCE_UNIT_NAME = "library";
+ protected static final String TEST_PERSISTENCE_UNIT_NAME = "library";
- protected TestModelFactory testLibraryFactory = new TestModelFactory();
+ protected TestModelFactory testLibraryFactory = new TestModelFactory();
- protected Map<String, Object> getTestPersistenceUnitProperties() {
+ protected Map<String, Object> getTestPersistenceUnitProperties() {
- HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
- return options;
- }
+ HashMap<String, Object> options = new HashMap<String, Object>();
+ options.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
+ return options;
+ }
- @Override
- protected void tearDown() throws Exception {
+ @Override
+ protected void tearDown() throws Exception {
- super.tearDown();
+ super.tearDown();
- // create entity manager factory for given persistence unit name
- Map<String, Object> properties = getTestPersistenceUnitProperties();
- EntityManagerFactory entityManagerFactory = new PersistenceProvider().createEntityManagerFactory(TEST_PERSISTENCE_UNIT_NAME, properties);
+ // create entity manager factory for given persistence unit name
+ Map<String, Object> properties = getTestPersistenceUnitProperties();
+ EntityManagerFactory entityManagerFactory = new PersistenceProvider().createEntityManagerFactory(
+ TEST_PERSISTENCE_UNIT_NAME, properties);
- // create entity manager and begin transaction
- EntityManager entityManager = entityManagerFactory.createEntityManager();
+ // create entity manager and begin transaction
+ EntityManager entityManager = entityManagerFactory.createEntityManager();
- // destroy library model in database and memory
- testLibraryFactory.destroyLibraryModel(entityManager);
+ // destroy library model in database and memory
+ testLibraryFactory.destroyLibraryModel(entityManager);
- // close entity manager
- entityManager.close();
+ // close entity manager
+ entityManager.close();
- // close entity manager factory for given persistence unit name
- entityManagerFactory.close();
- }
+ // close entity manager factory for given persistence unit name
+ entityManagerFactory.close();
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java
index 147ccbe9b..acf1bdac6 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/CreateSampleLibrariesWithEclipseLinkResourceTest.java
@@ -17,69 +17,69 @@ import org.eclipse.emf.common.util.URI;
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.resource.EclipseLinkResourceUtil;
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.Translator;
import org.eclipse.emf.teneo.eclipselink.examples.library.Writer;
+import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceUtil;
public class CreateSampleLibrariesWithEclipseLinkResourceTest extends BasicEclipseLinkTest {
- private URI uri;
- private Resource resource;
- private Library library1, library2, library3;
-
- public void testEclipseLinkResource() throws IOException {
-
- // create and populate first library model instance
- library1 = LibraryFactory.eINSTANCE.createLibrary();
- library1.setName("EclipseCon Library");
-
- Writer writer1 = LibraryFactory.eINSTANCE.createWriter();
- writer1.setName("The True Eclipse Expert");
- library1.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");
- library1.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
- library2 = LibraryFactory.eINSTANCE.createLibrary();
- library2.setName("IBM Library");
-
- // create and populate third library model instance
- library3 = LibraryFactory.eINSTANCE.createLibrary();
- library3.setName("ORACLE Library");
-
- // create EclipseLink URI for saving/loading all library models in/from
- // database
- uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, Library.class.getName());
-
- // save all library model instances in database
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getLoadOptions().putAll(getTestPersistenceUnitProperties());
- resource = resourceSet.createResource(uri);
- resource.getContents().add(library1);
- resource.getContents().add(library2);
- resource.getContents().add(library3);
- resource.save(Collections.EMPTY_MAP);
-
- // unload resource of library model instances
- resource.unload();
- }
+ private URI uri;
+ private Resource resource;
+ private Library library1, library2, library3;
+
+ public void testEclipseLinkResource() throws IOException {
+
+ // create and populate first library model instance
+ library1 = LibraryFactory.eINSTANCE.createLibrary();
+ library1.setName("EclipseCon Library");
+
+ Writer writer1 = LibraryFactory.eINSTANCE.createWriter();
+ writer1.setName("The True Eclipse Expert");
+ library1.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");
+ library1.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
+ library2 = LibraryFactory.eINSTANCE.createLibrary();
+ library2.setName("IBM Library");
+
+ // create and populate third library model instance
+ library3 = LibraryFactory.eINSTANCE.createLibrary();
+ library3.setName("ORACLE Library");
+
+ // create EclipseLink URI for saving/loading all library models in/from
+ // database
+ uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, Library.class.getName());
+
+ // save all library model instances in database
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getLoadOptions().putAll(getTestPersistenceUnitProperties());
+ resource = resourceSet.createResource(uri);
+ resource.getContents().add(library1);
+ resource.getContents().add(library2);
+ resource.getContents().add(library3);
+ resource.save(Collections.EMPTY_MAP);
+
+ // unload resource of library model instances
+ resource.unload();
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java
index 41f328f90..b6b83d251 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkAndXMIResourceTest.java
@@ -14,7 +14,6 @@ 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;
@@ -31,223 +30,221 @@ 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.resource.EclipseLinkResourceImpl;
-import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceUtil;
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.EclipseLinkResourceUtil;
public class EclipseLinkAndXMIResourceTest extends BasicEclipseLinkTest {
- 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 = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(), LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
- libraryURI = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
-
- // save library model instance in database
- ResourceSet resourceSet1 = new ResourceSetImpl();
- resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
- 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());
- 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());
- 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();
- }
-
- //
- // helper methods
- //
-
- private String createForumModelPathName(IProject project, Forum forum) {
-
- IPath result = project.getFullPath().append(forum.getName() + "." + forum.eClass().getEPackage().getName());
- return result.toString();
- }
+ 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 = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),
+ LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
+ libraryURI = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
+
+ // save library model instance in database
+ ResourceSet resourceSet1 = new ResourceSetImpl();
+ resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
+ 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());
+ 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());
+ 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/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java
index c98810d3b..d9b390e43 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/EclipseLinkResourceTest.java
@@ -27,104 +27,105 @@ import org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceUtil;
public class EclipseLinkResourceTest extends BasicEclipseLinkTest {
- private URI uri;
- private Resource resource1, resource2;
- private Library library1;
+ private URI uri;
+ private Resource resource1, resource2;
+ private Library library1;
- public void testEclipseLinkResource() throws IOException {
+ public void testEclipseLinkResource() throws IOException {
- // create library model instance
- library1 = testLibraryFactory.createLibraryModel();
+ // create library model instance
+ library1 = testLibraryFactory.createLibraryModel();
- saveLibraryModel1();
- loadLibraryModel2();
- deleteLibraryModel1();
- reloadLibraryModel2();
- unloadAllLibraryModels();
- }
+ saveLibraryModel1();
+ loadLibraryModel2();
+ deleteLibraryModel1();
+ reloadLibraryModel2();
+ unloadAllLibraryModels();
+ }
- private void saveLibraryModel1() throws IOException {
+ private void saveLibraryModel1() throws IOException {
- // create EclipseLink URI for saving/loading library model in/from database
- String query = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(), LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
- uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
+ // create EclipseLink URI for saving/loading library model in/from database
+ String query = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),
+ LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
+ uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
- // save library model instance in database
- ResourceSet resourceSet1 = new ResourceSetImpl();
- resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
- resource1 = resourceSet1.createResource(uri);
+ // save library model instance in database
+ ResourceSet resourceSet1 = new ResourceSetImpl();
+ resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
+ resource1 = resourceSet1.createResource(uri);
- assertTrue(resource1 instanceof EclipseLinkResourceImpl);
- assertFalse(resource1.isLoaded());
+ assertTrue(resource1 instanceof EclipseLinkResourceImpl);
+ assertFalse(resource1.isLoaded());
- resource1.getContents().add(library1);
+ resource1.getContents().add(library1);
- assertTrue(resource1.isLoaded());
+ assertTrue(resource1.isLoaded());
- resource1.save(Collections.EMPTY_MAP);
- }
+ resource1.save(Collections.EMPTY_MAP);
+ }
- private void loadLibraryModel2() {
+ private void loadLibraryModel2() {
- // load second library model instance from database
- ResourceSet resourceSet2 = new ResourceSetImpl();
- resourceSet2.getLoadOptions().putAll(getTestPersistenceUnitProperties());
- resource2 = resourceSet2.getResource(uri, true);
+ // load second library model instance from database
+ ResourceSet resourceSet2 = new ResourceSetImpl();
+ resourceSet2.getLoadOptions().putAll(getTestPersistenceUnitProperties());
+ resource2 = resourceSet2.getResource(uri, true);
- assertTrue(resource2 instanceof EclipseLinkResourceImpl);
- assertTrue(resource2.isLoaded());
+ 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);
+ // 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());
- }
+ 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 {
+ private void deleteLibraryModel1() throws IOException {
- // delete first library model instance in database
- resource1.getContents().remove(library1);
- resource1.save(Collections.EMPTY_MAP);
- }
+ // delete first library model instance in database
+ resource1.getContents().remove(library1);
+ resource1.save(Collections.EMPTY_MAP);
+ }
- private void reloadLibraryModel2() throws IOException {
+ private void reloadLibraryModel2() throws IOException {
- // reload second library model instance from database
- resource2.unload();
+ // reload second library model instance from database
+ resource2.unload();
- assertFalse(resource2.isLoaded());
+ assertFalse(resource2.isLoaded());
- resource2.load(Collections.EMPTY_MAP);
+ resource2.load(Collections.EMPTY_MAP);
- assertTrue(resource2.isLoaded());
+ assertTrue(resource2.isLoaded());
- // analyse second library model instance
- List<EObject> contents2 = resource2.getContents();
- assertNotNull(contents2);
- assertEquals(0, contents2.size());
- }
+ // analyse second library model instance
+ List<EObject> contents2 = resource2.getContents();
+ assertNotNull(contents2);
+ assertEquals(0, contents2.size());
+ }
- private void unloadAllLibraryModels() {
+ private void unloadAllLibraryModels() {
- // unload resource of first library model instance
- resource1.unload();
+ // unload resource of first library model instance
+ resource1.unload();
- assertFalse(resource1.isLoaded());
+ assertFalse(resource1.isLoaded());
- // unload resource of second library model instance
- resource2.unload();
+ // unload resource of second library model instance
+ resource2.unload();
- assertFalse(resource2.isLoaded());
- }
+ assertFalse(resource2.isLoaded());
+ }
}
diff --git a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java
index 9c78d23c1..1b9a6fdb7 100644
--- a/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java
+++ b/tests/org.eclipse.emf.teneo.eclipselink.examples.library.orm.tests/src/org/eclipse/emf/teneo/eclipselink/examples/library/orm/tests/resource/TestModelFactory.java
@@ -19,74 +19,73 @@ 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 StringToBookMapEntryImpl o").executeUpdate();
- entityManager.createQuery("delete from BookStylesMapEntryImpl o").executeUpdate();
- entityManager.createQuery("delete from Cover o").executeUpdate();
- entityManager.createQuery("delete from Book o").executeUpdate();
- entityManager.createQuery("delete from Publisher 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;
- }
- }
+ 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 StringToBookMapEntryImpl o").executeUpdate();
+ entityManager.createQuery("delete from BookStylesMapEntryImpl o").executeUpdate();
+ entityManager.createQuery("delete from Cover o").executeUpdate();
+ entityManager.createQuery("delete from Book o").executeUpdate();
+ entityManager.createQuery("delete from Publisher 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