Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-01-14 10:27:01 +0000
committerEike Stepper2012-01-14 10:27:01 +0000
commit0266166cb9ff9535c150250073ea1e57b42d2693 (patch)
treec006a3bc0ba1f6e1d8a2bc032eedc346f71eab0d /plugins/org.eclipse.emf.cdo.tests.db
parent7416443692cdda72d1f704ea4fc5ececcc669df7 (diff)
downloadcdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.gz
cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.xz
cdo-0266166cb9ff9535c150250073ea1e57b42d2693.zip
Adjusted copyrights to 2012
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.db')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.jdt.ui.prefs240
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java426
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/build.properties62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/copyright.txt14
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/plugin.properties22
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java142
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java324
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java986
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java278
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java652
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java1426
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java902
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java694
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/HsqlTest.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java70
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java1080
39 files changed, 4411 insertions, 4411 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.jdt.ui.prefs
index aaef0ccba1..6726e7034a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.jdt.ui.prefs
+++ b/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.jdt.ui.prefs
@@ -1,120 +1,120 @@
-#Thu Feb 04 09:44:24 CET 2010
-cleanup.add_default_serial_version_id=true
-cleanup.add_generated_serial_version_id=false
-cleanup.add_missing_annotations=true
-cleanup.add_missing_deprecated_annotations=true
-cleanup.add_missing_methods=false
-cleanup.add_missing_nls_tags=false
-cleanup.add_missing_override_annotations=true
-cleanup.add_missing_override_annotations_interface_methods=true
-cleanup.add_serial_version_id=true
-cleanup.always_use_blocks=true
-cleanup.always_use_parentheses_in_expressions=false
-cleanup.always_use_this_for_non_static_field_access=false
-cleanup.always_use_this_for_non_static_method_access=false
-cleanup.convert_to_enhanced_for_loop=false
-cleanup.correct_indentation=true
-cleanup.format_source_code=true
-cleanup.format_source_code_changes_only=false
-cleanup.make_local_variable_final=true
-cleanup.make_parameters_final=false
-cleanup.make_private_fields_final=true
-cleanup.make_type_abstract_if_missing_method=false
-cleanup.make_variable_declarations_final=false
-cleanup.never_use_blocks=false
-cleanup.never_use_parentheses_in_expressions=true
-cleanup.organize_imports=true
-cleanup.qualify_static_field_accesses_with_declaring_class=false
-cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-cleanup.qualify_static_member_accesses_with_declaring_class=false
-cleanup.qualify_static_method_accesses_with_declaring_class=false
-cleanup.remove_private_constructors=true
-cleanup.remove_trailing_whitespaces=true
-cleanup.remove_trailing_whitespaces_all=true
-cleanup.remove_trailing_whitespaces_ignore_empty=false
-cleanup.remove_unnecessary_casts=true
-cleanup.remove_unnecessary_nls_tags=true
-cleanup.remove_unused_imports=true
-cleanup.remove_unused_local_variables=false
-cleanup.remove_unused_private_fields=true
-cleanup.remove_unused_private_members=false
-cleanup.remove_unused_private_methods=true
-cleanup.remove_unused_private_types=true
-cleanup.sort_members=false
-cleanup.sort_members_all=false
-cleanup.use_blocks=true
-cleanup.use_blocks_only_for_return_and_throw=false
-cleanup.use_parentheses_in_expressions=true
-cleanup.use_this_for_non_static_field_access=true
-cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-cleanup.use_this_for_non_static_method_access=true
-cleanup.use_this_for_non_static_method_access_only_if_necessary=true
-cleanup_profile=_EMFT
-cleanup_settings_version=2
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_EMFT
-formatter_settings_version=11
-org.eclipse.jdt.ui.exception.name=ex
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.ignorelowercasenames=true
-org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.keywordthis=false
-org.eclipse.jdt.ui.ondemandthreshold=99
-org.eclipse.jdt.ui.overrideannotation=true
-org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></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_missing_override_annotations_interface_methods=false
-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=false
-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=false
-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=true
-sp_cleanup.use_this_for_non_static_field_access=true
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=true
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+#Thu Feb 04 09:44:24 CET 2010
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=false
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=false
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_EMFT
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_EMFT
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></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_missing_override_annotations_interface_methods=false
+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=false
+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=false
+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=true
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
index 8b726c4e7a..107c495b0d 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
@@ -1,213 +1,213 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.db.CDODBUtil;
-import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.tests.AuditTest;
-import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.db2.DB2Adapter;
-import org.eclipse.net4j.db.db2.DB2SchemaDatasource;
-
-import javax.sql.DataSource;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBDB2NonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBDB2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)"); //$NON-NLS-1$
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, AllTestsDBDB2NonAudit.DB2NonAudit.INSTANCE, JVM, NATIVE);
- }
-
- @Override
- protected boolean hasAuditSupport()
- {
- return false;
- }
-
- @Override
- protected boolean hasBranchingSupport()
- {
- return false;
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
- {
- super.initTestClasses(testClasses);
-
- // non-audit mode - remove audit tests
- testClasses.remove(AuditTest.class);
- testClasses.remove(AuditTestSameSession.class);
- testClasses.remove(Bugzilla_252214_Test.class);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class DB2NonAudit extends DBStoreRepositoryConfig
- {
- private static final String DB_NAME = "SAMPLE"; //$NON-NLS-1$
-
- private static final String DB_USER = "DB2ADMIN"; //$NON-NLS-1$
-
- private static final String DB_PASSWORD = "12345"; //$NON-NLS-1$
-
- static final String DB_SCHEMA = "CDOTEST"; //$NON-NLS-1$
-
- private static final long serialVersionUID = 1L;
-
- public static final AllTestsDBDB2NonAudit.DB2NonAudit INSTANCE = new DB2NonAudit("DBStore: DB2 (non-audit)"); //$NON-NLS-1$
-
- private transient String currentRepoName;
-
- private static int tableCounter;
-
- private static int dropCounter;
-
- public DB2NonAudit(String name)
- {
- super(name);
- }
-
- @Override
- protected void initRepositoryProperties(Map<String, String> props)
- {
- super.initRepositoryProperties(props);
- props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$
- }
-
- @Override
- protected IMappingStrategy createMappingStrategy()
- {
- Map<String, String> properties = new HashMap<String, String>();
- properties.put("qualifiedNames", "false");
- properties.put("forceNamesWithID", "false");
-
- IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false);
- mappingStrategy.setProperties(properties);
-
- return mappingStrategy;
- }
-
- @Override
- protected IDBAdapter createDBAdapter()
- {
- return new DB2Adapter();
- }
-
- @Override
- protected DataSource createDataSource(final String repoName)
- {
- if (currentRepoName != null && !repoName.equals(currentRepoName))
- {
- throw new IllegalStateException("This test config only supports a single repository"); //$NON-NLS-1$
- }
-
- currentRepoName = repoName;
-
- DB2SchemaDatasource dataSource = new DB2SchemaDatasource(DB_SCHEMA);
- dataSource.setDatabaseName(DB_NAME);
- dataSource.setUser(DB_USER);
- dataSource.setPassword(DB_PASSWORD);
-
- if (!isRestarting())
- {
- initAllTables(dataSource);
- }
-
- return dataSource;
- }
-
- @Override
- public void tearDown() throws Exception
- {
- currentRepoName = null;
- super.tearDown();
- }
-
- private static void initAllTables(DataSource dataSource)
- {
- Connection conn = null;
- Statement statement = null;
- String sql = null;
-
- try
- {
- conn = dataSource.getConnection();
- List<String> tableNames = DBUtil.getAllTableNames(conn, DB_SCHEMA);
- if (tableCounter != 0)
- {
- if (tableCounter < tableNames.size())
- {
- dropCounter = 20;
- }
- }
-
- tableCounter = tableNames.size();
-
- boolean drop = false;
- if (dropCounter > 0)
- {
- --dropCounter;
- }
- else if (dropCounter == 0)
- {
- tableCounter = 0;
- dropCounter = -1;
- drop = true;
- }
-
- statement = conn.createStatement();
- for (String tableName : tableNames)
- {
- sql = (drop ? "DROP TABLE " : "DELETE FROM ") + tableName; //$NON-NLS-1$ //$NON-NLS-2$
- DBUtil.trace(sql);
- statement.execute(sql);
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex, sql);
- }
- finally
- {
- DBUtil.close(statement);
- DBUtil.close(conn);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.tests.AuditTest;
+import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.db2.DB2Adapter;
+import org.eclipse.net4j.db.db2.DB2SchemaDatasource;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBDB2NonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBDB2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, AllTestsDBDB2NonAudit.DB2NonAudit.INSTANCE, JVM, NATIVE);
+ }
+
+ @Override
+ protected boolean hasAuditSupport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean hasBranchingSupport()
+ {
+ return false;
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
+ {
+ super.initTestClasses(testClasses);
+
+ // non-audit mode - remove audit tests
+ testClasses.remove(AuditTest.class);
+ testClasses.remove(AuditTestSameSession.class);
+ testClasses.remove(Bugzilla_252214_Test.class);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class DB2NonAudit extends DBStoreRepositoryConfig
+ {
+ private static final String DB_NAME = "SAMPLE"; //$NON-NLS-1$
+
+ private static final String DB_USER = "DB2ADMIN"; //$NON-NLS-1$
+
+ private static final String DB_PASSWORD = "12345"; //$NON-NLS-1$
+
+ static final String DB_SCHEMA = "CDOTEST"; //$NON-NLS-1$
+
+ private static final long serialVersionUID = 1L;
+
+ public static final AllTestsDBDB2NonAudit.DB2NonAudit INSTANCE = new DB2NonAudit("DBStore: DB2 (non-audit)"); //$NON-NLS-1$
+
+ private transient String currentRepoName;
+
+ private static int tableCounter;
+
+ private static int dropCounter;
+
+ public DB2NonAudit(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void initRepositoryProperties(Map<String, String> props)
+ {
+ super.initRepositoryProperties(props);
+ props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected IMappingStrategy createMappingStrategy()
+ {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("qualifiedNames", "false");
+ properties.put("forceNamesWithID", "false");
+
+ IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false);
+ mappingStrategy.setProperties(properties);
+
+ return mappingStrategy;
+ }
+
+ @Override
+ protected IDBAdapter createDBAdapter()
+ {
+ return new DB2Adapter();
+ }
+
+ @Override
+ protected DataSource createDataSource(final String repoName)
+ {
+ if (currentRepoName != null && !repoName.equals(currentRepoName))
+ {
+ throw new IllegalStateException("This test config only supports a single repository"); //$NON-NLS-1$
+ }
+
+ currentRepoName = repoName;
+
+ DB2SchemaDatasource dataSource = new DB2SchemaDatasource(DB_SCHEMA);
+ dataSource.setDatabaseName(DB_NAME);
+ dataSource.setUser(DB_USER);
+ dataSource.setPassword(DB_PASSWORD);
+
+ if (!isRestarting())
+ {
+ initAllTables(dataSource);
+ }
+
+ return dataSource;
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ currentRepoName = null;
+ super.tearDown();
+ }
+
+ private static void initAllTables(DataSource dataSource)
+ {
+ Connection conn = null;
+ Statement statement = null;
+ String sql = null;
+
+ try
+ {
+ conn = dataSource.getConnection();
+ List<String> tableNames = DBUtil.getAllTableNames(conn, DB_SCHEMA);
+ if (tableCounter != 0)
+ {
+ if (tableCounter < tableNames.size())
+ {
+ dropCounter = 20;
+ }
+ }
+
+ tableCounter = tableNames.size();
+
+ boolean drop = false;
+ if (dropCounter > 0)
+ {
+ --dropCounter;
+ }
+ else if (dropCounter == 0)
+ {
+ tableCounter = 0;
+ dropCounter = -1;
+ drop = true;
+ }
+
+ statement = conn.createStatement();
+ for (String tableName : tableNames)
+ {
+ sql = (drop ? "DROP TABLE " : "DELETE FROM ") + tableName; //$NON-NLS-1$ //$NON-NLS-2$
+ DBUtil.trace(sql);
+ statement.execute(sql);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex, sql);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ DBUtil.close(conn);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/build.properties b/plugins/org.eclipse.emf.cdo.tests.db/build.properties
index f6c72dd766..65455211eb 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/build.properties
+++ b/plugins/org.eclipse.emf.cdo.tests.db/build.properties
@@ -1,31 +1,31 @@
-# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-bin.includes = .,\
- META-INF/,\
- plugin.properties,\
- copyright.txt,\
- about.html,\
- .options
-jars.compile.order = .
-source.. = src/
-output.. = bin/
-src.includes = about.html,\
- copyright.txt,\
- CDO AllTests (DB2 non-audit).launch,\
- CDO AllTests (Derby).launch,\
- CDO AllTests (H2 audit).launch,\
- CDO AllTests (H2 branching).launch,\
- CDO AllTests (H2 non-audit).launch,\
- CDO AllTests (H2 offline).launch,\
- CDO AllTests (Hsqldb audit).launch,\
- CDO AllTests (Hsqldb non-audit).launch,\
- CDO AllTests (Mysql).launch,\
- CDO AllTests (PostgreSQL non-audit).launch,\
- CDO AllTests (DBStore).launch
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+bin.includes = .,\
+ META-INF/,\
+ plugin.properties,\
+ copyright.txt,\
+ about.html,\
+ .options
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+src.includes = about.html,\
+ copyright.txt,\
+ CDO AllTests (DB2 non-audit).launch,\
+ CDO AllTests (Derby).launch,\
+ CDO AllTests (H2 audit).launch,\
+ CDO AllTests (H2 branching).launch,\
+ CDO AllTests (H2 non-audit).launch,\
+ CDO AllTests (H2 offline).launch,\
+ CDO AllTests (Hsqldb audit).launch,\
+ CDO AllTests (Hsqldb non-audit).launch,\
+ CDO AllTests (Mysql).launch,\
+ CDO AllTests (PostgreSQL non-audit).launch,\
+ CDO AllTests (DBStore).launch
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt b/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
index e921242cf0..8f6328980e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
+++ b/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
Eike Stepper - initial API and implementation \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties b/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
index 42715fec1c..939a2bdd6e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
@@ -1,11 +1,11 @@
-# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-pluginName = CDO Model Repository Tests DB
-providerName = Eclipse Modeling Project
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+pluginName = CDO Model Repository Tests DB
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
index 321a8f37a0..461905ed75 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBDerby extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBDerby().getTestSuite("CDO Tests (DBStore Derby Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE);
- // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBDerby extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBDerby().getTestSuite("CDO Tests (DBStore Derby Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE);
+ // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
index efcbd32649..279f8dc0a4 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - introduced variable mapping strategies
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2All extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2All().getTestSuite("CDO Tests (DBStore H2 All)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenarios(parent, IDGenerationLocation.STORE);
- addScenarios(parent, IDGenerationLocation.CLIENT);
- }
-
- private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- AllTestsDBH2NonAudit.initConfigSuites(this, parent, idGenerationLocation);
- AllTestsDBH2Audit.initConfigSuites(this, parent, idGenerationLocation);
- AllTestsDBH2Branching.initConfigSuites(this, parent, idGenerationLocation);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - introduced variable mapping strategies
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2All extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2All().getTestSuite("CDO Tests (DBStore H2 All)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenarios(parent, IDGenerationLocation.STORE);
+ addScenarios(parent, IDGenerationLocation.CLIENT);
+ }
+
+ private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ AllTestsDBH2NonAudit.initConfigSuites(this, parent, idGenerationLocation);
+ AllTestsDBH2Audit.initConfigSuites(this, parent, idGenerationLocation);
+ AllTestsDBH2Branching.initConfigSuites(this, parent, idGenerationLocation);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java
index 3a9a383c08..dd8bc33e29 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - introduced variable mapping strategies
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2Audit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2Audit().getTestSuite("CDO Tests (DBStore H2 Horizontal)");
- }
-
- public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- suite.addScenario(parent, COMBINED, new H2Config(true, false, false, false, idGenerationLocation), JVM, NATIVE);
- suite.addScenario(parent, COMBINED, new H2Config(true, false, true, false, idGenerationLocation), JVM, NATIVE);
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- initConfigSuites(this, parent, IDGenerationLocation.STORE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - introduced variable mapping strategies
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2Audit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2Audit().getTestSuite("CDO Tests (DBStore H2 Horizontal)");
+ }
+
+ public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ suite.addScenario(parent, COMBINED, new H2Config(true, false, false, false, idGenerationLocation), JVM, NATIVE);
+ suite.addScenario(parent, COMBINED, new H2Config(true, false, true, false, idGenerationLocation), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ initConfigSuites(this, parent, IDGenerationLocation.STORE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java
index d52cf6a9b7..90aad2246d 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2Branching extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2Branching().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode)");
- }
-
- public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- // suite.addScenario(parent, COMBINED, new H2Config(true, true, false, false, idGenerationLocation), JVM, NATIVE);
- suite.addScenario(parent, COMBINED, new H2Config(true, true, true, false, idGenerationLocation), JVM, NATIVE);
- // suite.addScenario(parent, COMBINED, new H2Config(true, true, true, true, idGenerationLocation), JVM, NATIVE);
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- initConfigSuites(this, parent, IDGenerationLocation.STORE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2Branching extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2Branching().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode)");
+ }
+
+ public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ // suite.addScenario(parent, COMBINED, new H2Config(true, true, false, false, idGenerationLocation), JVM, NATIVE);
+ suite.addScenario(parent, COMBINED, new H2Config(true, true, true, false, idGenerationLocation), JVM, NATIVE);
+ // suite.addScenario(parent, COMBINED, new H2Config(true, true, true, true, idGenerationLocation), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ initConfigSuites(this, parent, IDGenerationLocation.STORE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
index ac10daf508..7eb5cc19d1 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2BranchingUUIDs extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2BranchingUUIDs().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode, UUIDs)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2BranchingUUIDs extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2BranchingUUIDs().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode, UUIDs)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
index 7c68782a80..d9c095c535 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2NonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)");
- }
-
- public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- suite.addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE);
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- initConfigSuites(this, parent, IDGenerationLocation.STORE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2NonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)");
+ }
+
+ public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ suite.addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ initConfigSuites(this, parent, IDGenerationLocation.STORE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index f5f207c5ff..91bf077bbd 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_319552_Test;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_328352_Test;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_329014_Test;
-import org.eclipse.emf.cdo.tests.offline.FailoverTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineDelayedTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockRawReplicationTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2Offline extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2Offline().getTestSuite("CDO Tests (DBStore H2 Horizontal - offline mode)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new H2OfflineConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- addScenario(parent, COMBINED, new H2OfflineConfig(false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
- addScenario(parent, COMBINED, new H2OfflineConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.add(OfflineTest.class);
- testClasses.add(OfflineRawTest.class);
- testClasses.add(OfflineDelayedTest.class);
- testClasses.add(OfflineLockingTest.class);
- testClasses.add(OfflineLockReplicationTest.class);
- testClasses.add(OfflineLockRawReplicationTest.class);
-
- testClasses.add(Bugzilla_329014_Test.class);
- testClasses.add(Bugzilla_328352_Test.class);
- testClasses.add(Bugzilla_326047_Test.class);
- testClasses.add(Bugzilla_325097_Test.class);
- testClasses.add(Bugzilla_319552_Test.class);
- testClasses.add(Bugzilla_351078_DB_Test.class);
-
- testClasses.add(FailoverTest.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_319552_Test;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_328352_Test;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_329014_Test;
+import org.eclipse.emf.cdo.tests.offline.FailoverTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineDelayedTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineLockRawReplicationTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2Offline extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2Offline().getTestSuite("CDO Tests (DBStore H2 Horizontal - offline mode)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new H2OfflineConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ addScenario(parent, COMBINED, new H2OfflineConfig(false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
+ addScenario(parent, COMBINED, new H2OfflineConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(OfflineTest.class);
+ testClasses.add(OfflineRawTest.class);
+ testClasses.add(OfflineDelayedTest.class);
+ testClasses.add(OfflineLockingTest.class);
+ testClasses.add(OfflineLockReplicationTest.class);
+ testClasses.add(OfflineLockRawReplicationTest.class);
+
+ testClasses.add(Bugzilla_329014_Test.class);
+ testClasses.add(Bugzilla_328352_Test.class);
+ testClasses.add(Bugzilla_326047_Test.class);
+ testClasses.add(Bugzilla_325097_Test.class);
+ testClasses.add(Bugzilla_319552_Test.class);
+ testClasses.add(Bugzilla_351078_DB_Test.class);
+
+ testClasses.add(FailoverTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
index 1c87676fd7..b5e9d56501 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBHsqldb extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBHsqldb().getTestSuite("CDO Tests (DBStore Hsql Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- super.initTestClasses(testClasses, scenario);
-
- // this takes ages ...
- testClasses.remove(Bugzilla_266982_Test.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBHsqldb extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBHsqldb().getTestSuite("CDO Tests (DBStore Hsql Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ super.initTestClasses(testClasses, scenario);
+
+ // this takes ages ...
+ testClasses.remove(Bugzilla_266982_Test.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
index 14667570e7..6a5019ddb9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Stefan Winkler
- */
-public class AllTestsDBHsqldbNonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBHsqldbNonAudit().getTestSuite("CDO Tests (DBStore Hsql Horizontal Non-audit)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- super.initTestClasses(testClasses, scenario);
-
- // this takes ages - so for now, we disable it
- testClasses.remove(Bugzilla_261218_Test.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Stefan Winkler
+ */
+public class AllTestsDBHsqldbNonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBHsqldbNonAudit().getTestSuite("CDO Tests (DBStore Hsql Horizontal Non-audit)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ super.initTestClasses(testClasses, scenario);
+
+ // this takes ages - so for now, we disable it
+ testClasses.remove(Bugzilla_261218_Test.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
index 26fc22a6c0..a5ade788be 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
-import org.eclipse.emf.cdo.tests.BranchingTest;
-import org.eclipse.emf.cdo.tests.MergingTest;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Simon McDuff
- */
-public class AllTestsDBMysql extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- // add branching tests for this testsuite
- testClasses.add(BranchingTest.class);
- testClasses.add(BranchingSameSessionTest.class);
- testClasses.add(MergingTest.class);
-
- super.initTestClasses(testClasses, scenario);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
+import org.eclipse.emf.cdo.tests.BranchingTest;
+import org.eclipse.emf.cdo.tests.MergingTest;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Simon McDuff
+ */
+public class AllTestsDBMysql extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ // add branching tests for this testsuite
+ testClasses.add(BranchingTest.class);
+ testClasses.add(BranchingSameSessionTest.class);
+ testClasses.add(MergingTest.class);
+
+ super.initTestClasses(testClasses, scenario);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
index 54dd17aa0e..a4c84fa042 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- * Stefan Winkler - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Database preparation before test execution:
- * <ol>
- * <li>create user sa (pass: sa)
- * <li>create databases cdodb1, authrepo, repo2
- * </ol>
- * Database creation/removal is avoided because it takes too long and makes the test-suite impractical.
- *
- * @author Victor Roldan Betancort
- */
-public class AllTestsDBPsql extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBPsql().getTestSuite("CDO Tests (DBStore PSQL Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ * Stefan Winkler - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Database preparation before test execution:
+ * <ol>
+ * <li>create user sa (pass: sa)
+ * <li>create databases cdodb1, authrepo, repo2
+ * </ol>
+ * Database creation/removal is avoided because it takes too long and makes the test-suite impractical.
+ *
+ * @author Victor Roldan Betancort
+ */
+public class AllTestsDBPsql extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBPsql().getTestSuite("CDO Tests (DBStore PSQL Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
index 9e8aa34abb..b8405b446c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
@@ -1,32 +1,32 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AutomatedTests
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite(AutomatedTests.class.getName());
- suite.addTest(AllTestsDBH2NonAudit.suite());
- suite.addTest(AllTestsDBH2Audit.suite());
- suite.addTest(AllTestsDBH2Branching.suite());
- // suite.addTest(AllTestsDBH2Offline.suite());
- // suite.addTest(AllTestsDBHsqldb.suite());
- // suite.addTest(AllTestsDBHsqldbNonAudit.suite());
- return suite;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AutomatedTests
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite(AutomatedTests.class.getName());
+ suite.addTest(AllTestsDBH2NonAudit.suite());
+ suite.addTest(AllTestsDBH2Audit.suite());
+ suite.addTest(AllTestsDBH2Branching.suite());
+ // suite.addTest(AllTestsDBH2Offline.suite());
+ // suite.addTest(AllTestsDBHsqldb.suite());
+ // suite.addTest(AllTestsDBHsqldbNonAudit.suite());
+ return suite;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
index 3d3499e20f..d8ed821cce 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
index 2a757fa0bc..3ac92291b9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
@@ -1,162 +1,162 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping;
-import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMappingFactory;
-import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * @author Stefan Winkler
- */
-public class CustomTypeMappingTest extends AbstractCDOTest
-{
-
- public void testCustomTypeMapping() throws CommitException
- {
- // manually register type mapping
- MyIntToVarcharTypeMapping.Factory factory = new MyIntToVarcharTypeMapping.Factory();
- IPluginContainer.INSTANCE.registerFactory(factory);
-
- try
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest2", "uct2",
- "http://cdo.eclipse.org/tests/underscoreTest2.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "bar", EcorePackage.eINSTANCE.getEInt());
-
- // annotate type mapping and column type
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
- annotation.getDetails().put("columnType", DBType.VARCHAR.getKeyword());
- att.getEAnnotations().add(annotation);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject obj = EcoreUtil.create(cls);
- obj.eSet(att, 42);
-
- resource.getContents().add(obj);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if type was mapped to string...");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- Statement stmt = null;
- ResultSet rset = null;
- try
- {
- stmt = getStatement();
- rset = stmt.executeQuery("SELECT bar FROM underscoreTest2_foo");
- assertEquals("java.lang.String", rset.getMetaData().getColumnClassName(1));
-
- rset.next();
- assertEquals("2a", rset.getString(1));
- }
- finally
- {
- DBUtil.close(rset);
- DBUtil.close(stmt);
- }
- }
- }.verify();
- }
- finally
- {
- IPluginContainer.INSTANCE.getFactoryRegistry().remove(factory.getKey());
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class MyIntToVarcharTypeMapping extends AbstractTypeMapping
- {
- public static final ITypeMapping.Descriptor DESCRIPTOR = TypeMappingUtil.createDescriptor(
- "org.eclipse.emf.cdo.tests.db.EIntToVarchar", EcorePackage.eINSTANCE.getEInt(), DBType.VARCHAR);
-
- public MyIntToVarcharTypeMapping()
- {
- }
-
- @Override
- protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
- {
- Integer val = (Integer)value;
- stmt.setString(index, Integer.toHexString(val));
- }
-
- @Override
- protected Object getResultSetValue(ResultSet resultSet) throws SQLException
- {
- String stringVal = resultSet.getString(getField().getName());
- return Integer.parseInt(stringVal, 16);
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class Factory extends AbstractTypeMappingFactory
- {
- public Factory()
- {
- super(DESCRIPTOR);
- }
-
- @Override
- public ITypeMapping create(String description)
- {
- return new MyIntToVarcharTypeMapping();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping;
+import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMappingFactory;
+import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author Stefan Winkler
+ */
+public class CustomTypeMappingTest extends AbstractCDOTest
+{
+
+ public void testCustomTypeMapping() throws CommitException
+ {
+ // manually register type mapping
+ MyIntToVarcharTypeMapping.Factory factory = new MyIntToVarcharTypeMapping.Factory();
+ IPluginContainer.INSTANCE.registerFactory(factory);
+
+ try
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest2", "uct2",
+ "http://cdo.eclipse.org/tests/underscoreTest2.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "bar", EcorePackage.eINSTANCE.getEInt());
+
+ // annotate type mapping and column type
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
+ annotation.getDetails().put("columnType", DBType.VARCHAR.getKeyword());
+ att.getEAnnotations().add(annotation);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject obj = EcoreUtil.create(cls);
+ obj.eSet(att, 42);
+
+ resource.getContents().add(obj);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if type was mapped to string...");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ Statement stmt = null;
+ ResultSet rset = null;
+ try
+ {
+ stmt = getStatement();
+ rset = stmt.executeQuery("SELECT bar FROM underscoreTest2_foo");
+ assertEquals("java.lang.String", rset.getMetaData().getColumnClassName(1));
+
+ rset.next();
+ assertEquals("2a", rset.getString(1));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ DBUtil.close(stmt);
+ }
+ }
+ }.verify();
+ }
+ finally
+ {
+ IPluginContainer.INSTANCE.getFactoryRegistry().remove(factory.getKey());
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class MyIntToVarcharTypeMapping extends AbstractTypeMapping
+ {
+ public static final ITypeMapping.Descriptor DESCRIPTOR = TypeMappingUtil.createDescriptor(
+ "org.eclipse.emf.cdo.tests.db.EIntToVarchar", EcorePackage.eINSTANCE.getEInt(), DBType.VARCHAR);
+
+ public MyIntToVarcharTypeMapping()
+ {
+ }
+
+ @Override
+ protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
+ {
+ Integer val = (Integer)value;
+ stmt.setString(index, Integer.toHexString(val));
+ }
+
+ @Override
+ protected Object getResultSetValue(ResultSet resultSet) throws SQLException
+ {
+ String stringVal = resultSet.getString(getField().getName());
+ return Integer.parseInt(stringVal, 16);
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class Factory extends AbstractTypeMappingFactory
+ {
+ public Factory()
+ {
+ super(DESCRIPTOR);
+ }
+
+ @Override
+ public ITypeMapping create(String description)
+ {
+ return new MyIntToVarcharTypeMapping();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
index 023b9845cb..338b609056 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
@@ -1,493 +1,493 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Kai Schlamp - initial API and implementation
- * Eike Stepper - maintenance
- * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
-import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.db.DBUtil;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.sql.ResultSet;
-
-/**
- * Test different DB annotations.
- *
- * @author Kai Schlamp
- */
-// XXX PSQL fails, too - need to investigate
-@Skips("Postgresql")
-public class DBAnnotationsTest extends AbstractCDOTest
-{
- private static int modelCounter;
-
- public void testLengthAnnotationPositive() throws Exception
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product that has a name with an allowed string length.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- product.eSet(eClass.getEStructuralFeature("name"), "01234567");
-
- resource.getContents().add(product);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- // HSQL does not support length annotations
- @Skips("Hsqldb")
- public void testLengthAnnotationNegative() throws Exception
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product that has a name with an invalid string length.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- product.eSet(eClass.getEStructuralFeature("name"), "012345678");
-
- resource.getContents().add(product);
-
- try
- {
- transaction.commit();
- fail("Committing too long data did not result in an exception");
- }
- catch (Exception success)
- {
- }
- finally
- {
- transaction.close();
- session.close();
- }
- }
-
- public void testLengthAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- resource.getContents().add(product);
-
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if column size was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_PRODUCT1";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
-
- try
- {
- rset.next();
- assertEquals("8", rset.getString(7));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- // HSQL does not support type annotations
- @Skips("Hsqldb")
- public void testTypeAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addTypeAnnotation(model1, "CLOB");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if column type was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
-
- try
- {
- rset.next();
- assertEquals("CLOB", rset.getString(6));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testTableNameAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addTableNameAnnotation(model1, "Subject");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- ResultSet rset = getMetaData().getTables(null, null, "SUBJECT", null);
-
- try
- {
- rset.next();
- assertEquals("SUBJECT", rset.getString(3));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testColumnNameAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addColumnNameAnnotation(model1, "TOPIC");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
-
- try
- {
- rset.next();
- assertEquals("TOPIC", rset.getString(4));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- // HSQL does not support type annotations
- @Skips("Hsqldb")
- public void testColumnNameTypeAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addColumnNameAndTypeAnnoation(model1, "TOPIC", "CLOB");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
-
- try
- {
- rset.next();
- assertEquals("TOPIC", rset.getString(4));
- assertEquals("CLOB", rset.getString(6));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testTableMappingAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addTableMappingAnnotation(model1, "OrderDetail", "Company");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- ResultSet rset = getMetaData().getTables(null, null, null, null);
-
- try
- {
- boolean orderDetailTableCreated = false;
- boolean companyTableCreated = false;
- boolean categoryTableCreated = false;
-
- String prefix = model1.getName().toUpperCase() + '_';
- while (rset.next())
- {
- String tableName = rset.getString(3);
- if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
- {
- orderDetailTableCreated = true;
- }
- else if ((prefix + "COMPANY").equalsIgnoreCase(tableName))
- {
- companyTableCreated = true;
- }
- else if ((prefix + "CATEGORY").equalsIgnoreCase(tableName))
- {
- categoryTableCreated = true;
- }
- }
-
- assertEquals(false, orderDetailTableCreated);
- assertEquals(false, companyTableCreated);
- assertEquals(true, categoryTableCreated);
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- private EPackage createModel()
- {
- EPackage ePackage = EcoreUtil.copy(getModel1Package());
- String suffix = "_dynamic" + modelCounter++;
- ePackage.setNsURI(ePackage.getNsURI() + suffix);
- ePackage.setName(ePackage.getName() + suffix);
- return ePackage;
- }
-
- private void addLengthAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnLength", value);
-
- EClass product1 = (EClass)model1.getEClassifier("Product1");
- EStructuralFeature element = product1.getEStructuralFeature(Model1Package.PRODUCT1__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTypeAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnType", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTableNameAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("tableName", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- category.getEAnnotations().add(annotation);
- }
-
- private void addColumnNameAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnName", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addColumnNameAndTypeAnnoation(EPackage model1, String name, String type)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnName", name);
- annotation.getDetails().put("columnType", type);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTableMappingAnnotation(EPackage model1, String... unmappedTables)
- {
- for (String unmappedTable : unmappedTables)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("tableMapping", "NONE");
-
- // ID is defined in plugin.xml
- annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
-
- EClass orderDetail = (EClass)model1.getEClassifier(unmappedTable);
- orderDetail.getEAnnotations().add(annotation);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kai Schlamp - initial API and implementation
+ * Eike Stepper - maintenance
+ * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
+import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.db.DBUtil;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.sql.ResultSet;
+
+/**
+ * Test different DB annotations.
+ *
+ * @author Kai Schlamp
+ */
+// XXX PSQL fails, too - need to investigate
+@Skips("Postgresql")
+public class DBAnnotationsTest extends AbstractCDOTest
+{
+ private static int modelCounter;
+
+ public void testLengthAnnotationPositive() throws Exception
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product that has a name with an allowed string length.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ product.eSet(eClass.getEStructuralFeature("name"), "01234567");
+
+ resource.getContents().add(product);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ // HSQL does not support length annotations
+ @Skips("Hsqldb")
+ public void testLengthAnnotationNegative() throws Exception
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product that has a name with an invalid string length.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ product.eSet(eClass.getEStructuralFeature("name"), "012345678");
+
+ resource.getContents().add(product);
+
+ try
+ {
+ transaction.commit();
+ fail("Committing too long data did not result in an exception");
+ }
+ catch (Exception success)
+ {
+ }
+ finally
+ {
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testLengthAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ resource.getContents().add(product);
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if column size was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_PRODUCT1";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
+
+ try
+ {
+ rset.next();
+ assertEquals("8", rset.getString(7));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ // HSQL does not support type annotations
+ @Skips("Hsqldb")
+ public void testTypeAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addTypeAnnotation(model1, "CLOB");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if column type was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
+
+ try
+ {
+ rset.next();
+ assertEquals("CLOB", rset.getString(6));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testTableNameAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addTableNameAnnotation(model1, "Subject");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ ResultSet rset = getMetaData().getTables(null, null, "SUBJECT", null);
+
+ try
+ {
+ rset.next();
+ assertEquals("SUBJECT", rset.getString(3));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testColumnNameAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addColumnNameAnnotation(model1, "TOPIC");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
+
+ try
+ {
+ rset.next();
+ assertEquals("TOPIC", rset.getString(4));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ // HSQL does not support type annotations
+ @Skips("Hsqldb")
+ public void testColumnNameTypeAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addColumnNameAndTypeAnnoation(model1, "TOPIC", "CLOB");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
+
+ try
+ {
+ rset.next();
+ assertEquals("TOPIC", rset.getString(4));
+ assertEquals("CLOB", rset.getString(6));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testTableMappingAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addTableMappingAnnotation(model1, "OrderDetail", "Company");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ ResultSet rset = getMetaData().getTables(null, null, null, null);
+
+ try
+ {
+ boolean orderDetailTableCreated = false;
+ boolean companyTableCreated = false;
+ boolean categoryTableCreated = false;
+
+ String prefix = model1.getName().toUpperCase() + '_';
+ while (rset.next())
+ {
+ String tableName = rset.getString(3);
+ if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
+ {
+ orderDetailTableCreated = true;
+ }
+ else if ((prefix + "COMPANY").equalsIgnoreCase(tableName))
+ {
+ companyTableCreated = true;
+ }
+ else if ((prefix + "CATEGORY").equalsIgnoreCase(tableName))
+ {
+ categoryTableCreated = true;
+ }
+ }
+
+ assertEquals(false, orderDetailTableCreated);
+ assertEquals(false, companyTableCreated);
+ assertEquals(true, categoryTableCreated);
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ private EPackage createModel()
+ {
+ EPackage ePackage = EcoreUtil.copy(getModel1Package());
+ String suffix = "_dynamic" + modelCounter++;
+ ePackage.setNsURI(ePackage.getNsURI() + suffix);
+ ePackage.setName(ePackage.getName() + suffix);
+ return ePackage;
+ }
+
+ private void addLengthAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnLength", value);
+
+ EClass product1 = (EClass)model1.getEClassifier("Product1");
+ EStructuralFeature element = product1.getEStructuralFeature(Model1Package.PRODUCT1__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTypeAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnType", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTableNameAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("tableName", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ category.getEAnnotations().add(annotation);
+ }
+
+ private void addColumnNameAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnName", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addColumnNameAndTypeAnnoation(EPackage model1, String name, String type)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnName", name);
+ annotation.getDetails().put("columnType", type);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTableMappingAnnotation(EPackage model1, String... unmappedTables)
+ {
+ for (String unmappedTable : unmappedTables)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("tableMapping", "NONE");
+
+ // ID is defined in plugin.xml
+ annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
+
+ EClass orderDetail = (EClass)model1.getEClassifier(unmappedTable);
+ orderDetail.getEAnnotations().add(annotation);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
index 707a63ac65..0a502f8609 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
@@ -1,139 +1,139 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.db.CDODBUtil;
-import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingRegistry;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import javax.sql.DataSource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DBConfig extends RepositoryConfig
-{
- public static final String CAPABILITY_RANGES = "DB.ranges";
-
- public static final String CAPABILITY_COPY_ON_BRANCH = "DB.copy.on.branch";
-
- private static final long serialVersionUID = 1L;
-
- private boolean withRanges;
-
- private boolean copyOnBranch;
-
- public DBConfig(String name, boolean supportingAudits, boolean supportingBranches, boolean withRanges,
- boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
- {
- super(name, supportingAudits, supportingBranches, idGenerationLocation);
- this.withRanges = withRanges;
- this.copyOnBranch = copyOnBranch;
- }
-
- @Override
- public void initCapabilities(Set<String> capabilities)
- {
- super.initCapabilities(capabilities);
- capabilities.add(getDBAdapterName());
-
- if (isWithRanges())
- {
- capabilities.add(CAPABILITY_RANGES);
- }
-
- if (isCopyOnBranch())
- {
- capabilities.add(CAPABILITY_COPY_ON_BRANCH);
- }
- }
-
- protected abstract String getDBAdapterName();
-
- @Override
- protected String getStoreName()
- {
- return "DB";
- }
-
- public boolean isWithRanges()
- {
- return withRanges;
- }
-
- public boolean isCopyOnBranch()
- {
- return copyOnBranch;
- }
-
- @Override
- public void setUp() throws Exception
- {
- CDODBUtil.prepareContainer(IPluginContainer.INSTANCE);
- super.setUp();
- ((TypeMappingRegistry)ITypeMapping.Registry.INSTANCE).init();
- }
-
- @Override
- protected boolean isOptimizing()
- {
- return true;
- }
-
- public IStore createStore(String repoName)
- {
- IMappingStrategy mappingStrategy = createMappingStrategy();
- mappingStrategy.setProperties(createMappingStrategyProperties());
-
- IDBAdapter dbAdapter = createDBAdapter();
-
- DataSource dataSource = createDataSource(repoName);
- IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
-
- return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider);
- }
-
- protected Map<String, String> createMappingStrategyProperties()
- {
- Map<String, String> props = new HashMap<String, String>();
- props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
- props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch));
- return props;
- }
-
- protected IMappingStrategy createMappingStrategy()
- {
- return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges);
- }
-
- @Override
- protected String getMappingStrategySpecialization()
- {
- return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : "");
- }
-
- protected abstract IDBAdapter createDBAdapter();
-
- protected abstract DataSource createDataSource(String repoName);
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingRegistry;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import javax.sql.DataSource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBConfig extends RepositoryConfig
+{
+ public static final String CAPABILITY_RANGES = "DB.ranges";
+
+ public static final String CAPABILITY_COPY_ON_BRANCH = "DB.copy.on.branch";
+
+ private static final long serialVersionUID = 1L;
+
+ private boolean withRanges;
+
+ private boolean copyOnBranch;
+
+ public DBConfig(String name, boolean supportingAudits, boolean supportingBranches, boolean withRanges,
+ boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
+ {
+ super(name, supportingAudits, supportingBranches, idGenerationLocation);
+ this.withRanges = withRanges;
+ this.copyOnBranch = copyOnBranch;
+ }
+
+ @Override
+ public void initCapabilities(Set<String> capabilities)
+ {
+ super.initCapabilities(capabilities);
+ capabilities.add(getDBAdapterName());
+
+ if (isWithRanges())
+ {
+ capabilities.add(CAPABILITY_RANGES);
+ }
+
+ if (isCopyOnBranch())
+ {
+ capabilities.add(CAPABILITY_COPY_ON_BRANCH);
+ }
+ }
+
+ protected abstract String getDBAdapterName();
+
+ @Override
+ protected String getStoreName()
+ {
+ return "DB";
+ }
+
+ public boolean isWithRanges()
+ {
+ return withRanges;
+ }
+
+ public boolean isCopyOnBranch()
+ {
+ return copyOnBranch;
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ CDODBUtil.prepareContainer(IPluginContainer.INSTANCE);
+ super.setUp();
+ ((TypeMappingRegistry)ITypeMapping.Registry.INSTANCE).init();
+ }
+
+ @Override
+ protected boolean isOptimizing()
+ {
+ return true;
+ }
+
+ public IStore createStore(String repoName)
+ {
+ IMappingStrategy mappingStrategy = createMappingStrategy();
+ mappingStrategy.setProperties(createMappingStrategyProperties());
+
+ IDBAdapter dbAdapter = createDBAdapter();
+
+ DataSource dataSource = createDataSource(repoName);
+ IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
+
+ return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider);
+ }
+
+ protected Map<String, String> createMappingStrategyProperties()
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
+ props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch));
+ return props;
+ }
+
+ protected IMappingStrategy createMappingStrategy()
+ {
+ return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges);
+ }
+
+ @Override
+ protected String getMappingStrategySpecialization()
+ {
+ return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : "");
+ }
+
+ protected abstract IDBAdapter createDBAdapter();
+
+ protected abstract DataSource createDataSource(String repoName);
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
index e4649e53f8..99485349f0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.tests.AllConfigs;
-import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
-import org.eclipse.emf.cdo.tests.AuditTest;
-import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
-import org.eclipse.emf.cdo.tests.BranchingTest;
-import org.eclipse.emf.cdo.tests.MEMStoreQueryTest;
-import org.eclipse.emf.cdo.tests.MergingTest;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DBConfigs extends AllConfigs
-{
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.add(Net4jDBTest.class);
- testClasses.add(DBAnnotationsTest.class);
- testClasses.add(DBStoreTest.class);
- testClasses.add(CustomTypeMappingTest.class);
- testClasses.add(SQLQueryTest.class);
-
- super.initTestClasses(testClasses, scenario);
- testClasses.remove(MEMStoreQueryTest.class);
-
- if (!scenario.getRepositoryConfig().isSupportingBranches())
- {
- testClasses.remove(BranchingTest.class);
- testClasses.remove(BranchingSameSessionTest.class);
- testClasses.remove(MergingTest.class);
- testClasses.remove(Bugzilla_303807_Test.class);
- }
-
- if (!scenario.getRepositoryConfig().isSupportingAudits())
- {
- // non-audit mode - remove audit tests
- testClasses.remove(AuditTest.class);
- testClasses.remove(AuditSameSessionTest.class);
- testClasses.remove(Bugzilla_252214_Test.class);
- }
-
- // // fails because of Bug 284109
- // testClasses.remove(XATransactionTest.class);
- // testClasses.add(DISABLE_XATransactionTest.class);
-
- // XXX Range-based audit mapping does not support queryXRefs for now
- // testClasses.remove(XRefTest.class);
- // testClasses.add(DISABLE_XRefTest.class);
-
- // ------------ tests below only fail for PostgreSQL
- // ------------ therefore they are overridden and
- // ------------ skipConfig for PSQL is used temporarily
-
- // // XXX [PSQL] disabled because of Bug 289445
- // testClasses.remove(AttributeTest.class);
- // testClasses.add(DISABLE_AttributeTest.class);
-
- // testClasses.remove(FeatureMapTest.class);
- // testClasses.add(DISABLE_FeatureMapTest.class);
-
- // XXX [PSQL] disabled because of Bug 290095
- // using skipconfig in DBAnnotationTest
-
- // // XXX [PSQL] disabled because of Bug 290097
- // testClasses.remove(ExternalReferenceTest.class);
- // testClasses.add(DISABLE_ExternalReferenceTest.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.tests.AllConfigs;
+import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
+import org.eclipse.emf.cdo.tests.AuditTest;
+import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
+import org.eclipse.emf.cdo.tests.BranchingTest;
+import org.eclipse.emf.cdo.tests.MEMStoreQueryTest;
+import org.eclipse.emf.cdo.tests.MergingTest;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBConfigs extends AllConfigs
+{
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(Net4jDBTest.class);
+ testClasses.add(DBAnnotationsTest.class);
+ testClasses.add(DBStoreTest.class);
+ testClasses.add(CustomTypeMappingTest.class);
+ testClasses.add(SQLQueryTest.class);
+
+ super.initTestClasses(testClasses, scenario);
+ testClasses.remove(MEMStoreQueryTest.class);
+
+ if (!scenario.getRepositoryConfig().isSupportingBranches())
+ {
+ testClasses.remove(BranchingTest.class);
+ testClasses.remove(BranchingSameSessionTest.class);
+ testClasses.remove(MergingTest.class);
+ testClasses.remove(Bugzilla_303807_Test.class);
+ }
+
+ if (!scenario.getRepositoryConfig().isSupportingAudits())
+ {
+ // non-audit mode - remove audit tests
+ testClasses.remove(AuditTest.class);
+ testClasses.remove(AuditSameSessionTest.class);
+ testClasses.remove(Bugzilla_252214_Test.class);
+ }
+
+ // // fails because of Bug 284109
+ // testClasses.remove(XATransactionTest.class);
+ // testClasses.add(DISABLE_XATransactionTest.class);
+
+ // XXX Range-based audit mapping does not support queryXRefs for now
+ // testClasses.remove(XRefTest.class);
+ // testClasses.add(DISABLE_XRefTest.class);
+
+ // ------------ tests below only fail for PostgreSQL
+ // ------------ therefore they are overridden and
+ // ------------ skipConfig for PSQL is used temporarily
+
+ // // XXX [PSQL] disabled because of Bug 289445
+ // testClasses.remove(AttributeTest.class);
+ // testClasses.add(DISABLE_AttributeTest.class);
+
+ // testClasses.remove(FeatureMapTest.class);
+ // testClasses.add(DISABLE_FeatureMapTest.class);
+
+ // XXX [PSQL] disabled because of Bug 290095
+ // using skipconfig in DBAnnotationTest
+
+ // // XXX [PSQL] disabled because of Bug 290097
+ // testClasses.remove(ExternalReferenceTest.class);
+ // testClasses.add(DISABLE_ExternalReferenceTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
index 1f018439f7..a582f46d14 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
@@ -1,326 +1,326 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.GregorianCalendar;
-
-/**
- * @author Stefan Winkler
- */
-public class DBStoreTest extends AbstractCDOTest
-{
- // Bug 256462
- public void testInsertNull() throws Exception
- {
- CDOSession s = openSession();
- CDOTransaction t = s.openTransaction();
- CDOResource r = t.createResource(getResourcePath("/dbStoreTest"));
-
- Company c = Model1Factory.eINSTANCE.createCompany();
- c.setName(null);
- r.getContents().add(c);
-
- t.commit();
- }
-
- public void testStoreStringTrailingBackslash()
- {
- storeRetrieve("foobar\\");
- }
-
- public void testStoreStringContainingBackslash()
- {
- storeRetrieve("foo\\bar");
- }
-
- public void testStoreStringTrailingSingleQuote()
- {
- storeRetrieve("foobar'");
- }
-
- public void testStoreStringContainingSingleQuote()
- {
- storeRetrieve("foo'bar");
- }
-
- public void testStoreStringTrailingDoubleQuote()
- {
- storeRetrieve("foobar\"");
- }
-
- public void testStoreStringContainingDoubleQuote()
- {
- storeRetrieve("foo\"bar");
- }
-
- public void testStoreStringTrailingTwoSingleQuote()
- {
- storeRetrieve("foobar''");
- }
-
- public void testStoreStringContainingTwoSingleQuote()
- {
- storeRetrieve("foo''bar");
- }
-
- // Bug 217255
- public void testStoreDate() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
-
- PurchaseOrder o = Model1Factory.eINSTANCE.createPurchaseOrder();
- o.setDate(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime());
-
- resource.getContents().add(o);
- transaction.commit();
-
- transaction.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(1, resource.getContents().size());
- o = (PurchaseOrder)resource.getContents().get(0);
- assertEquals(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime(), o.getDate());
- }
-
- public void testStoreCustom() throws CommitException
- {
- EPackage pkg = EMFUtil.createEPackage("customTest", "ct", "http://tests.cdo.emf.eclipse.org/customTest");
-
- EDataType dt = EcoreFactory.eINSTANCE.createEDataType();
- dt.setName("custom");
- dt.setInstanceClass(Custom.class);
- pkg.getEClassifiers().add(dt);
-
- EClass clz = EMFUtil.createEClass(pkg, "customClass", false, false);
- EAttribute att = EMFUtil.createEAttribute(clz, "customAtt", dt);
-
- Custom cust1 = new Custom(2, 5);
- Custom cust1ref = new Custom(2, 5);
- Custom cust2 = new Custom(5, 2);
- Custom cust2ref = new Custom(5, 2);
-
- assertEquals(cust1ref, cust1);
- assertEquals(cust2ref, cust2);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- {
- EObject obj1 = EcoreUtil.create(clz);
- EObject obj2 = EcoreUtil.create(clz);
-
- obj1.eSet(att, cust1);
- obj2.eSet(att, cust2);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- resource.getContents().add(obj1);
- resource.getContents().add(obj2);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(2, resource.getContents().size());
-
- EObject obj1 = resource.getContents().get(0);
- EObject obj2 = resource.getContents().get(1);
-
- assertEquals(cust1ref, obj1.eGet(att));
- assertEquals(cust2ref, obj2.eGet(att));
-
- view.close();
- session.close();
- }
-
- }
-
- public static class Custom
- {
- private int first;
-
- private int second;
-
- public Custom(String emfString)
- {
- int sep = emfString.indexOf('!');
- first = Integer.parseInt(emfString.substring(0, sep));
- second = Integer.parseInt(emfString.substring(sep + 1));
- }
-
- public Custom(int first, int second)
- {
- this.first = first;
- this.second = second;
- }
-
- public int getFirst()
- {
- return first;
- }
-
- public int getSecond()
- {
- return second;
- }
-
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof Custom)
- {
- return first == ((Custom)other).first && second == ((Custom)other).second;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return (first + 3 * second) % 65536;
- }
-
- // -------------------------------------------
- // - EMF String serialization
- @Override
- public String toString()
- {
- return Integer.valueOf(first) + "!" + Integer.valueOf(second);
- }
-
- public static Custom valueOf(String s)
- {
- return new Custom(s);
- }
- }
-
- private void storeRetrieve(String s)
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
-
- Company e = Model1Factory.eINSTANCE.createCompany();
- e.setName(s);
- // this escapes only the string!
- // resulting string only contains one backslash
-
- resource.getContents().add(e);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(1, resource.getContents().size());
- e = (Company)resource.getContents().get(0);
- assertEquals(s, e.getName());
- }
-
- public void testUnderscoreFeature() throws Exception
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject foo = EcoreUtil.create(cls);
- foo.eSet(att, "foobar");
- resource.getContents().add(foo);
- transaction.commit();
- session.close();
- }
-
- public void testUnderscoreClass() throws Exception
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject foo = EcoreUtil.create(cls);
- foo.eSet(att, "foobar");
- resource.getContents().add(foo);
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.GregorianCalendar;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DBStoreTest extends AbstractCDOTest
+{
+ // Bug 256462
+ public void testInsertNull() throws Exception
+ {
+ CDOSession s = openSession();
+ CDOTransaction t = s.openTransaction();
+ CDOResource r = t.createResource(getResourcePath("/dbStoreTest"));
+
+ Company c = Model1Factory.eINSTANCE.createCompany();
+ c.setName(null);
+ r.getContents().add(c);
+
+ t.commit();
+ }
+
+ public void testStoreStringTrailingBackslash()
+ {
+ storeRetrieve("foobar\\");
+ }
+
+ public void testStoreStringContainingBackslash()
+ {
+ storeRetrieve("foo\\bar");
+ }
+
+ public void testStoreStringTrailingSingleQuote()
+ {
+ storeRetrieve("foobar'");
+ }
+
+ public void testStoreStringContainingSingleQuote()
+ {
+ storeRetrieve("foo'bar");
+ }
+
+ public void testStoreStringTrailingDoubleQuote()
+ {
+ storeRetrieve("foobar\"");
+ }
+
+ public void testStoreStringContainingDoubleQuote()
+ {
+ storeRetrieve("foo\"bar");
+ }
+
+ public void testStoreStringTrailingTwoSingleQuote()
+ {
+ storeRetrieve("foobar''");
+ }
+
+ public void testStoreStringContainingTwoSingleQuote()
+ {
+ storeRetrieve("foo''bar");
+ }
+
+ // Bug 217255
+ public void testStoreDate() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
+
+ PurchaseOrder o = Model1Factory.eINSTANCE.createPurchaseOrder();
+ o.setDate(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime());
+
+ resource.getContents().add(o);
+ transaction.commit();
+
+ transaction.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(1, resource.getContents().size());
+ o = (PurchaseOrder)resource.getContents().get(0);
+ assertEquals(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime(), o.getDate());
+ }
+
+ public void testStoreCustom() throws CommitException
+ {
+ EPackage pkg = EMFUtil.createEPackage("customTest", "ct", "http://tests.cdo.emf.eclipse.org/customTest");
+
+ EDataType dt = EcoreFactory.eINSTANCE.createEDataType();
+ dt.setName("custom");
+ dt.setInstanceClass(Custom.class);
+ pkg.getEClassifiers().add(dt);
+
+ EClass clz = EMFUtil.createEClass(pkg, "customClass", false, false);
+ EAttribute att = EMFUtil.createEAttribute(clz, "customAtt", dt);
+
+ Custom cust1 = new Custom(2, 5);
+ Custom cust1ref = new Custom(2, 5);
+ Custom cust2 = new Custom(5, 2);
+ Custom cust2ref = new Custom(5, 2);
+
+ assertEquals(cust1ref, cust1);
+ assertEquals(cust2ref, cust2);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ {
+ EObject obj1 = EcoreUtil.create(clz);
+ EObject obj2 = EcoreUtil.create(clz);
+
+ obj1.eSet(att, cust1);
+ obj2.eSet(att, cust2);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ resource.getContents().add(obj1);
+ resource.getContents().add(obj2);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(2, resource.getContents().size());
+
+ EObject obj1 = resource.getContents().get(0);
+ EObject obj2 = resource.getContents().get(1);
+
+ assertEquals(cust1ref, obj1.eGet(att));
+ assertEquals(cust2ref, obj2.eGet(att));
+
+ view.close();
+ session.close();
+ }
+
+ }
+
+ public static class Custom
+ {
+ private int first;
+
+ private int second;
+
+ public Custom(String emfString)
+ {
+ int sep = emfString.indexOf('!');
+ first = Integer.parseInt(emfString.substring(0, sep));
+ second = Integer.parseInt(emfString.substring(sep + 1));
+ }
+
+ public Custom(int first, int second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public int getFirst()
+ {
+ return first;
+ }
+
+ public int getSecond()
+ {
+ return second;
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof Custom)
+ {
+ return first == ((Custom)other).first && second == ((Custom)other).second;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (first + 3 * second) % 65536;
+ }
+
+ // -------------------------------------------
+ // - EMF String serialization
+ @Override
+ public String toString()
+ {
+ return Integer.valueOf(first) + "!" + Integer.valueOf(second);
+ }
+
+ public static Custom valueOf(String s)
+ {
+ return new Custom(s);
+ }
+ }
+
+ private void storeRetrieve(String s)
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
+
+ Company e = Model1Factory.eINSTANCE.createCompany();
+ e.setName(s);
+ // this escapes only the string!
+ // resulting string only contains one backslash
+
+ resource.getContents().add(e);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(1, resource.getContents().size());
+ e = (Company)resource.getContents().get(0);
+ assertEquals(s, e.getName());
+ }
+
+ public void testUnderscoreFeature() throws Exception
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject foo = EcoreUtil.create(cls);
+ foo.eSet(att, "foobar");
+ resource.getContents().add(foo);
+ transaction.commit();
+ session.close();
+ }
+
+ public void testUnderscoreClass() throws Exception
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject foo = EcoreUtil.create(cls);
+ foo.eSet(att, "foobar");
+ resource.getContents().add(foo);
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
index c0ed6d3c3d..2c3aac7b05 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
index e7ae38fa03..c997cb5f47 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
index 7bd0710bce..74b56ba6c5 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
index 27dc52a171..93446d15b9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
index 454a8da1ab..82a25e567f 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
index dda16955cb..914adc40b2 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
@@ -1,713 +1,713 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.server.internal.db.DBStore;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.ddl.IDBSchema;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.GregorianCalendar;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jDBTest extends AbstractCDOTest
-{
- private static final String FIELD_NAME = "testField";
-
- private DBStore store;
-
- private ArrayList<Pair<DBType, Object>> columns = new ArrayList<Pair<DBType, Object>>();
-
- private Connection connection;
-
- public void testBigInt() throws Exception
- {
- registerColumn(DBType.BIGINT, Long.MAX_VALUE);
- registerColumn(DBType.BIGINT, Long.MIN_VALUE);
- registerColumn(DBType.BIGINT, 0L);
- registerColumn(DBType.BIGINT, 42L);
- doTest(getName());
- }
-
- public void testBinary() throws Exception
- {
- registerColumn(DBType.BINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.BINARY, data);
- doTest(getName());
- }
-
- public void testVarBinary() throws Exception
- {
- registerColumn(DBType.VARBINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.VARBINARY, data);
- doTest(getName());
- }
-
- public void testLongVarBinary() throws Exception
- {
- registerColumn(DBType.LONGVARBINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.LONGVARBINARY, data);
- doTest(getName());
- }
-
- public void testBit() throws Exception
- {
- registerColumn(DBType.BIT, true);
- registerColumn(DBType.BIT, false);
- doTest(getName());
- }
-
- public void testBlob() throws Exception
- {
- byte[] data = new byte[1000000];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.BLOB, data);
- doTest(getName());
- }
-
- public void testBlobLength0() throws Exception
- {
- registerColumn(DBType.BLOB, new byte[0]);
- doTest(getName());
- }
-
- public void testBoolean() throws Exception
- {
- registerColumn(DBType.BOOLEAN, true);
- registerColumn(DBType.BOOLEAN, false);
- doTest(getName());
- }
-
- public void testChar() throws Exception
- {
- registerColumn(DBType.CHAR, "0");
- registerColumn(DBType.CHAR, "a");
- registerColumn(DBType.CHAR, "\255"); // Fails for DB2
- registerColumn(DBType.CHAR, "\u1234"); // Fails for DB2
- doTest(getName());
- }
-
- public void testClob() throws Exception
- {
- registerColumn(DBType.CLOB, "Test");
-
- StringBuffer b = new StringBuffer();
- for (int i = 0; i < 1000000; i++)
- {
- b.append("x");
- }
-
- registerColumn(DBType.CLOB, b.toString());
- doTest(getName());
- }
-
- public void testClobLength0() throws Exception
- {
- registerColumn(DBType.CLOB, "");
- doTest(getName());
- }
-
- public void testTinyInt() throws Exception
- {
- registerColumn(DBType.TINYINT, Byte.MAX_VALUE);
- registerColumn(DBType.TINYINT, Byte.MIN_VALUE);
- registerColumn(DBType.TINYINT, new Byte("0"));
- registerColumn(DBType.TINYINT, new Integer(42).byteValue());
- doTest(getName());
- }
-
- public void testSmallInt() throws Exception
- {
- registerColumn(DBType.SMALLINT, Short.MAX_VALUE);
- registerColumn(DBType.SMALLINT, Short.MIN_VALUE);
- registerColumn(DBType.SMALLINT, (short)-1);
- registerColumn(DBType.SMALLINT, (short)5);
- doTest(getName());
- }
-
- public void testInteger() throws Exception
- {
- registerColumn(DBType.INTEGER, Integer.MAX_VALUE);
- registerColumn(DBType.INTEGER, Integer.MIN_VALUE);
- registerColumn(DBType.INTEGER, -1);
- registerColumn(DBType.INTEGER, 5);
- doTest(getName());
- }
-
- public void testFloat() throws Exception
- {
- registerColumn(DBType.FLOAT, Float.MAX_VALUE);
- registerColumn(DBType.FLOAT, Float.MIN_VALUE); // Fails for DB2
- registerColumn(DBType.FLOAT, -.1f);
- registerColumn(DBType.FLOAT, 3.33333f);
- doTest(getName());
- }
-
- public void testReal() throws Exception
- {
- registerColumn(DBType.REAL, Float.MAX_VALUE);
- registerColumn(DBType.REAL, Float.MIN_VALUE); // Fails for DB2
- registerColumn(DBType.REAL, -.1f);
- registerColumn(DBType.REAL, 3.33333f);
- doTest(getName());
- }
-
- public void testDouble() throws Exception
- {
- registerColumn(DBType.DOUBLE, new Double(Double.MAX_VALUE));
- // registerColumn(DBType.DOUBLE, new Double(Double.MIN_VALUE));
- registerColumn(DBType.DOUBLE, -.1d);
- registerColumn(DBType.DOUBLE, 3.33333d);
- doTest(getName());
- }
-
- public void _testNumeric() throws Exception
- {
- String numberLiteral1 = "12345678901234567890123456789012";
- String numberLiteral2 = "10000000000000000000000000000000";
-
- for (int precision = 1; precision < 32; precision++)
- {
- BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
- BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
-
- for (int scale = 0; scale <= precision; scale++)
- {
- BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
- BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
-
- registerColumn(DBType.NUMERIC, numberDecimal1);
- registerColumn(DBType.NUMERIC, numberDecimal2);
-
- doTest(getName() + precision + "_" + scale);
- columns.clear();
- }
- }
- }
-
- public void _testDecimal() throws Exception
- {
- String numberLiteral1 = "12345678901234567890123456789012";
- String numberLiteral2 = "10000000000000000000000000000000";
-
- for (int precision = 1; precision < 32; precision++)
- {
- BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
- BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
-
- for (int scale = 0; scale <= precision; scale++)
- {
- BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
- BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
-
- registerColumn(DBType.DECIMAL, numberDecimal1);
- registerColumn(DBType.DECIMAL, numberDecimal2);
-
- doTest(getName() + precision + "_" + scale);
- columns.clear();
- }
- }
- }
-
- public void testVarChar() throws Exception
- {
- registerColumn(DBType.VARCHAR, "");
- registerColumn(DBType.VARCHAR, "\n");
- registerColumn(DBType.VARCHAR, "\t");
- registerColumn(DBType.VARCHAR, "\r");
- registerColumn(DBType.VARCHAR, "\u1234");
- registerColumn(DBType.VARCHAR, "The quick brown fox jumps over the lazy dog.");
- registerColumn(DBType.VARCHAR, "\\,:\",\'");
-
- doTest(getName());
- }
-
- public void testLongVarChar() throws Exception
- {
- registerColumn(DBType.LONGVARCHAR, "");
- registerColumn(DBType.LONGVARCHAR, "\n");
- registerColumn(DBType.LONGVARCHAR, "\t");
- registerColumn(DBType.LONGVARCHAR, "\r");
- registerColumn(DBType.LONGVARCHAR, "\u1234");
- registerColumn(DBType.LONGVARCHAR, "The quick brown fox jumps over the lazy dog.");
- registerColumn(DBType.LONGVARCHAR, "\\,:\",\'");
-
- doTest(getName());
- }
-
- public void testDate() throws Exception
- {
- registerColumn(DBType.DATE, new GregorianCalendar(2010, 04, 21).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(1950, 04, 21).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(2030, 12, 31).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis()); // Fails for DB2
-
- doTest(getName());
- }
-
- public void testTime() throws Exception
- {
- registerColumn(DBType.TIME, HOURS_toMillis(10));
- registerColumn(DBType.TIME, 0l);
- registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
-
- // Following tests fail on H2 as 24h == 1 day => 0
- //
- // registerColumn(DBType.TIME, HOURS_toMillis(24));
-
- doTest(getName());
- }
-
- public void testTimestamp() throws Exception
- {
- registerColumn(DBType.TIME, HOURS_toMillis(10));
- registerColumn(DBType.TIME, 0l);
- registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
-
- // Following tests fail on H2 as 24h == 1 day => 0
- //
- // registerColumn(DBType.TIME, HOURS_toMillis(24));
-
- doTest(getName());
- }
-
- private void registerColumn(DBType type, Object value)
- {
- Pair<DBType, Object> column = new Pair<DBType, Object>(type, value);
- columns.add(column);
- }
-
- private void prepareTable(String tableName)
- {
- IDBSchema schema = store.getDBSchema();
- IDBTable table = schema.addTable(tableName);
- int c = 0;
-
- for (Pair<DBType, Object> column : columns)
- {
- switch (column.getElement1())
- {
- case NUMERIC:
- case DECIMAL:
- BigDecimal value = (BigDecimal)column.getElement2();
- table.addField(FIELD_NAME + c++, column.getElement1(), value.precision(), value.scale());
- break;
-
- default:
- table.addField(FIELD_NAME + c++, column.getElement1());
- break;
- }
- }
-
- store.getDBAdapter().createTables(Arrays.asList(table), connection);
- }
-
- private void writeValues(String tableName) throws Exception
- {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
-
- boolean first = true;
- StringBuilder builder = new StringBuilder("INSERT INTO " + tableName + " VALUES (");
- for (Pair<DBType, Object> column : columns)
- {
- writeTypeValue(outs, column.getElement1(), column.getElement2());
- if (first)
- {
- builder.append("?");
- first = false;
- }
- else
- {
- builder.append(", ?");
- }
- }
-
- builder.append(")");
- String sql = builder.toString();
-
- outs.close();
- output.flush();
- byte[] buffer = output.toByteArray();
- output.close();
-
- ByteArrayInputStream input = new ByteArrayInputStream(buffer);
- ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
-
- PreparedStatement stmt = connection.prepareStatement(sql);
- int c = 1;
-
- for (Pair<DBType, Object> column : columns)
- {
- column.getElement1().readValueWithResult(ins, stmt, c++, false);
- }
-
- stmt.executeUpdate();
-
- stmt.close();
- ins.close();
- input.close();
- }
-
- private void checkValues(String tableName) throws Exception
- {
- Statement stmt = connection.createStatement();
- ResultSet resultSet = stmt.executeQuery("SELECT * FROM " + tableName);
- assertEquals(true, resultSet.next());
-
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
-
- int c = 1;
- for (Pair<DBType, Object> column : columns)
- {
- column.getElement1().writeValue(outs, resultSet, c++, false);
- }
-
- resultSet.close();
- stmt.close();
-
- outs.close();
- output.flush();
- byte[] buffer = output.toByteArray();
- output.close();
-
- ByteArrayInputStream input = new ByteArrayInputStream(buffer);
- ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
-
- c = 1;
- for (Pair<DBType, Object> column : columns)
- {
- Object actual = readTypeValue(ins, column.getElement1());
- Class<? extends Object> type = column.getElement2().getClass();
- if (type.isArray())
- {
- Class<?> componentType = type.getComponentType();
- if (componentType == byte.class)
- {
- assertEquals("Error in column " + c + " of type " + column.getElement1(), true,
- Arrays.equals((byte[])column.getElement2(), (byte[])actual));
- }
- else if (componentType == char.class)
- {
- assertEquals("Error in column " + c + " with type " + column.getElement1(), true,
- Arrays.equals((char[])column.getElement2(), (char[])actual));
- }
- else
- {
- throw new IllegalStateException("Unexpected component type: " + componentType);
- }
- }
- else
- {
- assertEquals("Error in column " + c + " with type " + column.getElement1(), column.getElement2(), actual);
- }
-
- ++c;
- }
- }
-
- private void doTest(String tableName) throws Exception
- {
- store = (DBStore)getRepository().getStore();
- connection = store.getConnection();
-
- try
- {
- prepareTable(tableName);
- writeValues(tableName);
- checkValues(tableName);
- }
- finally
- {
- try
- {
- connection.commit();
- }
- finally
- {
- DBUtil.close(connection);
- connection = null;
- store = null;
- }
- }
- }
-
- private void writeTypeValue(ExtendedDataOutputStream outs, DBType type, Object value) throws IOException
- {
- switch (type)
- {
- case BOOLEAN:
- case BIT:
- outs.writeBoolean((Boolean)value);
- return;
-
- case TINYINT:
- outs.writeByte((Byte)value);
- return;
-
- case CHAR:
- outs.writeString((String)value);
- return;
-
- case SMALLINT:
- outs.writeShort((Short)value);
- return;
-
- case INTEGER:
- outs.writeInt((Integer)value);
- return;
-
- case FLOAT:
- outs.writeFloat((Float)value);
- return;
-
- case REAL:
- outs.writeFloat((Float)value);
- return;
-
- case DOUBLE:
- outs.writeDouble((Double)value);
- return;
-
- case NUMERIC:
- case DECIMAL:
- {
- BigDecimal bigDecimal = (BigDecimal)value;
- outs.writeByteArray(bigDecimal.unscaledValue().toByteArray());
- outs.writeInt(bigDecimal.scale());
- return;
- }
-
- case VARCHAR:
- case LONGVARCHAR:
- outs.writeString((String)value);
- return;
-
- case CLOB:
- {
- long length = ((String)value).length();
- StringReader source = new StringReader((String)value);
- try
- {
- outs.writeLong(length);
- while (length-- > 0)
- {
- int c = source.read();
- outs.writeChar(c);
- }
- }
- finally
- {
- IOUtil.close(source);
- }
-
- return;
- }
-
- case BIGINT:
- case DATE:
- case TIME:
- case TIMESTAMP:
- outs.writeLong((Long)value);
- return;
-
- case BINARY:
- case VARBINARY:
- case LONGVARBINARY:
- outs.writeByteArray((byte[])value);
- return;
-
- case BLOB:
- {
- long length = ((byte[])value).length;
- ByteArrayInputStream source = new ByteArrayInputStream((byte[])value);
- try
- {
- outs.writeLong(length);
- while (length-- > 0)
- {
- int b = source.read();
- outs.writeByte(b + Byte.MIN_VALUE);
- }
- }
- finally
- {
- IOUtil.close(source);
- }
-
- return;
- }
-
- default:
- throw new UnsupportedOperationException("not implemented");
- }
- }
-
- private Object readTypeValue(ExtendedDataInputStream ins, DBType type) throws IOException
- {
- switch (type)
- {
- case BOOLEAN:
- case BIT:
- return ins.readBoolean();
-
- case CHAR:
- return ins.readString();
-
- case TINYINT:
- return ins.readByte();
-
- case SMALLINT:
- return ins.readShort();
-
- case INTEGER:
- return ins.readInt();
-
- case FLOAT:
- case REAL:
- return ins.readFloat();
-
- case DOUBLE:
- return ins.readDouble();
-
- case NUMERIC:
- case DECIMAL:
- {
- byte[] array = ins.readByteArray();
- if (array == null)
- {
- return null;
- }
-
- BigInteger unscaled = new BigInteger(array);
- int scale = ins.readInt();
- return new BigDecimal(unscaled, scale);
- }
-
- case VARCHAR:
- case LONGVARCHAR:
- return ins.readString();
-
- case CLOB:
- {
- StringWriter result = new StringWriter();
- try
- {
- long length = ins.readLong();
- while (length-- > 0)
- {
- char c = ins.readChar();
- result.append(c);
- }
- }
- finally
- {
- IOUtil.close(result);
- }
- return result.toString();
- }
-
- case DATE:
- case BIGINT:
- case TIME:
- case TIMESTAMP:
- return ins.readLong();
-
- case BINARY:
- case VARBINARY:
- case LONGVARBINARY:
- return ins.readByteArray();
-
- case BLOB:
- {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
-
- try
- {
- long length = ins.readLong();
- while (length-- > 0)
- {
- int b = ins.readByte();
- result.write(b - Byte.MIN_VALUE);
- }
- }
- finally
- {
- IOUtil.close(result);
- }
-
- return result.toByteArray();
- }
-
- default:
- throw new UnsupportedOperationException("not implemented");
- }
- }
-
- private long HOURS_toMillis(int hours)
- {
- return 1000L * 60L * 60L * hours;
- }
-
- private long MINUTES_toMillis(int minutes)
- {
- return 1000L * 60L * minutes;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.server.internal.db.DBStore;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.GregorianCalendar;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ */
+public class Net4jDBTest extends AbstractCDOTest
+{
+ private static final String FIELD_NAME = "testField";
+
+ private DBStore store;
+
+ private ArrayList<Pair<DBType, Object>> columns = new ArrayList<Pair<DBType, Object>>();
+
+ private Connection connection;
+
+ public void testBigInt() throws Exception
+ {
+ registerColumn(DBType.BIGINT, Long.MAX_VALUE);
+ registerColumn(DBType.BIGINT, Long.MIN_VALUE);
+ registerColumn(DBType.BIGINT, 0L);
+ registerColumn(DBType.BIGINT, 42L);
+ doTest(getName());
+ }
+
+ public void testBinary() throws Exception
+ {
+ registerColumn(DBType.BINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.BINARY, data);
+ doTest(getName());
+ }
+
+ public void testVarBinary() throws Exception
+ {
+ registerColumn(DBType.VARBINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.VARBINARY, data);
+ doTest(getName());
+ }
+
+ public void testLongVarBinary() throws Exception
+ {
+ registerColumn(DBType.LONGVARBINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.LONGVARBINARY, data);
+ doTest(getName());
+ }
+
+ public void testBit() throws Exception
+ {
+ registerColumn(DBType.BIT, true);
+ registerColumn(DBType.BIT, false);
+ doTest(getName());
+ }
+
+ public void testBlob() throws Exception
+ {
+ byte[] data = new byte[1000000];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.BLOB, data);
+ doTest(getName());
+ }
+
+ public void testBlobLength0() throws Exception
+ {
+ registerColumn(DBType.BLOB, new byte[0]);
+ doTest(getName());
+ }
+
+ public void testBoolean() throws Exception
+ {
+ registerColumn(DBType.BOOLEAN, true);
+ registerColumn(DBType.BOOLEAN, false);
+ doTest(getName());
+ }
+
+ public void testChar() throws Exception
+ {
+ registerColumn(DBType.CHAR, "0");
+ registerColumn(DBType.CHAR, "a");
+ registerColumn(DBType.CHAR, "\255"); // Fails for DB2
+ registerColumn(DBType.CHAR, "\u1234"); // Fails for DB2
+ doTest(getName());
+ }
+
+ public void testClob() throws Exception
+ {
+ registerColumn(DBType.CLOB, "Test");
+
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < 1000000; i++)
+ {
+ b.append("x");
+ }
+
+ registerColumn(DBType.CLOB, b.toString());
+ doTest(getName());
+ }
+
+ public void testClobLength0() throws Exception
+ {
+ registerColumn(DBType.CLOB, "");
+ doTest(getName());
+ }
+
+ public void testTinyInt() throws Exception
+ {
+ registerColumn(DBType.TINYINT, Byte.MAX_VALUE);
+ registerColumn(DBType.TINYINT, Byte.MIN_VALUE);
+ registerColumn(DBType.TINYINT, new Byte("0"));
+ registerColumn(DBType.TINYINT, new Integer(42).byteValue());
+ doTest(getName());
+ }
+
+ public void testSmallInt() throws Exception
+ {
+ registerColumn(DBType.SMALLINT, Short.MAX_VALUE);
+ registerColumn(DBType.SMALLINT, Short.MIN_VALUE);
+ registerColumn(DBType.SMALLINT, (short)-1);
+ registerColumn(DBType.SMALLINT, (short)5);
+ doTest(getName());
+ }
+
+ public void testInteger() throws Exception
+ {
+ registerColumn(DBType.INTEGER, Integer.MAX_VALUE);
+ registerColumn(DBType.INTEGER, Integer.MIN_VALUE);
+ registerColumn(DBType.INTEGER, -1);
+ registerColumn(DBType.INTEGER, 5);
+ doTest(getName());
+ }
+
+ public void testFloat() throws Exception
+ {
+ registerColumn(DBType.FLOAT, Float.MAX_VALUE);
+ registerColumn(DBType.FLOAT, Float.MIN_VALUE); // Fails for DB2
+ registerColumn(DBType.FLOAT, -.1f);
+ registerColumn(DBType.FLOAT, 3.33333f);
+ doTest(getName());
+ }
+
+ public void testReal() throws Exception
+ {
+ registerColumn(DBType.REAL, Float.MAX_VALUE);
+ registerColumn(DBType.REAL, Float.MIN_VALUE); // Fails for DB2
+ registerColumn(DBType.REAL, -.1f);
+ registerColumn(DBType.REAL, 3.33333f);
+ doTest(getName());
+ }
+
+ public void testDouble() throws Exception
+ {
+ registerColumn(DBType.DOUBLE, new Double(Double.MAX_VALUE));
+ // registerColumn(DBType.DOUBLE, new Double(Double.MIN_VALUE));
+ registerColumn(DBType.DOUBLE, -.1d);
+ registerColumn(DBType.DOUBLE, 3.33333d);
+ doTest(getName());
+ }
+
+ public void _testNumeric() throws Exception
+ {
+ String numberLiteral1 = "12345678901234567890123456789012";
+ String numberLiteral2 = "10000000000000000000000000000000";
+
+ for (int precision = 1; precision < 32; precision++)
+ {
+ BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
+ BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
+
+ for (int scale = 0; scale <= precision; scale++)
+ {
+ BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
+ BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
+
+ registerColumn(DBType.NUMERIC, numberDecimal1);
+ registerColumn(DBType.NUMERIC, numberDecimal2);
+
+ doTest(getName() + precision + "_" + scale);
+ columns.clear();
+ }
+ }
+ }
+
+ public void _testDecimal() throws Exception
+ {
+ String numberLiteral1 = "12345678901234567890123456789012";
+ String numberLiteral2 = "10000000000000000000000000000000";
+
+ for (int precision = 1; precision < 32; precision++)
+ {
+ BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
+ BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
+
+ for (int scale = 0; scale <= precision; scale++)
+ {
+ BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
+ BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
+
+ registerColumn(DBType.DECIMAL, numberDecimal1);
+ registerColumn(DBType.DECIMAL, numberDecimal2);
+
+ doTest(getName() + precision + "_" + scale);
+ columns.clear();
+ }
+ }
+ }
+
+ public void testVarChar() throws Exception
+ {
+ registerColumn(DBType.VARCHAR, "");
+ registerColumn(DBType.VARCHAR, "\n");
+ registerColumn(DBType.VARCHAR, "\t");
+ registerColumn(DBType.VARCHAR, "\r");
+ registerColumn(DBType.VARCHAR, "\u1234");
+ registerColumn(DBType.VARCHAR, "The quick brown fox jumps over the lazy dog.");
+ registerColumn(DBType.VARCHAR, "\\,:\",\'");
+
+ doTest(getName());
+ }
+
+ public void testLongVarChar() throws Exception
+ {
+ registerColumn(DBType.LONGVARCHAR, "");
+ registerColumn(DBType.LONGVARCHAR, "\n");
+ registerColumn(DBType.LONGVARCHAR, "\t");
+ registerColumn(DBType.LONGVARCHAR, "\r");
+ registerColumn(DBType.LONGVARCHAR, "\u1234");
+ registerColumn(DBType.LONGVARCHAR, "The quick brown fox jumps over the lazy dog.");
+ registerColumn(DBType.LONGVARCHAR, "\\,:\",\'");
+
+ doTest(getName());
+ }
+
+ public void testDate() throws Exception
+ {
+ registerColumn(DBType.DATE, new GregorianCalendar(2010, 04, 21).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(1950, 04, 21).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(2030, 12, 31).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis()); // Fails for DB2
+
+ doTest(getName());
+ }
+
+ public void testTime() throws Exception
+ {
+ registerColumn(DBType.TIME, HOURS_toMillis(10));
+ registerColumn(DBType.TIME, 0l);
+ registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
+
+ // Following tests fail on H2 as 24h == 1 day => 0
+ //
+ // registerColumn(DBType.TIME, HOURS_toMillis(24));
+
+ doTest(getName());
+ }
+
+ public void testTimestamp() throws Exception
+ {
+ registerColumn(DBType.TIME, HOURS_toMillis(10));
+ registerColumn(DBType.TIME, 0l);
+ registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
+
+ // Following tests fail on H2 as 24h == 1 day => 0
+ //
+ // registerColumn(DBType.TIME, HOURS_toMillis(24));
+
+ doTest(getName());
+ }
+
+ private void registerColumn(DBType type, Object value)
+ {
+ Pair<DBType, Object> column = new Pair<DBType, Object>(type, value);
+ columns.add(column);
+ }
+
+ private void prepareTable(String tableName)
+ {
+ IDBSchema schema = store.getDBSchema();
+ IDBTable table = schema.addTable(tableName);
+ int c = 0;
+
+ for (Pair<DBType, Object> column : columns)
+ {
+ switch (column.getElement1())
+ {
+ case NUMERIC:
+ case DECIMAL:
+ BigDecimal value = (BigDecimal)column.getElement2();
+ table.addField(FIELD_NAME + c++, column.getElement1(), value.precision(), value.scale());
+ break;
+
+ default:
+ table.addField(FIELD_NAME + c++, column.getElement1());
+ break;
+ }
+ }
+
+ store.getDBAdapter().createTables(Arrays.asList(table), connection);
+ }
+
+ private void writeValues(String tableName) throws Exception
+ {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
+
+ boolean first = true;
+ StringBuilder builder = new StringBuilder("INSERT INTO " + tableName + " VALUES (");
+ for (Pair<DBType, Object> column : columns)
+ {
+ writeTypeValue(outs, column.getElement1(), column.getElement2());
+ if (first)
+ {
+ builder.append("?");
+ first = false;
+ }
+ else
+ {
+ builder.append(", ?");
+ }
+ }
+
+ builder.append(")");
+ String sql = builder.toString();
+
+ outs.close();
+ output.flush();
+ byte[] buffer = output.toByteArray();
+ output.close();
+
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+ ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
+
+ PreparedStatement stmt = connection.prepareStatement(sql);
+ int c = 1;
+
+ for (Pair<DBType, Object> column : columns)
+ {
+ column.getElement1().readValueWithResult(ins, stmt, c++, false);
+ }
+
+ stmt.executeUpdate();
+
+ stmt.close();
+ ins.close();
+ input.close();
+ }
+
+ private void checkValues(String tableName) throws Exception
+ {
+ Statement stmt = connection.createStatement();
+ ResultSet resultSet = stmt.executeQuery("SELECT * FROM " + tableName);
+ assertEquals(true, resultSet.next());
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
+
+ int c = 1;
+ for (Pair<DBType, Object> column : columns)
+ {
+ column.getElement1().writeValue(outs, resultSet, c++, false);
+ }
+
+ resultSet.close();
+ stmt.close();
+
+ outs.close();
+ output.flush();
+ byte[] buffer = output.toByteArray();
+ output.close();
+
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+ ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
+
+ c = 1;
+ for (Pair<DBType, Object> column : columns)
+ {
+ Object actual = readTypeValue(ins, column.getElement1());
+ Class<? extends Object> type = column.getElement2().getClass();
+ if (type.isArray())
+ {
+ Class<?> componentType = type.getComponentType();
+ if (componentType == byte.class)
+ {
+ assertEquals("Error in column " + c + " of type " + column.getElement1(), true,
+ Arrays.equals((byte[])column.getElement2(), (byte[])actual));
+ }
+ else if (componentType == char.class)
+ {
+ assertEquals("Error in column " + c + " with type " + column.getElement1(), true,
+ Arrays.equals((char[])column.getElement2(), (char[])actual));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected component type: " + componentType);
+ }
+ }
+ else
+ {
+ assertEquals("Error in column " + c + " with type " + column.getElement1(), column.getElement2(), actual);
+ }
+
+ ++c;
+ }
+ }
+
+ private void doTest(String tableName) throws Exception
+ {
+ store = (DBStore)getRepository().getStore();
+ connection = store.getConnection();
+
+ try
+ {
+ prepareTable(tableName);
+ writeValues(tableName);
+ checkValues(tableName);
+ }
+ finally
+ {
+ try
+ {
+ connection.commit();
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ connection = null;
+ store = null;
+ }
+ }
+ }
+
+ private void writeTypeValue(ExtendedDataOutputStream outs, DBType type, Object value) throws IOException
+ {
+ switch (type)
+ {
+ case BOOLEAN:
+ case BIT:
+ outs.writeBoolean((Boolean)value);
+ return;
+
+ case TINYINT:
+ outs.writeByte((Byte)value);
+ return;
+
+ case CHAR:
+ outs.writeString((String)value);
+ return;
+
+ case SMALLINT:
+ outs.writeShort((Short)value);
+ return;
+
+ case INTEGER:
+ outs.writeInt((Integer)value);
+ return;
+
+ case FLOAT:
+ outs.writeFloat((Float)value);
+ return;
+
+ case REAL:
+ outs.writeFloat((Float)value);
+ return;
+
+ case DOUBLE:
+ outs.writeDouble((Double)value);
+ return;
+
+ case NUMERIC:
+ case DECIMAL:
+ {
+ BigDecimal bigDecimal = (BigDecimal)value;
+ outs.writeByteArray(bigDecimal.unscaledValue().toByteArray());
+ outs.writeInt(bigDecimal.scale());
+ return;
+ }
+
+ case VARCHAR:
+ case LONGVARCHAR:
+ outs.writeString((String)value);
+ return;
+
+ case CLOB:
+ {
+ long length = ((String)value).length();
+ StringReader source = new StringReader((String)value);
+ try
+ {
+ outs.writeLong(length);
+ while (length-- > 0)
+ {
+ int c = source.read();
+ outs.writeChar(c);
+ }
+ }
+ finally
+ {
+ IOUtil.close(source);
+ }
+
+ return;
+ }
+
+ case BIGINT:
+ case DATE:
+ case TIME:
+ case TIMESTAMP:
+ outs.writeLong((Long)value);
+ return;
+
+ case BINARY:
+ case VARBINARY:
+ case LONGVARBINARY:
+ outs.writeByteArray((byte[])value);
+ return;
+
+ case BLOB:
+ {
+ long length = ((byte[])value).length;
+ ByteArrayInputStream source = new ByteArrayInputStream((byte[])value);
+ try
+ {
+ outs.writeLong(length);
+ while (length-- > 0)
+ {
+ int b = source.read();
+ outs.writeByte(b + Byte.MIN_VALUE);
+ }
+ }
+ finally
+ {
+ IOUtil.close(source);
+ }
+
+ return;
+ }
+
+ default:
+ throw new UnsupportedOperationException("not implemented");
+ }
+ }
+
+ private Object readTypeValue(ExtendedDataInputStream ins, DBType type) throws IOException
+ {
+ switch (type)
+ {
+ case BOOLEAN:
+ case BIT:
+ return ins.readBoolean();
+
+ case CHAR:
+ return ins.readString();
+
+ case TINYINT:
+ return ins.readByte();
+
+ case SMALLINT:
+ return ins.readShort();
+
+ case INTEGER:
+ return ins.readInt();
+
+ case FLOAT:
+ case REAL:
+ return ins.readFloat();
+
+ case DOUBLE:
+ return ins.readDouble();
+
+ case NUMERIC:
+ case DECIMAL:
+ {
+ byte[] array = ins.readByteArray();
+ if (array == null)
+ {
+ return null;
+ }
+
+ BigInteger unscaled = new BigInteger(array);
+ int scale = ins.readInt();
+ return new BigDecimal(unscaled, scale);
+ }
+
+ case VARCHAR:
+ case LONGVARCHAR:
+ return ins.readString();
+
+ case CLOB:
+ {
+ StringWriter result = new StringWriter();
+ try
+ {
+ long length = ins.readLong();
+ while (length-- > 0)
+ {
+ char c = ins.readChar();
+ result.append(c);
+ }
+ }
+ finally
+ {
+ IOUtil.close(result);
+ }
+ return result.toString();
+ }
+
+ case DATE:
+ case BIGINT:
+ case TIME:
+ case TIMESTAMP:
+ return ins.readLong();
+
+ case BINARY:
+ case VARBINARY:
+ case LONGVARBINARY:
+ return ins.readByteArray();
+
+ case BLOB:
+ {
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+
+ try
+ {
+ long length = ins.readLong();
+ while (length-- > 0)
+ {
+ int b = ins.readByte();
+ result.write(b - Byte.MIN_VALUE);
+ }
+ }
+ finally
+ {
+ IOUtil.close(result);
+ }
+
+ return result.toByteArray();
+ }
+
+ default:
+ throw new UnsupportedOperationException("not implemented");
+ }
+ }
+
+ private long HOURS_toMillis(int hours)
+ {
+ return 1000L * 60L * 60L * hours;
+ }
+
+ private long MINUTES_toMillis(int minutes)
+ {
+ return 1000L * 60L * minutes;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
index 84adc271f4..b30ed034c5 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
index 65e503d556..569f29623b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
@@ -1,451 +1,451 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Kai Schlamp - initial API and implementation
- * Eike Stepper - maintenance
- * Kai Schlamp - Bug 284812: [DB] Query non CDO object fails
- * Stefan Winkler - Bug 284812: [DB] Query non CDO object fails
- * Erdal Karaca - added test case for cdoObjectResultAsMap query parameter
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.internal.db.SQLQueryHandler;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.emf.cdo.tests.model1.Order;
-import org.eclipse.emf.cdo.tests.model1.OrderDetail;
-import org.eclipse.emf.cdo.tests.model1.Product1;
-import org.eclipse.emf.cdo.tests.model1.SalesOrder;
-import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOQuery;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.collection.CloseableIterator;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Test different aspects of SQL querying using the CDO query api.
- *
- * @author Kai Schlamp
- */
-public class SQLQueryTest extends AbstractCDOTest
-{
- private static final int NUM_OF_PRODUCTS = 20;
-
- private static final int NUM_OF_CUSTOMERS = 5;
-
- private static final int NUM_OF_PRODUCTS_CUSTOMER = NUM_OF_PRODUCTS / NUM_OF_CUSTOMERS;
-
- private static final int NUM_OF_SALES_ORDERS = 5;
-
- @CleanRepositoriesBefore
- public void testSimpleQueries() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- // {
- // msg("Query for products");
- // CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1");
- // final List<Product1> products = query.getResult(Product1.class);
- // assertEquals(NUM_OF_PRODUCTS, products.size());
- // }
-
- {
- msg("Query for products with a specific name");
- CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE name=:name");
- query.setParameter("name", "" + 1);
- final List<Product1> products = query.getResult(Product1.class);
- assertEquals(1, products.size());
- }
-
- {
- msg("Query for Customers");
- CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER");
- final List<Customer> customers = query.getResult(Customer.class);
- assertEquals(NUM_OF_CUSTOMERS, customers.size());
- }
-
- {
- msg("Query for products with VAT15");
- CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE VAT =:vat");
- query.setParameter("vat", VAT.VAT15.getValue());
- final List<Product1> products = query.getResult(Product1.class);
- assertEquals(10, products.size());
- for (Product1 p : products)
- {
- assertEquals(p.getVat(), VAT.VAT15);
- }
- }
-
- transaction.commit();
- }
-
- @CleanRepositoriesBefore
- public void testFunctions() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Count products");
- CDOQuery query = transaction.createQuery("sql", "SELECT COUNT(*) from MODEL1_PRODUCT1");
- query.setParameter(SQLQueryHandler.CDO_OBJECT_QUERY, false);
-
- // we need to handle objects, because different DBs produce either
- // Long or Integer results
- final List<Object> counts = query.getResult(Object.class);
- assertEquals(counts.size(), 1);
-
- Object result = counts.get(0);
- int intResult;
- if (result instanceof Integer)
- {
- intResult = ((Integer)result).intValue();
- }
- else
- {
- assertEquals(true, result instanceof Long);
- intResult = ((Long)result).intValue();
- }
-
- assertEquals(NUM_OF_PRODUCTS, intResult);
- }
-
- transaction.commit();
- }
-
- @CleanRepositoriesBefore
- public void testComplexQuerySalesOrderJoinCustomerProduct() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for customers");
- CDOQuery customerQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER ORDER BY NAME");
- final List<Customer> customers = customerQuery.getResult(Customer.class);
- assertEquals(NUM_OF_CUSTOMERS, customers.size());
-
- msg("Query for products");
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
- final List<Product1> products = productQuery.getResult(Product1.class);
- assertEquals(NUM_OF_PRODUCTS, products.size());
- }
-
- transaction.commit();
- }
-
- public void testPaging() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for products in pages");
- int pageSize = 5;
- int numOfPages = NUM_OF_PRODUCTS / pageSize;
- final List<Product1> allProducts = new ArrayList<Product1>();
- for (int page = 0; page < numOfPages; page++)
- {
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
- productQuery.setMaxResults(pageSize);
- productQuery.setParameter(SQLQueryHandler.FIRST_RESULT, page * pageSize);
- final List<Product1> queriedProducts = productQuery.getResult(Product1.class);
- assertEquals(true, queriedProducts.size() <= pageSize);
- // a product should not have been read yet
- for (Product1 newProduct : queriedProducts)
- {
- assertEquals(true, !allProducts.contains(newProduct));
- }
-
- allProducts.addAll(queriedProducts);
- }
-
- assertEquals(NUM_OF_PRODUCTS, allProducts.size());
- }
-
- transaction.commit();
- }
-
- public void testIterator() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for products");
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
- final CloseableIterator<Product1> iterator = productQuery.getResultAsync(Product1.class);
- int counter = 0;
- while (iterator.hasNext())
- {
- final Product1 product = iterator.next();
- // meaningless but do something
- assertEquals(true, product != null);
- counter++;
- if (counter == NUM_OF_PRODUCTS / 2)
- {
- iterator.close();
- }
- }
- }
-
- transaction.commit();
- }
-
- public void _testNonCdoObjectQueries() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for customer street strings.");
- CDOQuery query = transaction.createQuery("sql", "SELECT STREET FROM MODEL1_CUSTOMER");
- query.setParameter("cdoObjectQuery", false);
- List<String> streets = new ArrayList<String>(query.getResult(String.class));
- for (int i = 0; i < 5; i++)
- {
- assertEquals(true, streets.contains("Street " + i));
- }
- }
- }
-
- public void _testNonCdoObjectQueries_Null() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for customer city strings.");
- CDOQuery query = transaction.createQuery("sql", "SELECT CITY FROM MODEL1_CUSTOMER");
- query.setParameter("cdoObjectQuery", false);
- List<String> cities = new ArrayList<String>(query.getResult(String.class));
-
- assertEquals(true, cities.contains(null));
- for (int i = 1; i < 5; i++)
- {
- assertEquals(true, cities.contains("City " + i));
- }
- }
- }
-
- @CleanRepositoriesBefore
- public void testNonCDOObjectQueries_Complex() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- {
- msg("Query for customer fields");
- CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
- query.setParameter("cdoObjectQuery", false);
-
- List<Object[]> results = query.getResult(Object[].class);
- for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
- {
- assertEquals("Street " + i, results.get(i)[0]);
- Object actual = results.get(i)[1];
- if (i == 0)
- {
- assertEquals(null, actual);
- }
- else
- {
- assertEquals("City " + i, actual);
- }
-
- assertEquals("" + i, results.get(i)[2]);
- }
- }
- }
-
- @CleanRepositoriesBefore
- public void testNonCDOObjectQueries_Complex_MAP() throws Exception
- {
- msg("Opening session");
- CDOSession session = openSession();
-
- createTestSet(session);
-
- msg("Opening transaction for querying");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Query for customer fields");
- CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
- query.setParameter("cdoObjectQuery", false);
- query.setParameter("mapQuery", true);
-
- List<Map<String, Object>> results = query.getResult();
- for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
- {
- assertEquals("Street " + i, results.get(i).get("STREET"));
- Object actual = results.get(i).get("CITY");
- if (i == 0)
- {
- assertEquals(null, actual);
- }
- else
- {
- assertEquals("City " + i, actual);
- }
-
- assertEquals("" + i, results.get(i).get("NAME"));
- }
- }
-
- private void createTestSet(CDOSession session)
- {
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- fillResource(resource);
-
- try
- {
- msg("Committing");
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- private void fillResource(CDOResource resource)
- {
- msg("Creating Testset");
- final List<Product1> products = new ArrayList<Product1>();
- for (int i = 0; i < NUM_OF_PRODUCTS; i++)
- {
- products.add(createProduct(i));
- }
-
- resource.getContents().addAll(products);
-
- int productCounter = 0;
- for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
- {
- final Customer customer = getModel1Factory().createCustomer();
-
- if (i == 0)
- {
- // set first city null for null-test-case
- customer.setCity(null);
- }
- else
- {
- customer.setCity("City " + i);
- }
-
- customer.setName(i + "");
- customer.setStreet("Street " + i);
- resource.getContents().add(customer);
-
- final List<Product1> customerProducts = products.subList(productCounter, productCounter
- + NUM_OF_PRODUCTS_CUSTOMER);
- for (int k = 0; k < NUM_OF_SALES_ORDERS; k++)
- {
- resource.getContents().add(createSalesOrder(i * 10 + k, customer, customerProducts));
- }
-
- productCounter += NUM_OF_PRODUCTS_CUSTOMER;
- }
- }
-
- private SalesOrder createSalesOrder(int num, Customer customer, List<Product1> products)
- {
- SalesOrder salesOrder = getModel1Factory().createSalesOrder();
- salesOrder.setCustomer(customer);
- salesOrder.setId(num);
- createOrderDetail(salesOrder, num, products);
- return salesOrder;
- }
-
- private List<OrderDetail> createOrderDetail(Order order, int index, List<Product1> products)
- {
- final List<OrderDetail> orderDetails = new ArrayList<OrderDetail>();
- int count = 0;
- for (Product1 product : products)
- {
- OrderDetail orderDetail = getModel1Factory().createOrderDetail();
- orderDetail.setOrder(order);
- orderDetail.setPrice(count++ * index * 1.1f);
- orderDetail.setProduct(product);
- }
-
- return orderDetails;
- }
-
- private Product1 createProduct(int index)
- {
- Product1 product = getModel1Factory().createProduct1();
- product.setDescription("Description " + index);
- product.setName("" + index);
- if (index < 10)
- {
- product.setVat(VAT.VAT15);
- }
- else
- {
- product.setVat(VAT.VAT7);
- }
-
- return product;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kai Schlamp - initial API and implementation
+ * Eike Stepper - maintenance
+ * Kai Schlamp - Bug 284812: [DB] Query non CDO object fails
+ * Stefan Winkler - Bug 284812: [DB] Query non CDO object fails
+ * Erdal Karaca - added test case for cdoObjectResultAsMap query parameter
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.internal.db.SQLQueryHandler;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Order;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOQuery;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.CloseableIterator;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Test different aspects of SQL querying using the CDO query api.
+ *
+ * @author Kai Schlamp
+ */
+public class SQLQueryTest extends AbstractCDOTest
+{
+ private static final int NUM_OF_PRODUCTS = 20;
+
+ private static final int NUM_OF_CUSTOMERS = 5;
+
+ private static final int NUM_OF_PRODUCTS_CUSTOMER = NUM_OF_PRODUCTS / NUM_OF_CUSTOMERS;
+
+ private static final int NUM_OF_SALES_ORDERS = 5;
+
+ @CleanRepositoriesBefore
+ public void testSimpleQueries() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ // {
+ // msg("Query for products");
+ // CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1");
+ // final List<Product1> products = query.getResult(Product1.class);
+ // assertEquals(NUM_OF_PRODUCTS, products.size());
+ // }
+
+ {
+ msg("Query for products with a specific name");
+ CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE name=:name");
+ query.setParameter("name", "" + 1);
+ final List<Product1> products = query.getResult(Product1.class);
+ assertEquals(1, products.size());
+ }
+
+ {
+ msg("Query for Customers");
+ CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER");
+ final List<Customer> customers = query.getResult(Customer.class);
+ assertEquals(NUM_OF_CUSTOMERS, customers.size());
+ }
+
+ {
+ msg("Query for products with VAT15");
+ CDOQuery query = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE VAT =:vat");
+ query.setParameter("vat", VAT.VAT15.getValue());
+ final List<Product1> products = query.getResult(Product1.class);
+ assertEquals(10, products.size());
+ for (Product1 p : products)
+ {
+ assertEquals(p.getVat(), VAT.VAT15);
+ }
+ }
+
+ transaction.commit();
+ }
+
+ @CleanRepositoriesBefore
+ public void testFunctions() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Count products");
+ CDOQuery query = transaction.createQuery("sql", "SELECT COUNT(*) from MODEL1_PRODUCT1");
+ query.setParameter(SQLQueryHandler.CDO_OBJECT_QUERY, false);
+
+ // we need to handle objects, because different DBs produce either
+ // Long or Integer results
+ final List<Object> counts = query.getResult(Object.class);
+ assertEquals(counts.size(), 1);
+
+ Object result = counts.get(0);
+ int intResult;
+ if (result instanceof Integer)
+ {
+ intResult = ((Integer)result).intValue();
+ }
+ else
+ {
+ assertEquals(true, result instanceof Long);
+ intResult = ((Long)result).intValue();
+ }
+
+ assertEquals(NUM_OF_PRODUCTS, intResult);
+ }
+
+ transaction.commit();
+ }
+
+ @CleanRepositoriesBefore
+ public void testComplexQuerySalesOrderJoinCustomerProduct() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for customers");
+ CDOQuery customerQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER ORDER BY NAME");
+ final List<Customer> customers = customerQuery.getResult(Customer.class);
+ assertEquals(NUM_OF_CUSTOMERS, customers.size());
+
+ msg("Query for products");
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
+ final List<Product1> products = productQuery.getResult(Product1.class);
+ assertEquals(NUM_OF_PRODUCTS, products.size());
+ }
+
+ transaction.commit();
+ }
+
+ public void testPaging() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for products in pages");
+ int pageSize = 5;
+ int numOfPages = NUM_OF_PRODUCTS / pageSize;
+ final List<Product1> allProducts = new ArrayList<Product1>();
+ for (int page = 0; page < numOfPages; page++)
+ {
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
+ productQuery.setMaxResults(pageSize);
+ productQuery.setParameter(SQLQueryHandler.FIRST_RESULT, page * pageSize);
+ final List<Product1> queriedProducts = productQuery.getResult(Product1.class);
+ assertEquals(true, queriedProducts.size() <= pageSize);
+ // a product should not have been read yet
+ for (Product1 newProduct : queriedProducts)
+ {
+ assertEquals(true, !allProducts.contains(newProduct));
+ }
+
+ allProducts.addAll(queriedProducts);
+ }
+
+ assertEquals(NUM_OF_PRODUCTS, allProducts.size());
+ }
+
+ transaction.commit();
+ }
+
+ public void testIterator() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for products");
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
+ final CloseableIterator<Product1> iterator = productQuery.getResultAsync(Product1.class);
+ int counter = 0;
+ while (iterator.hasNext())
+ {
+ final Product1 product = iterator.next();
+ // meaningless but do something
+ assertEquals(true, product != null);
+ counter++;
+ if (counter == NUM_OF_PRODUCTS / 2)
+ {
+ iterator.close();
+ }
+ }
+ }
+
+ transaction.commit();
+ }
+
+ public void _testNonCdoObjectQueries() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for customer street strings.");
+ CDOQuery query = transaction.createQuery("sql", "SELECT STREET FROM MODEL1_CUSTOMER");
+ query.setParameter("cdoObjectQuery", false);
+ List<String> streets = new ArrayList<String>(query.getResult(String.class));
+ for (int i = 0; i < 5; i++)
+ {
+ assertEquals(true, streets.contains("Street " + i));
+ }
+ }
+ }
+
+ public void _testNonCdoObjectQueries_Null() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for customer city strings.");
+ CDOQuery query = transaction.createQuery("sql", "SELECT CITY FROM MODEL1_CUSTOMER");
+ query.setParameter("cdoObjectQuery", false);
+ List<String> cities = new ArrayList<String>(query.getResult(String.class));
+
+ assertEquals(true, cities.contains(null));
+ for (int i = 1; i < 5; i++)
+ {
+ assertEquals(true, cities.contains("City " + i));
+ }
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testNonCDOObjectQueries_Complex() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ {
+ msg("Query for customer fields");
+ CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
+ query.setParameter("cdoObjectQuery", false);
+
+ List<Object[]> results = query.getResult(Object[].class);
+ for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ {
+ assertEquals("Street " + i, results.get(i)[0]);
+ Object actual = results.get(i)[1];
+ if (i == 0)
+ {
+ assertEquals(null, actual);
+ }
+ else
+ {
+ assertEquals("City " + i, actual);
+ }
+
+ assertEquals("" + i, results.get(i)[2]);
+ }
+ }
+ }
+
+ @CleanRepositoriesBefore
+ public void testNonCDOObjectQueries_Complex_MAP() throws Exception
+ {
+ msg("Opening session");
+ CDOSession session = openSession();
+
+ createTestSet(session);
+
+ msg("Opening transaction for querying");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Query for customer fields");
+ CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
+ query.setParameter("cdoObjectQuery", false);
+ query.setParameter("mapQuery", true);
+
+ List<Map<String, Object>> results = query.getResult();
+ for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ {
+ assertEquals("Street " + i, results.get(i).get("STREET"));
+ Object actual = results.get(i).get("CITY");
+ if (i == 0)
+ {
+ assertEquals(null, actual);
+ }
+ else
+ {
+ assertEquals("City " + i, actual);
+ }
+
+ assertEquals("" + i, results.get(i).get("NAME"));
+ }
+ }
+
+ private void createTestSet(CDOSession session)
+ {
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ fillResource(resource);
+
+ try
+ {
+ msg("Committing");
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ private void fillResource(CDOResource resource)
+ {
+ msg("Creating Testset");
+ final List<Product1> products = new ArrayList<Product1>();
+ for (int i = 0; i < NUM_OF_PRODUCTS; i++)
+ {
+ products.add(createProduct(i));
+ }
+
+ resource.getContents().addAll(products);
+
+ int productCounter = 0;
+ for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ {
+ final Customer customer = getModel1Factory().createCustomer();
+
+ if (i == 0)
+ {
+ // set first city null for null-test-case
+ customer.setCity(null);
+ }
+ else
+ {
+ customer.setCity("City " + i);
+ }
+
+ customer.setName(i + "");
+ customer.setStreet("Street " + i);
+ resource.getContents().add(customer);
+
+ final List<Product1> customerProducts = products.subList(productCounter, productCounter
+ + NUM_OF_PRODUCTS_CUSTOMER);
+ for (int k = 0; k < NUM_OF_SALES_ORDERS; k++)
+ {
+ resource.getContents().add(createSalesOrder(i * 10 + k, customer, customerProducts));
+ }
+
+ productCounter += NUM_OF_PRODUCTS_CUSTOMER;
+ }
+ }
+
+ private SalesOrder createSalesOrder(int num, Customer customer, List<Product1> products)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setCustomer(customer);
+ salesOrder.setId(num);
+ createOrderDetail(salesOrder, num, products);
+ return salesOrder;
+ }
+
+ private List<OrderDetail> createOrderDetail(Order order, int index, List<Product1> products)
+ {
+ final List<OrderDetail> orderDetails = new ArrayList<OrderDetail>();
+ int count = 0;
+ for (Product1 product : products)
+ {
+ OrderDetail orderDetail = getModel1Factory().createOrderDetail();
+ orderDetail.setOrder(order);
+ orderDetail.setPrice(count++ * index * 1.1f);
+ orderDetail.setProduct(product);
+ }
+
+ return orderDetails;
+ }
+
+ private Product1 createProduct(int index)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setDescription("Description " + index);
+ product.setName("" + index);
+ if (index < 10)
+ {
+ product.setVat(VAT.VAT15);
+ }
+ else
+ {
+ product.setVat(VAT.VAT7);
+ }
+
+ return product;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
index 8e5fc563e3..fbe8bd553e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests.db"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests.db"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
index d820df9524..f7527bb5f7 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
@@ -1,347 +1,347 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import junit.framework.TestCase;
-
-/**
- * This is a simple test case that can be used to analyze how a DBMS handles DML in the middle of a transaction.
- *
- * @author Stefan Winkler
- */
-public abstract class AbstractCapabilityTest extends TestCase
-{
- public AbstractCapabilityTest(String name)
- {
- super(name);
- }
-
- public void testDirtyRead() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - DIRTY READ");
- msg("----------------------------------------------------------");
- msg("Transaction 1 changes a value, transaction 2 will read the value.");
- msg("The value of transaction 2 should be UNCHANGED (else we have a dirty read)");
-
- Thread t = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- msg("Read value (transaction 1) is "
- + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
- sleep(1000);
-
- transaction1.rollback();
- transaction1.close();
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
- };
-
- t.start();
- Thread.sleep(300);
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction2 = provider.getConnection();
-
- transaction2.setAutoCommit(false);
-
- msg("Read value (transaction 2) is "
- + select(transaction2, "select status from status_table where trans = 'transaction1'").toUpperCase());
- msg("----------------------------------------------------------");
- transaction2.rollback();
- transaction2.close();
- }
-
- public void testRollback() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - ROLLBACK");
- msg("----------------------------------------------------------");
- msg("Transaction changes a value and does a rollback.");
- msg("The value of after rollback should be UNCHANGED.");
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
-
- try
- {
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- }
- finally
- {
- DBUtil.close(tx1stmt);
- }
-
- msg("Read value before rollback is "
- + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
-
- transaction1.rollback();
- transaction1.close();
-
- Connection view = provider.getConnection();
- msg("Read value after rollback is "
- + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
- view.close();
- msg("----------------------------------------------------------");
- }
-
- public void testDml() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - DML");
- msg("----------------------------------------------------------");
- msg("Transaction 1 will execute DML, transaction 2 will just change its data.");
-
- Thread t = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction2 = provider.getConnection();
- Statement tx2stmt = transaction2.createStatement();
- transaction2.setAutoCommit(false);
- tx2stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction2'");
- tx2stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction2'");
- tx2stmt.close();
- sleep(1000);
- transaction2.rollback();
- transaction2.close();
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
- };
-
- t.start();
- Thread.sleep(100);
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
-
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- tx1stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction1'");
-
- tx1stmt.execute("alter table change_table add new_column varchar(255) default 'added column present'");
-
- tx1stmt.close();
-
- transaction1.rollback();
- transaction1.close();
-
- t.join();
-
- Connection view = provider.getConnection();
-
- msg("transaction1: unchanged table record is "
- + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
- msg("transaction2: unchanged table record is "
- + select(view, "select status from status_table where trans = 'transaction2'").toUpperCase());
-
- msg("transaction1: changed table record is "
- + select(view, "select status from change_table where trans = 'transaction1'").toUpperCase());
- msg("transaction2: changed table record is "
- + select(view, "select status from change_table where trans = 'transaction2'").toUpperCase());
-
- String present = "present";
- try
- {
- select(view, "select new_column from change_table where trans = 'transaction2'");
- }
- catch (SQLException e)
- {
- present = "not present";
- }
-
- msg("Added column is " + present.toUpperCase());
- view.close();
-
- msg("----------------------------------------------------------");
- }
-
- @Override
- protected void setUp() throws Exception
- {
- // create table
- Connection conn = getConnectionProvider().getConnection();
- conn.setAutoCommit(false);
- Statement stmt = conn.createStatement();
-
- // make sure tables don't exist!
- try
- {
- stmt.execute("drop table status_table");
- }
- catch (Exception e)
- {
- }
-
- try
- {
- stmt.execute("drop table change_table");
- }
- catch (Exception e)
- {
- }
-
- stmt.execute("create table status_table (trans varchar(255), status varchar(255))");
- stmt.execute("insert into status_table values ('transaction1', 'unchanged')");
- stmt.execute("insert into status_table values ('transaction2', 'unchanged')");
-
- stmt.execute("create table change_table (trans varchar(255), status varchar(255))");
- stmt.execute("insert into change_table values ('transaction1', 'unchanged')");
- stmt.execute("insert into change_table values ('transaction2', 'unchanged')");
-
- conn.commit();
- stmt.close();
- conn.close();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- Connection conn = getConnectionProvider().getConnection();
- conn.setAutoCommit(true);
- Statement stmt = conn.createStatement();
-
- stmt.execute("drop table status_table");
- stmt.execute("drop table change_table");
-
- stmt.close();
- conn.close();
- }
-
- protected abstract IDBConnectionProvider getConnectionProvider();
-
- private void msg(String string)
- {
- System.out.println(string);
- }
-
- private String select(Connection conn, String sql) throws SQLException
- {
- ResultSet rs = null;
- try
- {
- rs = conn.createStatement().executeQuery(sql);
- rs.next();
- return rs.getString(1);
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-
- @SuppressWarnings("unused")
- private void sqlDump(Connection conn, String sql)
- {
- ResultSet rs = null;
- try
- {
- System.out.format("Dumping output of %s\n", sql); //$NON-NLS-1$
- rs = conn.createStatement().executeQuery(sql);
- int numCol = rs.getMetaData().getColumnCount();
-
- StringBuilder row = new StringBuilder(" ");
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%15s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------------+"); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
-
- while (rs.next())
- {
- row = new StringBuilder(" ");
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%15s | ", rs.getString(c))); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
- }
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------------+"); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
- }
- catch (SQLException ex)
- {
- // NOP
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import junit.framework.TestCase;
+
+/**
+ * This is a simple test case that can be used to analyze how a DBMS handles DML in the middle of a transaction.
+ *
+ * @author Stefan Winkler
+ */
+public abstract class AbstractCapabilityTest extends TestCase
+{
+ public AbstractCapabilityTest(String name)
+ {
+ super(name);
+ }
+
+ public void testDirtyRead() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - DIRTY READ");
+ msg("----------------------------------------------------------");
+ msg("Transaction 1 changes a value, transaction 2 will read the value.");
+ msg("The value of transaction 2 should be UNCHANGED (else we have a dirty read)");
+
+ Thread t = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ msg("Read value (transaction 1) is "
+ + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ sleep(1000);
+
+ transaction1.rollback();
+ transaction1.close();
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+ };
+
+ t.start();
+ Thread.sleep(300);
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction2 = provider.getConnection();
+
+ transaction2.setAutoCommit(false);
+
+ msg("Read value (transaction 2) is "
+ + select(transaction2, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ msg("----------------------------------------------------------");
+ transaction2.rollback();
+ transaction2.close();
+ }
+
+ public void testRollback() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - ROLLBACK");
+ msg("----------------------------------------------------------");
+ msg("Transaction changes a value and does a rollback.");
+ msg("The value of after rollback should be UNCHANGED.");
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+
+ try
+ {
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ }
+ finally
+ {
+ DBUtil.close(tx1stmt);
+ }
+
+ msg("Read value before rollback is "
+ + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
+
+ transaction1.rollback();
+ transaction1.close();
+
+ Connection view = provider.getConnection();
+ msg("Read value after rollback is "
+ + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ view.close();
+ msg("----------------------------------------------------------");
+ }
+
+ public void testDml() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - DML");
+ msg("----------------------------------------------------------");
+ msg("Transaction 1 will execute DML, transaction 2 will just change its data.");
+
+ Thread t = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction2 = provider.getConnection();
+ Statement tx2stmt = transaction2.createStatement();
+ transaction2.setAutoCommit(false);
+ tx2stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction2'");
+ tx2stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction2'");
+ tx2stmt.close();
+ sleep(1000);
+ transaction2.rollback();
+ transaction2.close();
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+ };
+
+ t.start();
+ Thread.sleep(100);
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ tx1stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction1'");
+
+ tx1stmt.execute("alter table change_table add new_column varchar(255) default 'added column present'");
+
+ tx1stmt.close();
+
+ transaction1.rollback();
+ transaction1.close();
+
+ t.join();
+
+ Connection view = provider.getConnection();
+
+ msg("transaction1: unchanged table record is "
+ + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ msg("transaction2: unchanged table record is "
+ + select(view, "select status from status_table where trans = 'transaction2'").toUpperCase());
+
+ msg("transaction1: changed table record is "
+ + select(view, "select status from change_table where trans = 'transaction1'").toUpperCase());
+ msg("transaction2: changed table record is "
+ + select(view, "select status from change_table where trans = 'transaction2'").toUpperCase());
+
+ String present = "present";
+ try
+ {
+ select(view, "select new_column from change_table where trans = 'transaction2'");
+ }
+ catch (SQLException e)
+ {
+ present = "not present";
+ }
+
+ msg("Added column is " + present.toUpperCase());
+ view.close();
+
+ msg("----------------------------------------------------------");
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ // create table
+ Connection conn = getConnectionProvider().getConnection();
+ conn.setAutoCommit(false);
+ Statement stmt = conn.createStatement();
+
+ // make sure tables don't exist!
+ try
+ {
+ stmt.execute("drop table status_table");
+ }
+ catch (Exception e)
+ {
+ }
+
+ try
+ {
+ stmt.execute("drop table change_table");
+ }
+ catch (Exception e)
+ {
+ }
+
+ stmt.execute("create table status_table (trans varchar(255), status varchar(255))");
+ stmt.execute("insert into status_table values ('transaction1', 'unchanged')");
+ stmt.execute("insert into status_table values ('transaction2', 'unchanged')");
+
+ stmt.execute("create table change_table (trans varchar(255), status varchar(255))");
+ stmt.execute("insert into change_table values ('transaction1', 'unchanged')");
+ stmt.execute("insert into change_table values ('transaction2', 'unchanged')");
+
+ conn.commit();
+ stmt.close();
+ conn.close();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ Connection conn = getConnectionProvider().getConnection();
+ conn.setAutoCommit(true);
+ Statement stmt = conn.createStatement();
+
+ stmt.execute("drop table status_table");
+ stmt.execute("drop table change_table");
+
+ stmt.close();
+ conn.close();
+ }
+
+ protected abstract IDBConnectionProvider getConnectionProvider();
+
+ private void msg(String string)
+ {
+ System.out.println(string);
+ }
+
+ private String select(Connection conn, String sql) throws SQLException
+ {
+ ResultSet rs = null;
+ try
+ {
+ rs = conn.createStatement().executeQuery(sql);
+ rs.next();
+ return rs.getString(1);
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private void sqlDump(Connection conn, String sql)
+ {
+ ResultSet rs = null;
+ try
+ {
+ System.out.format("Dumping output of %s\n", sql); //$NON-NLS-1$
+ rs = conn.createStatement().executeQuery(sql);
+ int numCol = rs.getMetaData().getColumnCount();
+
+ StringBuilder row = new StringBuilder(" ");
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%15s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------------+"); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+
+ while (rs.next())
+ {
+ row = new StringBuilder(" ");
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%15s | ", rs.getString(c))); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+ }
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------------+"); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
index 44f2402a24..3ad7f94747 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.util.io.TMPUtil;
-
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-import java.io.File;
-
-/**
- * @author Stefan Winkler
- */
-public class DerbyTest extends AbstractCapabilityTest
-{
- private IDBConnectionProvider provider;
-
- public DerbyTest()
- {
- super("derby");
- File dbFolder = TMPUtil.createTempFolder("derby_", "_test");
- dbFolder.delete();
- EmbeddedDataSource derbyds = new EmbeddedDataSource();
- derbyds.setDatabaseName(dbFolder.getAbsolutePath());
- derbyds.setCreateDatabase("create");
- provider = DBUtil.createConnectionProvider(derbyds);
- }
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.io.TMPUtil;
+
+import org.apache.derby.jdbc.EmbeddedDataSource;
+
+import java.io.File;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DerbyTest extends AbstractCapabilityTest
+{
+ private IDBConnectionProvider provider;
+
+ public DerbyTest()
+ {
+ super("derby");
+ File dbFolder = TMPUtil.createTempFolder("derby_", "_test");
+ dbFolder.delete();
+ EmbeddedDataSource derbyds = new EmbeddedDataSource();
+ derbyds.setDatabaseName(dbFolder.getAbsolutePath());
+ derbyds.setCreateDatabase("create");
+ provider = DBUtil.createConnectionProvider(derbyds);
+ }
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
index 13dd2b1484..1405e2a57a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import org.h2.jdbcx.JdbcDataSource;
-
-/**
- * @author Stefan Winkler
- */
-public class H2Test extends AbstractCapabilityTest
-{
- public H2Test()
- {
- super("h2");
- JdbcDataSource h2ds = new JdbcDataSource();
- h2ds = new JdbcDataSource();
- h2ds.setURL("jdbc:h2:file:c:/temp/h2test");
- h2ds.setUser("sa");
- provider = DBUtil.createConnectionProvider(h2ds);
- }
-
- IDBConnectionProvider provider = null;
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import org.h2.jdbcx.JdbcDataSource;
+
+/**
+ * @author Stefan Winkler
+ */
+public class H2Test extends AbstractCapabilityTest
+{
+ public H2Test()
+ {
+ super("h2");
+ JdbcDataSource h2ds = new JdbcDataSource();
+ h2ds = new JdbcDataSource();
+ h2ds.setURL("jdbc:h2:file:c:/temp/h2test");
+ h2ds.setUser("sa");
+ provider = DBUtil.createConnectionProvider(h2ds);
+ }
+
+ IDBConnectionProvider provider = null;
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/HsqlTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/HsqlTest.java
index 44b4ee5cc6..4425a55115 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/HsqlTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/HsqlTest.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import org.hsqldb.jdbc.jdbcDataSource;
-
-/**
- * @author Stefan Winkler
- */
-public class HsqlTest extends AbstractCapabilityTest
-{
- private IDBConnectionProvider provider;
-
- public HsqlTest()
- {
- super("hsqldb");
- jdbcDataSource hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:file:c:/temp/hsql_test");
- hsqlds.setUser("sa");
-
- provider = DBUtil.createConnectionProvider(hsqlds);
- }
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import org.hsqldb.jdbc.jdbcDataSource;
+
+/**
+ * @author Stefan Winkler
+ */
+public class HsqlTest extends AbstractCapabilityTest
+{
+ private IDBConnectionProvider provider;
+
+ public HsqlTest()
+ {
+ super("hsqldb");
+ jdbcDataSource hsqlds = new jdbcDataSource();
+ hsqlds.setDatabase("jdbc:hsqldb:file:c:/temp/hsql_test");
+ hsqlds.setUser("sa");
+
+ provider = DBUtil.createConnectionProvider(hsqlds);
+ }
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
index c189a785ab..cc8902e81b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
-
-/**
- * @author Stefan Winkler
- */
-public class MysqlTest extends AbstractCapabilityTest
-{
- private IDBConnectionProvider provider;
-
- public MysqlTest()
- {
- super("mysql");
- MysqlDataSource mysqlds = new MysqlDataSource();
- mysqlds.setUrl("jdbc:mysql://localhost:33306/winkler_r2");
- mysqlds.setUser("winkler");
- mysqlds.setPassword("winkler");
- provider = DBUtil.createConnectionProvider(mysqlds);
- }
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
+
+/**
+ * @author Stefan Winkler
+ */
+public class MysqlTest extends AbstractCapabilityTest
+{
+ private IDBConnectionProvider provider;
+
+ public MysqlTest()
+ {
+ super("mysql");
+ MysqlDataSource mysqlds = new MysqlDataSource();
+ mysqlds.setUrl("jdbc:mysql://localhost:33306/winkler_r2");
+ mysqlds.setUser("winkler");
+ mysqlds.setPassword("winkler");
+ provider = DBUtil.createConnectionProvider(mysqlds);
+ }
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
index 32b3689c3e..cc13c52d26 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
@@ -1,35 +1,35 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.performance;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.db.H2Config;
-import org.eclipse.emf.cdo.tests.performance.AllPerformanceTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Stefan Winkler
- */
-public class AllPerformanceTestsH2NonAudit extends AllPerformanceTests
-{
- public static Test suite()
- {
- return new AllPerformanceTestsH2NonAudit().getTestSuite(AllPerformanceTestsH2NonAudit.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.performance;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.db.H2Config;
+import org.eclipse.emf.cdo.tests.performance.AllPerformanceTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Stefan Winkler
+ */
+public class AllPerformanceTestsH2NonAudit extends AllPerformanceTests
+{
+ public static Test suite()
+ {
+ return new AllPerformanceTestsH2NonAudit().getTestSuite(AllPerformanceTestsH2NonAudit.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
index 5e9c7681d5..7ab611d97a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
@@ -1,540 +1,540 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.verifier;
-
-import static junit.framework.Assert.assertEquals;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.tests.db.bundle.OM;
-
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
-
-/**
- * @author Stefan Winkler
- */
-public abstract class DBStoreVerifier
-{
- protected static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreVerifier.class);
-
- private IRepository repository;
-
- private IDBStoreAccessor accessor;
-
- public DBStoreVerifier(IRepository repository)
- {
- this.repository = repository;
- if (repository != null)
- {
- assertEquals(true, repository.getStore() instanceof IDBStore);
- }
- }
-
- protected IRepository getRepository()
- {
- return repository;
- }
-
- protected IDBStore getStore()
- {
- return (IDBStore)repository.getStore();
- }
-
- protected Statement getStatement()
- {
- if (accessor == null)
- {
- accessor = (IDBStoreAccessor)repository.getStore().getReader(null);
- }
-
- try
- {
- return accessor.getConnection().createStatement();
- }
- catch (SQLException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- protected Connection getConnection() throws SQLException
- {
- return getStatement().getConnection();
- }
-
- protected DatabaseMetaData getMetaData() throws SQLException
- {
- return getConnection().getMetaData();
- }
-
- protected List<IClassMapping> getClassMappings()
- {
- ArrayList<IClassMapping> result = new ArrayList<IClassMapping>();
- InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)repository.getPackageRegistry();
- for (InternalCDOPackageInfo packageInfo : packageRegistry.getPackageInfos())
- {
- // CDO core package is not mapped in horizontal mapping
- if (!packageInfo.isCorePackage())
- {
- for (EClass cls : EMFUtil.getPersistentClasses(packageInfo.getEPackage()))
- {
- result.add(getStore().getMappingStrategy().getClassMapping(cls));
- }
- }
- }
-
- return result;
- }
-
- protected void cleanUp()
- {
- if (accessor != null)
- {
- accessor.release();
- }
- }
-
- public void verify() throws VerificationException
- {
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Starting {0}...", getClass().getSimpleName());
- }
-
- doVerify();
-
- if (TRACER.isEnabled())
- {
- TRACER.format("{0} completed without complaints...", getClass().getSimpleName());
- }
- }
- catch (Exception e)
- {
- throw new VerificationException(e);
- }
- finally
- {
- cleanUp();
- }
- }
-
- protected void sqlDump(String sql)
- {
- ResultSet rs = null;
-
- try
- {
- TRACER.format("Dumping output of {0}", sql);
- rs = getStatement().executeQuery(sql);
- int numCol = rs.getMetaData().getColumnCount();
-
- StringBuilder row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c)));
- }
-
- TRACER.trace(row.toString());
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------+--");
- }
-
- TRACER.trace(row.toString());
-
- while (rs.next())
- {
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%10s | ", rs.getString(c)));
- }
-
- TRACER.trace(row.toString());
- }
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------+-");
- }
-
- TRACER.trace(row.toString());
- }
- catch (SQLException ex)
- {
- // NOP
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-
- protected abstract void doVerify() throws Exception;
-
- /**
- * @author Stefan Winkler
- */
- public static class VerificationException extends RuntimeException
- {
- private static final long serialVersionUID = 1L;
-
- public VerificationException(String message)
- {
- super(message);
- }
-
- public VerificationException(String message, Throwable t)
- {
- super(message, t);
- }
-
- public VerificationException(Throwable t)
- {
- super(t);
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class Audit extends DBStoreVerifier
- {
- public Audit(IRepository repo)
- {
- super(repo);
-
- // this is a verifier for auditing mode
- assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalAuditMappingStrategy);
- }
-
- @Override
- protected void doVerify() throws Exception
- {
- for (IClassMapping mapping : getClassMappings())
- {
- if (mapping != null && mapping.getDBTables() != null)
- {
- verifyClassMapping(mapping);
- }
- }
- }
-
- private void verifyClassMapping(IClassMapping mapping) throws Exception
- {
- verifyAtMostOneUnrevised(mapping);
- verifyUniqueIdVersion(mapping);
- verifyReferences(mapping);
- }
-
- private void verifyAtMostOneUnrevised(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- TRACER.format("verifyAtMostOneUnrevised: {0} ...", tableName);
-
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
- + CDODBSchema.ATTRIBUTES_REVISED + "= 0 GROUP BY " + CDODBSchema.ATTRIBUTES_ID;
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple unrevised rows for ID " + resultSet.getLong(1), true, resultSet.getInt(2) <= 1);
- }
- }
- finally
- {
- resultSet.close();
- }
- }
-
- /**
- * Verify that the pair (id,version) is unique.
- */
- private void verifyUniqueIdVersion(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
-
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION + ", count(1) FROM "
- + tableName + " GROUP BY " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION;
-
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple rows for ID " + resultSet.getLong(1) + "v" + resultSet.getInt(2), true,
- resultSet.getInt(3) <= 1);
- }
- }
- catch (AssertionFailedError e)
- {
- TRACER.trace(e.getMessage());
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + "=0");
- throw e;
- }
- finally
- {
- resultSet.close();
- }
- }
-
- private void verifyReferences(IClassMapping mapping) throws Exception
- {
- List<IListMapping> listMappings = ((HorizontalAuditClassMapping)mapping).getListMappings();
- if (listMappings == null)
- {
- return;
- }
-
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
-
- ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
- }
- }
- finally
- {
- resultSet.close();
- }
-
- for (IListMapping listMapping : listMappings)
- {
- for (Pair<Long, Integer> idVersion : idVersions)
- {
- verifyCorrectIndices(listMapping, idVersion.getElement1(), idVersion.getElement2());
- }
- }
- }
-
- private void verifyCorrectIndices(IListMapping refMapping, long id, int version) throws Exception
- {
- String tableName = refMapping.getDBTables().iterator().next().getName();
-
- TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
-
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " AND " + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
- + CDODBSchema.LIST_IDX;
-
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- int indexShouldBe = 0;
-
- try
- {
- while (resultSet.next())
- {
- assertEquals("Index " + indexShouldBe + " missing for ID" + id + "v" + version, indexShouldBe++,
- resultSet.getInt(1));
- }
- }
- catch (AssertionFailedError e)
- {
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=" + id + " AND "
- + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + CDODBSchema.LIST_IDX);
- throw e;
- }
- finally
- {
- resultSet.close();
- }
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class NonAudit extends DBStoreVerifier
- {
- public NonAudit(IRepository repo)
- {
- super(repo);
-
- // this is a verifier for non-auditing mode
- assertEquals(true, getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
- // ... and for horizontal class mapping
- assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalNonAuditMappingStrategy);
- }
-
- @Override
- protected void doVerify() throws Exception
- {
- for (IClassMapping mapping : getClassMappings())
- {
- if (mapping != null && mapping.getDBTables().size() > 0)
- {
- verifyClassMapping(mapping);
- }
- }
- }
-
- private void verifyClassMapping(IClassMapping mapping) throws Exception
- {
- verifyNoUnrevisedRevisions(mapping);
- verifyUniqueId(mapping);
- verifyReferences(mapping);
- }
-
- /**
- * Verify that there is no row with cdo_revised == 0.
- */
- private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- assertEquals(true, resultSet.next());
- assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
- }
- finally
- {
- resultSet.close();
- }
- }
-
- /**
- * Verify that the id is unique.
- */
- private void verifyUniqueId(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
- + CDODBSchema.ATTRIBUTES_ID;
-
- ResultSet resultSet = getStatement().executeQuery(sql);
-
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
- }
- }
- finally
- {
- resultSet.close();
- }
- }
-
- private void verifyReferences(IClassMapping mapping) throws Exception
- {
- List<IListMapping> referenceMappings = ((HorizontalNonAuditClassMapping)mapping).getListMappings();
- if (referenceMappings == null)
- {
- return;
- }
-
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
-
- ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
- }
- }
- finally
- {
- resultSet.close();
- }
-
- for (IListMapping refMapping : referenceMappings)
- {
- for (Pair<Long, Integer> idVersion : idVersions)
- {
- verifyCorrectIndices(refMapping, idVersion.getElement1());
- }
- }
- }
-
- private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
- {
- String tableName = refMapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- int indexShouldBe = 0;
- try
- {
- while (resultSet.next())
- {
- assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
- }
- }
- finally
- {
- resultSet.close();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.verifier;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.IDBStore;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
+import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
+import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.tests.db.bundle.OM;
+
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * @author Stefan Winkler
+ */
+public abstract class DBStoreVerifier
+{
+ protected static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreVerifier.class);
+
+ private IRepository repository;
+
+ private IDBStoreAccessor accessor;
+
+ public DBStoreVerifier(IRepository repository)
+ {
+ this.repository = repository;
+ if (repository != null)
+ {
+ assertEquals(true, repository.getStore() instanceof IDBStore);
+ }
+ }
+
+ protected IRepository getRepository()
+ {
+ return repository;
+ }
+
+ protected IDBStore getStore()
+ {
+ return (IDBStore)repository.getStore();
+ }
+
+ protected Statement getStatement()
+ {
+ if (accessor == null)
+ {
+ accessor = (IDBStoreAccessor)repository.getStore().getReader(null);
+ }
+
+ try
+ {
+ return accessor.getConnection().createStatement();
+ }
+ catch (SQLException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ protected Connection getConnection() throws SQLException
+ {
+ return getStatement().getConnection();
+ }
+
+ protected DatabaseMetaData getMetaData() throws SQLException
+ {
+ return getConnection().getMetaData();
+ }
+
+ protected List<IClassMapping> getClassMappings()
+ {
+ ArrayList<IClassMapping> result = new ArrayList<IClassMapping>();
+ InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)repository.getPackageRegistry();
+ for (InternalCDOPackageInfo packageInfo : packageRegistry.getPackageInfos())
+ {
+ // CDO core package is not mapped in horizontal mapping
+ if (!packageInfo.isCorePackage())
+ {
+ for (EClass cls : EMFUtil.getPersistentClasses(packageInfo.getEPackage()))
+ {
+ result.add(getStore().getMappingStrategy().getClassMapping(cls));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ protected void cleanUp()
+ {
+ if (accessor != null)
+ {
+ accessor.release();
+ }
+ }
+
+ public void verify() throws VerificationException
+ {
+ try
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Starting {0}...", getClass().getSimpleName());
+ }
+
+ doVerify();
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("{0} completed without complaints...", getClass().getSimpleName());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new VerificationException(e);
+ }
+ finally
+ {
+ cleanUp();
+ }
+ }
+
+ protected void sqlDump(String sql)
+ {
+ ResultSet rs = null;
+
+ try
+ {
+ TRACER.format("Dumping output of {0}", sql);
+ rs = getStatement().executeQuery(sql);
+ int numCol = rs.getMetaData().getColumnCount();
+
+ StringBuilder row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c)));
+ }
+
+ TRACER.trace(row.toString());
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------+--");
+ }
+
+ TRACER.trace(row.toString());
+
+ while (rs.next())
+ {
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%10s | ", rs.getString(c)));
+ }
+
+ TRACER.trace(row.toString());
+ }
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------+-");
+ }
+
+ TRACER.trace(row.toString());
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+
+ protected abstract void doVerify() throws Exception;
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class VerificationException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public VerificationException(String message)
+ {
+ super(message);
+ }
+
+ public VerificationException(String message, Throwable t)
+ {
+ super(message, t);
+ }
+
+ public VerificationException(Throwable t)
+ {
+ super(t);
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class Audit extends DBStoreVerifier
+ {
+ public Audit(IRepository repo)
+ {
+ super(repo);
+
+ // this is a verifier for auditing mode
+ assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalAuditMappingStrategy);
+ }
+
+ @Override
+ protected void doVerify() throws Exception
+ {
+ for (IClassMapping mapping : getClassMappings())
+ {
+ if (mapping != null && mapping.getDBTables() != null)
+ {
+ verifyClassMapping(mapping);
+ }
+ }
+ }
+
+ private void verifyClassMapping(IClassMapping mapping) throws Exception
+ {
+ verifyAtMostOneUnrevised(mapping);
+ verifyUniqueIdVersion(mapping);
+ verifyReferences(mapping);
+ }
+
+ private void verifyAtMostOneUnrevised(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ TRACER.format("verifyAtMostOneUnrevised: {0} ...", tableName);
+
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
+ + CDODBSchema.ATTRIBUTES_REVISED + "= 0 GROUP BY " + CDODBSchema.ATTRIBUTES_ID;
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple unrevised rows for ID " + resultSet.getLong(1), true, resultSet.getInt(2) <= 1);
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Verify that the pair (id,version) is unique.
+ */
+ private void verifyUniqueIdVersion(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
+
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION + ", count(1) FROM "
+ + tableName + " GROUP BY " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION;
+
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple rows for ID " + resultSet.getLong(1) + "v" + resultSet.getInt(2), true,
+ resultSet.getInt(3) <= 1);
+ }
+ }
+ catch (AssertionFailedError e)
+ {
+ TRACER.trace(e.getMessage());
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + "=0");
+ throw e;
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ private void verifyReferences(IClassMapping mapping) throws Exception
+ {
+ List<IListMapping> listMappings = ((HorizontalAuditClassMapping)mapping).getListMappings();
+ if (listMappings == null)
+ {
+ return;
+ }
+
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+
+ ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+
+ for (IListMapping listMapping : listMappings)
+ {
+ for (Pair<Long, Integer> idVersion : idVersions)
+ {
+ verifyCorrectIndices(listMapping, idVersion.getElement1(), idVersion.getElement2());
+ }
+ }
+ }
+
+ private void verifyCorrectIndices(IListMapping refMapping, long id, int version) throws Exception
+ {
+ String tableName = refMapping.getDBTables().iterator().next().getName();
+
+ TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
+
+ String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
+ + "=" + id + " AND " + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
+ + CDODBSchema.LIST_IDX;
+
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ int indexShouldBe = 0;
+
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Index " + indexShouldBe + " missing for ID" + id + "v" + version, indexShouldBe++,
+ resultSet.getInt(1));
+ }
+ }
+ catch (AssertionFailedError e)
+ {
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=" + id + " AND "
+ + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + CDODBSchema.LIST_IDX);
+ throw e;
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class NonAudit extends DBStoreVerifier
+ {
+ public NonAudit(IRepository repo)
+ {
+ super(repo);
+
+ // this is a verifier for non-auditing mode
+ assertEquals(true, getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
+ // ... and for horizontal class mapping
+ assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalNonAuditMappingStrategy);
+ }
+
+ @Override
+ protected void doVerify() throws Exception
+ {
+ for (IClassMapping mapping : getClassMappings())
+ {
+ if (mapping != null && mapping.getDBTables().size() > 0)
+ {
+ verifyClassMapping(mapping);
+ }
+ }
+ }
+
+ private void verifyClassMapping(IClassMapping mapping) throws Exception
+ {
+ verifyNoUnrevisedRevisions(mapping);
+ verifyUniqueId(mapping);
+ verifyReferences(mapping);
+ }
+
+ /**
+ * Verify that there is no row with cdo_revised == 0.
+ */
+ private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ assertEquals(true, resultSet.next());
+ assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Verify that the id is unique.
+ */
+ private void verifyUniqueId(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
+ + CDODBSchema.ATTRIBUTES_ID;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ private void verifyReferences(IClassMapping mapping) throws Exception
+ {
+ List<IListMapping> referenceMappings = ((HorizontalNonAuditClassMapping)mapping).getListMappings();
+ if (referenceMappings == null)
+ {
+ return;
+ }
+
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+
+ ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+
+ for (IListMapping refMapping : referenceMappings)
+ {
+ for (Pair<Long, Integer> idVersion : idVersions)
+ {
+ verifyCorrectIndices(refMapping, idVersion.getElement1());
+ }
+ }
+ }
+
+ private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
+ {
+ String tableName = refMapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
+ + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ int indexShouldBe = 0;
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+ }
+}

Back to the top